The problem
Bills arrive as PDFs, phone photos and Word files with no shared layout. Template-based OCR breaks on every new vendor, and sending every bill to the most capable model is slow and expensive. Indian bills add GST rules that a generic extractor knows nothing about.
My role
Solo build: architecture, extraction pipeline, validation scoring, database security, review UI, tests and CI.
Validate with code, not with another LLM
The score starts at 1.0. Each hard error (line items don’t sum to the subtotal, the total doesn’t match subtotal + tax − discount + round-off, a missing invoice number, a future date) costs 0.3; each soft flag costs 0.05. Below 0.5, Claude is called. It is cheap, explainable and cannot hallucinate.
GST rules that catch OCR misreads
GSTINs are checked against their built-in check character (a mod-36 Luhn variant), which catches most single-character misreads. CGST must equal SGST, and IGST vs CGST + SGST must match whether vendor and buyer are in the same state. These raise flags rather than errors, so a misread ID never triggers a paid fallback on its own.
Not locked to one AI provider
The primary extractor speaks the OpenAI API, so it can point at Gemini, Groq, OpenRouter or a local Ollama model, and Claude is optional. Every attempt’s model, latency and token counts are stored, so cost and quality can be compared per provider.
Row-level security and an audit trail
Postgres RLS and private storage keep each user’s bills unreachable from another session. When a user corrects a field, the original AI output is kept and the change is written to an audit log.