REVENUE LEAKAGE AGENT

CLAUDE API AGENTIC AI PYTHON PDF PARSING PANDAS FLASK FINTECH CONTRACT RECONCILIATION

Inspired by a real workflow that recovered $500k in hidden revenue.

> WHAT IT DOES

An AI agent that reads merchant contracts (PDF), reconciles them against billing records (Excel, CSV or PostgreSQL/MySQL), detects revenue shortfalls, classifies their root cause, and drafts targeted recovery emails — automatically.

Each shortfall is analysed for financial materiality and collection urgency across monthly, annual, and multi-year minimum volume commitments (MVC). The result is a prioritised discrepancy summary your finance team can act on immediately.

> HOW THE PIPELINE WORKS

STEP 01

LOAD

Connect to your PostgreSQL or MySQL database via a SELECT query, or upload a billing file (CSV or Excel). The agent normalises any schema to merchant_id, year, month, billing_amount.

STEP 02

PARSE

pdfplumber extracts contract terms from each merchant PDF: MVC amounts, billing cadence (monthly / annual / 2-year), effective dates, and merchant name.

STEP 03

ANALYSE

Claude reconciles cumulative billing against contractual commitments, then classifies each shortfall — genuine leakage, seasonal variance, data error, or ramp-up — with a severity rating.

STEP 04

ACT

Review the discrepancy summary, filter by time period and status, then generate targeted recovery emails for selected merchants with one click.

> KEY FEATURES

> TRYING THE DEMO

// DEMO MODE

The live demo runs on pre-computed sample data covering 10 merchants across monthly, annual, and 2-year contracts. No database connection or API key is required — all results are served from a cached analysis with realistic SSE progress timing.

To deploy with a live pipeline (real database, real Claude API calls, real contracts), set DEMO_MODE=false and provide an ANTHROPIC_API_KEY in the hosting environment.

Interested in a private deployment for your finance team? Get in touch.

> HOW IT WAS BUILT

The idea came from a real finance workflow: a team manually comparing PDF contracts against billing exports in spreadsheets to find merchants underbilling against their minimum volume commitments. The process was slow, error-prone, and easy to deprioritise. This agent automates the entire loop.

The backend is a Flask app with a full agentic tool-use pipeline: pdfplumber extracts contract terms, pandas handles billing reconciliation, and the Claude API classifies each shortfall and drafts recovery emails. Progress is streamed to the browser via Server-Sent Events so the UI stays responsive during analysis. The demo mode re-plays pre-computed results with realistic timing so the tool can be evaluated without a live database or API key.

Projects on this website are free to download for charities and non-profit organisations — please get in touch via the contact page.