DocIntel

How it works

From a file in the inbox to checked, searchable data, in six automatic steps. A person only looks at what the system is unsure about.

Step 1

Check the file

The real type is read from the file's first bytes. Renamed, empty, damaged and locked files are stopped with a clear reason.

Step 2

Read every page

Text PDFs are read directly. Scans and photos are straightened, cleaned and read with OCR. Every Excel sheet is read.

Step 3

Find each invoice

A 1,000-page PDF is split into separate invoices by their numbers and page markers like “Page 2 of 3”.

Step 4

Extract with AI

A language model fills a fixed JSON form and must quote where each value came from. Hard-to-read pages are read from the image.

Step 5

Prove and check

Code checks every quote is really in the document; unproven values are removed. Then totals, tax, line items, dates, duplicates and other documents are checked.

Step 6

Make it searchable

Results go into PostgreSQL with full-text search and meaning vectors (pgvector), so staff can search by words or by meaning.

Measured on a labelled test set

Run 2026-11-10 · full report in the repository
Field accuracy100%every field compared with the answer key
Documents processed100%of valid files; 100% of broken files stopped cleanly
Planted problems caught55/55wrong totals, duplicates, missing values…
1,000-page batch17.3 min1000 pages, 789 invoices, on a small 2-CPU server

What it is built with, and why

Web app · Next.js · React

Fast, simple screens for upload, review and search.

API · Python · FastAPI

The best OCR and spreadsheet tools are in Python; FastAPI writes the interactive API documentation itself.

Background work · Redis · RQ workers

Slow OCR and AI work never blocks the website. Add workers to process more files at once.

Reading · Tesseract OCR · OpenCV · pypdfium2 · pandas

Free, local OCR with image clean-up; exact text from digital PDFs; every Excel sheet.

AI · OpenAI models through an n8n gateway

Strict JSON output. The API key stays inside n8n; the gateway allows only two kinds of calls.

Data and search · PostgreSQL · pgvector

One database for records, history, keyword search and meaning search: fewer moving parts.

No made-up values

Language models can sound sure while being wrong. So the model is never trusted on its own: it must quote the document, and plain code checks the quote and the value. Maths is done by code, never by the model. A missing value stays empty and is flagged.

Security

  • HTTPS everywhere; an access code can lock the demo, and a daily AI budget caps the cost.
  • File type checked from content, size and page limits, rate limits per address.
  • Containers run as a normal user with CPU and memory limits, on a private network.
  • The AI key is never in the app; document text is not stored by the AI provider (store: false).
  • Every manual change is logged: old value, new value, who, when, why.

Scaling up

Each part scales on its own: more workers for more files, more API copies behind the load balancer, a managed PostgreSQL for more data, object storage for originals. The queue absorbs bursts, failed jobs can be retried in one click, and every stage is timed in the processing history.