Document AI Platform
Turns invoices, forms and IDs into clean structured data without anyone keying it in.
AI-powered document processing platform that automatically extracts, classifies and validates data from invoices, forms, IDs and PDFs using a multi-engine OCR + NLP pipeline running on async Celery workers.

- Industry
- Enterprise / Back-office Automation
- Role
- AI & Backend Engineer
- Team
- Team project — about half of the repository’s commits are mine
- Type
- AI System
- Year
- 2025
01
Overview
Document AI Platform is an enterprise-grade solution that turns unstructured documents into clean, structured data. It automatically classifies document types and extracts fields from invoices, forms, identification documents and PDFs — at high accuracy and a fraction of the manual effort.
The processing core is an asynchronous pipeline: FastAPI accepts uploads and dispatches work to Celery workers (brokered by Redis) so large or scanned documents never block a request. Each document flows through an OCR stage (PaddleOCR with OpenCV pre-processing), layout reconstruction, and template-driven field extraction with Gemini, with Google Document AI / Vision available as a high-accuracy path.
A Next.js dashboard lets operators monitor pipelines, review extracted data and manage workflows, with audit trails for compliance. The whole system is containerized behind nginx for production deployment.
02
Business challenge
Enterprises spend countless hours manually keying data from invoices, forms and IDs — slow, error-prone and expensive, with large scanned PDFs making naive processing time out.
Before this system
03
Solution
Built an async, multi-engine document pipeline: FastAPI dispatches uploads to Celery workers, which run OCR (PaddleOCR + OpenCV), classification and template-driven extraction with Gemini, with Google Document AI available for tough documents.
What it does
04
My contribution
- Role
- AI & Backend Engineer
- Team
- Team project — about half of the repository’s commits are mine
- Scope of my work
- API, extraction pipeline, connectors, dashboard and reviewer screens, deployment
05
Product screenshots
Screens from the application itself. Select any image to view it full size.
06
Architecture
Swipe sideways, or expand to zoom.
From an uploaded file to validated, delivered data
Three ways in, one pipeline. API-key jobs go to a high-priority queue so integrations are not held up behind bulk dashboard uploads. Workers read digital files directly and scanned pages through PaddleOCR with layout reconstruction, and Gemini extracts the fields defined by the document’s category template. Results are validated against master data and written back to the configured destination, with reviewers assigned to a job checking anything flagged for review.
- Interface
- Service
- AI / ML
- Data store
- External system
How it fits together
- 01FastAPI API layer accepts uploads and enqueues jobs; Celery workers (Redis broker) run the heavy pipeline asynchronously with a scheduler for recurring tasks
- 02OCR stage runs PaddleOCR with OpenCV pre-processing and rebuilds page layout; category templates drive classification and field mapping
- 03Extraction stage sends the reconstructed text to Gemini with the category template; a validation service checks the extracted fields against master data
- 04Google Document AI / Vision available as a high-accuracy path; cloud storage via S3 (boto3)
- 05Next.js dashboard for monitoring, review and workflow management; PostgreSQL for data and audit trails
- 06Dockerized and served behind nginx for production
Data and API design
- 01A job is one batch and a task is one document; a job’s status is reconciled from the terminal states of its tasks.
- 02Category templates define which fields are extracted for each document type.
- 03API keys let external systems submit work, and those jobs route to the priority queue.
- 04Reviewers are assigned per job through a many-to-many relation between jobs and users.
- 05A WebSocket manager pushes job status to the dashboard as documents move through the pipeline.
07
Engineering challenges
01
A document must never stay “in progress” forever
- The difficulty
- Extraction calls an external model that can stall, hit a rate limit or be cut off mid-request. A worker that dies after marking a document as being worked on leaves it in that state permanently.
- Why it mattered
- A job is finished only when every document in it reaches a terminal state, so one stuck document holds up the whole batch and whoever is waiting for it.
- What was built
- Layered time budgets, each strictly inside the next: a per-attempt request timeout, a total retry budget, a Celery soft limit that raises inside the task so it can mark itself failed and reconcile its job, a hard limit that kills the worker as a last resort, and a scheduled reaper that recovers tasks whose worker died before its cleanup ran.
- Why this approach
- Each layer covers the failure the one before it cannot. A soft limit cannot interrupt a blocked native call, and a hard kill never runs cleanup code — so the limits are ordered deliberately, with defaults that match the production values.
- Result
- Every document ends as completed or failed. A job cannot hang in a phase status, and a failure is visible rather than silent.
02
Integrations should not queue behind bulk uploads
- The difficulty
- Dashboard users submit large batches, while a system calling the API with a key expects a prompt answer. On a shared queue the API request waits behind everything uploaded before it.
- Why it mattered
- To the calling system, an integration that times out waiting is a broken integration.
- What was built
- Two Celery queues. API-key jobs route to a high-priority queue and dashboard jobs to the default one; workers consume the priority queue first, with a prefetch of one so a worker never reserves a backlog of low-priority work.
- Why this approach
- Routing by task name keeps the pipeline code identical for both paths — only the queue differs — and needs no second worker fleet.
- Result
- API-submitted documents are picked up ahead of queued dashboard batches.
03
Scanned pages lose their structure when read as plain text
- The difficulty
- OCR returns words with coordinates, not rows and columns. Flattened into a stream of text, a table or a two-column form loses the relationships a field extractor depends on.
- Why it mattered
- The extraction model can only be as right as the text it is given.
- What was built
- Scanned PDFs are rasterised page by page, oversized pages are scaled down, PaddleOCR reads each page, and the output is rebuilt into a spatial layout before it reaches the model. Office and text files skip OCR and are parsed directly.
- Why this approach
- Reconstructing layout once, up front, means every later step sees the page the way a person would read it.
- Result
- Scanned documents arrive at extraction with their structure intact, and digital ones never pay the cost of OCR.
04
Documents live in other people’s systems
- The difficulty
- Source files sit in cloud buckets, shared drives, SFTP servers and databases, and results are expected back in those same places.
- Why it mattered
- A pipeline that only accepts manual uploads still leaves someone moving files by hand.
- What was built
- A connector interface with implementations for Amazon S3, Azure Blob Storage, Google Drive, SFTP, SQL databases, PostgreSQL, MongoDB, HTTP endpoints and local folders. A scheduled watcher picks up new files for continuous jobs, and finished results are delivered to the job’s target.
- Why this approach
- One interface keeps the pipeline unaware of where a file came from or where its result is going.
- Result
- A job can watch a source and write to a destination with no manual transfer in between.
08
Technology stack
- Frontend
- Next.js
- Backend
- FastAPIPythonCelery
- Data
- RedisPostgreSQL
- AI & Processing
- PaddleOCROpenCVGeminiTransformersGoogle Document AI
- Infrastructure
- DockerNginx
Why these choices
- FastAPI + Celery
- Extraction runs outside the request, so an upload returns immediately however large the document is.
- Redis
- Broker for the two priority queues.
- PaddleOCR + OpenCV
- Reads scanned pages on CPU inside the platform’s own containers.
- Gemini
- Extracts the fields a category template asks for from the reconstructed text.
- Google Document AI · Vision
- Available as alternate extractors.
- PostgreSQL
- Jobs, tasks, templates, users and audit data.
- Next.js
- Operator dashboard and reviewer workspace.
- Docker + Nginx
- One image for API, worker and scheduler, fronted by a single reverse proxy.
09
Security & scale
Security
Scalability
10
Business impact
Every figure is labelled with where it comes from: a measurement, an estimate, a design target, or a fact of the system as built.
95%+
Extraction accuracy
Share of fields extracted correctly, as reported for the project.
~10×
Faster than manual entry
Processing speed compared with keying the same documents by hand.
~85%
Less manual document work
Reduction in hand-keying once documents flow through the pipeline.
9
Source and target connectors
Cloud storage, file servers, databases and HTTP endpoints.
2
Priority queues
API-key jobs are routed ahead of dashboard batches.
What changed
- Data entry
- BeforeFields keyed by hand from invoices, forms and IDs.
- AfterFields extracted against a category template, then validated.
- Large scanned PDFs
- BeforeTimed out when processed inside a request.
- AfterProcessed on background workers; the upload returns immediately.
- Document variety
- BeforeNo single engine handled every document type well.
- AfterEach document is read by the path that suits it — direct parse or OCR.
Reduced document processing time by ~85% and lifted data accuracy to 95%+, turning a manual back-office bottleneck into an automated, auditable pipeline.
11
Project status
What I took from it
- Async pipelines (FastAPI + Celery) are the right shape for unpredictable, heavy document workloads.
- Multi-engine OCR with template-driven routing beats betting on a single model.
An asynchronous document pipeline that reads files from wherever they live, extracts the fields a template defines, validates them and writes the result back — built so that a slow model call or a dead worker can fail a document but never strand it.
Next step
Need a similar solution for your business?
Tell me what you are trying to build or fix. I will come back with how I would approach it, what it realistically takes and where the risks are.


