Automation2026
Invoice Automation Pipeline
A self-hosted pipeline that reads invoice PDFs, extracts fields with an LLM, validates them and routes uncertain ones to a human.
97.5%
invoices fully correct
Overview
An end-to-end invoice processing system built on n8n. It accepts text or scanned PDFs, runs OCR when needed, extracts structured fields with an LLM, applies business validation rules, blocks duplicates, and either auto-posts the invoice or asks a person to approve it by email.
The problem
Manual invoice entry is slow and error-prone, but fully automatic extraction can't be trusted blindly. The goal was automation with guard-rails.
How it works
- 1Invoice PDF arrives — text-based or scanned.
- 2A FastAPI OCR service (PyMuPDF + Tesseract) extracts the text.
- 3GPT-4o-mini turns the text into structured invoice fields.
- 4Rule checks validate totals, dates and required fields.
- 5A unique hash in Postgres blocks duplicate invoices.
- 6Clean invoices auto-post; uncertain ones go to Gmail for Approve / Reject.
Highlights
- 39 of 40 synthetic test invoices extracted fully correctly
- Human-in-the-loop approvals via Gmail “send and wait”
- Idempotent de-duplication with a UNIQUE hash constraint
- Runs fully self-hosted with Docker
Next project
YouTube & Web Summarizer