Document AI
Invoice AI
Document AI that reads invoice PDFs into structured data, with duplicate detection and a dashboard.
- Role
- Full-stack AI engineer
- Timeline
- 2025
Stack
- Python
- FastAPI
- Next.js
- Firebase
- OpenAI
- Invoice PDF
- Page images
- AI stepAI extractionvision model
- Duplicate check
- Dashboard
The problem
Green Earth, a recycling company, receives invoices from many vendors, and every one is laid out differently. Reading them reliably usually means building a template for each vendor, or typing the numbers in by hand.
This system had to read scanned and handwritten invoices without per-vendor templates, handle a stack of them at once, and keep the same invoice from being saved twice.
What I built
Invoice AI takes an invoice PDF, converts each page to an image, and has a vision model read it. The model returns the vendor, dates, line items, quantities, prices, subtotal, tax and total as structured data.
I built it as a Python and FastAPI backend with a Next.js dashboard on Firebase. Invoices can be uploaded one at a time or in a batch, with progress shown as each one finishes. Saved invoices go through a duplicate check, and the dashboard shows the data with vendor charts, filters by item, and standardised vendor names.
The hard parts
No templates to maintain
Every page goes to one vision model with a structured output format, so a new vendor layout needs no new code or template.
One model call per invoice
The first version made a model call for every page. I changed it to send all the pages of an invoice in one call, with smaller page images, which cut both the time and the cost of each invoice.
A stack of invoices at once
Batches are processed in parallel, with a time limit on each step so one bad scan cannot hold up the rest. Results stream back to the dashboard as each invoice finishes.
More than totals
The model returns the whole document as structured data: invoice and PO numbers, dates and terms, vendor and customer details, delivery and shipping information, and every line item. Missing fields come back empty instead of guessed.
The same invoice twice
When an invoice is saved it is checked against the ones already stored, matching on invoice number first and then on filename, so duplicates are caught instead of silently doubling up.
Where it is now
I built Invoice AI for Green Earth, the same client as TrueCert.