Mirco Bochicchio
  • Projects
  • About
  • Experience
Email me

© 2026 Mirco Bochicchio. Built by me, for me: I was the customer again.

Privacy and credits
  • GitHub profile
  • LinkedIn profile

Revenue Leakage Defender· Open-source prototype

Catch overbilling before you pay it.

Upload a supplier invoice and its framework contract. You get every discrepancy and a draft dispute email.

View codeEmail me

Invoice checks are slow, so they get sampled.

Checking every supplier invoice against its framework contract by hand takes too long, so teams check a sample. Rate errors, wrong line totals and non-compliant payment terms slip through as overbilling.

Customer: me. I wanted to see how far GenAI can go in a sales and finance workflow before a human has to step in.

How it works

  1. Read the documents

    PDFs are parsed in memory. An unreadable file goes straight to the report instead of being guessed at.

    Invoice Framework contractText in memory
    Both files are read in memory. Nothing is written to disk.
  2. Extract invoice and contract

    Two LLM calls run in parallel and return structured data, validated against Pydantic schemas.

    Invoice LLM call Invoice data
    Framework contract LLM call Contract data
    Two LLM calls run in parallel. Each result is validated against a Pydantic schema.
  3. Check the maths without AI

    Line totals, VAT, rate caps, payment terms and validity are checked in plain Python with exact decimals. Every amount must appear in the PDF text.

    Line totals VAT Rate caps Payment terms Validity
    Plain Python, exact decimals. No LLM involved.
  4. Ask the LLM only when needed

    When the invoice breaks a contract term, the LLM weighs whether a clause justifies it. Arithmetic errors never go to the LLM.

    Arithmetic error Flagged, no LLM
    Contract term broken LLM weighs the clause
    Arithmetic errors are flagged directly. The LLM only judges contract terms.
  5. Report and draft

    Each invoice ends in one of three outcomes: approved, discrepancies found or review required. A dispute email is drafted for a person to review and send.

    Approved Discrepancies found Review required Dispute draft
    Three possible outcomes, plus a draft email that a person reviews before sending.

Built to be trusted

Nothing saved to disk

Uploaded PDFs are read in memory only.

Fails closed

Incomplete or unverifiable data means review required, never approved.

A human decides

The dispute email is a read-only draft. A person reviews it before anything is sent.

Swappable LLM provider

One provider interface: Gemini, a mock for tests, or another model through environment variables.

Observable

Live progress for each pipeline step in the UI, plus LangSmith tracing.

Tested offline

51 tests that need no real LLM. Fake models cover the worst cases: one justifies every charge, one times out, one invents amounts.

Inside the app

  • Upload screen with the invoice and the framework contract loaded
    Upload the invoice and the contract.
  • Discrepancy table with severity and reasoning for each line
    Every discrepancy, with severity and reasoning.
  • Draft dispute email listing the four discrepancies
    A dispute draft, ready for human review.

Built with

  • Python
  • FastAPI
  • LangGraph
  • Pydantic
  • pdfplumber
  • Gemini
  • LangSmith

Runs locally today. The design maps onto AWS: API Gateway and Lambda, Bedrock, S3, DynamoDB and SES.

All projectsNext: Leap Motion robot arm