AI Document Processing Platform
A platform for extracting structured data from PDF invoices and checking its completeness and validity. Incomplete or invalid cases require operator review, with optional suggestions from a locally run AI model.
The problem
Extracting text from a PDF is not enough to produce reliable data. If the document is a scan, the text must first be recognised through optical character recognition (OCR). Extracted fields may be incomplete or invalid, and processing can stop. An AI model may also suggest values unsupported by the document. The process should make it possible to check the data, trace decisions and identify errors.
What I built
I built a Python platform with FastAPI that accepts PDF documents and extracts their embedded text. If the extracted text is insufficient, it uses Tesseract to read text from images of the pages.
The platform classifies documents and, when it identifies an invoice, extracts its number, date, supplier, currency and total amount. It checks that required fields are present, that the date and currency are valid, and that the total amount is greater than zero. Complete, valid invoices are approved automatically; incomplete or invalid ones require operator review. Temporal coordinates the processing stages and manages time limits and retries.
The React console shows work queues and lets operators view the PDF alongside extracted data, correct values, and approve or reject invoices that need review. Suggestions from the local model run through Ollama are optional and shown separately. Operators can choose which suggestions to use when correcting the data.
The path of an invoice
Design decisions
Use AI as an aid
Invoice approval depends on automated checks and, when needed, an operator’s review. The model generates suggestions separately from the extracted data; it does not change them or approve the document.
Preserve decision history
Corrections and review decisions are recorded separately from extracted data, including whether corrected values were entered by the operator or suggested by the AI model. When a document is processed again, the new run links to its predecessor and the earlier results are preserved.
Handle interruptions between stages
The document record and the request to start processing are saved in the same transaction. A separate process starts the Temporal workflow, which records its execution history. If the workflow resumes after an interruption, activities reuse results that were already saved. The console queries the API, which reads the document state from PostgreSQL.
Status and limitations
It is a local demo with synthetic documents. Field extraction is supported only for invoices. Purchase orders, credit notes and unrecognised documents are marked as unsupported. The local AI model is optional and disabled by default.
The demo is not intended for confidential documents or files from untrusted sources. The backend is intended to run locally. Public access requires additional security measures, including per-user authentication and authorization. Results from a small set of synthetic documents are not enough to assess extraction accuracy on real documents.