Automating Invoice Processing with OCR + LLMs + FastAPI + Streamlit
Over the last few days, I built a small but powerful end-to-end invoice automation system — from PDF upload to structured data, with duplicate detection to prevent fraud and re-processing.
The goal was simple:
What the system does
This turned into a very practical AI + backend engineering exercise applicable to AP automation and fintech workflows.
High-Level Architecture
+------------------+
| PDF Invoice |
| Upload (UI) |
| Streamlit |
+--------+---------+
|
v
+------------------+
| FastAPI Backend |
+------------------+
|
v
+------------------+ +-------------------+
| OCR Layer | | LLM Extraction |
| (PDF -> text) |-----> | (Field Parsing) |
+------------------+ +-------------------+
|
v
+------------------------------+
| Duplicate Detection Module |
| (checksum + DB lookup) |
+------------------------------+
|
v
+------------------------------+
| SQLite Database |
| invoices table |
+------------------------------+
|
v
+------------------------------+
| Streamlit Viewer |
| list + search invoices |
+------------------------------+
Key AI Component — LLM Field Extraction
Instead of brittle regex-only parsing, an LLM helps map messy OCR text into structured JSON fields such as:
This allows support for:
✔ different invoice layouts ✔ different vendors ✔ noisy OCR text
🔐 Duplicate Invoice Detection (very important)
To prevent:
I added:
Flow:
This mirrors real AP automation systems.
What I learned
Tech Stack
✅ Real-world applications
How would you tackle invoicing in different formats ?