← Back to work

Document AI / Project notes

KnowledgeHub AI - Private Document Data Extraction

PythonFastAPISQLAlchemyAlembicPostgreSQLpgvectorOllamaRapidOCRNext.jsTypeScriptTailwind CSSDocker

Overview

I built KnowledgeHub AI, a multi-tenant platform that turns invoices and similar business documents into structured, reviewed spreadsheet data. It runs entirely on the customer's own hardware with local LLMs through Ollama, so sensitive documents never reach a cloud service. It began as a document Q&A (RAG) system and grew into schema-driven extraction.

Extraction is hybrid: rule-based readers handle fields they can validate, and a local LLM fills the gaps, merged field by field. Document types are defined as data, not code, so new formats can be added without rewriting the pipeline. The first schema is the Indian GST purchase invoice, with deterministic checks for tax-ID check digits, total = subtotal + tax, tax-rate sanity and duplicate invoices. Reviewers correct and approve results in a web review screen, and approved data exports to Excel.

The backend uses FastAPI, SQLAlchemy, Alembic, PostgreSQL with pgvector, and a Postgres-backed job queue, with OCR (RapidOCR, PyMuPDF) for scanned files. The frontend is Next.js with TypeScript. Tenant isolation, an audit log, and docker compose packaging support on-premise delivery.

The problem

Let organisations in privacy-sensitive fields such as finance, legal, healthcare and logistics extract data from documents into validated spreadsheets without sending the files to a third-party cloud.

The result

Built the end-to-end flow: ingestion and OCR, hybrid rule + local-LLM extraction, validation, human review with approval, and Excel export, plus a benchmark harness with synthetic invoices for comparing local models.

Document AI, Private LLM, On-premise, OCR, Invoice extraction, Data extraction, Automation