Inspiration
Investigators in customs, trade finance and compliance spend hours reading stacks of PDFs, looking for numbers that don't agree. A shipment is a good example. The purchase order, invoice and payment receipt say USD 48,000. The customs declaration and insurance certificate say USD 68,000. Nobody wants to find a USD 20,000 gap by eye, and a chatbot that "summarizes" the files can invent an answer. We wanted a tool that investigates documents and shows its proof.
Don't just read documents. Investigate the truth behind them.
What it does
VERITAS AI is a multi-tenant platform that investigates a set of business documents:
- Extracts fields with provenance. Each value keeps its page, bounding box, method and model version. A failed extraction is stored as
nullwith statusuncertain, never guessed. - Finds contradictions across documents. Deterministic rules run first. In the demo case they produce exactly one
financial_discrepancyof USD 20,000.00, backed by 5 evidence items. - Builds an evidence graph. Entities and relationships are linked, and every edge carries an
evidence_id. - Examines document integrity. It checks PDF structure, visual regions and stamps. Its severity is capped at medium, and every run states its limitations.
- Compares an original with a test document. The Comparison Lab finds changed regions, and a vision model checks them.
- Runs a bounded investigation. Eight LangGraph agents work through allowlisted, read-only tools. The run pauses for human approval before the report is written.
- Exports cited reports. PDF, DOCX, XLSX and JSON, with every citation re-checked against real database rows.
It never declares a document authentic or forged, and never labels a person or company fraudulent. It reports observations, evidence strength and limits for a human to review.
How we built it
We built it with Kiro, using spec-driven development: 13 specs (requirements, design, tasks), 10 steering files, 10 custom agents and 8 hooks, all committed in /.kiro.
The backend is a modular monolith: FastAPI, SQLAlchemy 2 and PostgreSQL 16 with row-level security, Celery and Redis, with Neo4j as a derived evidence graph fed by a transactional outbox. Document processing uses PyMuPDF, PaddleOCR, Docling and OpenCV. Models are reached through one OpenAI-compatible provider interface, and we ran Qwen2.5 locally through Ollama. The frontend is React, TypeScript, Tailwind, PDF.js and React Flow.
Challenges we ran into
- No fake results. Every finding, graph edge and citation must resolve to a real extracted field or evidence row. We enforced this in the database, not just in code review, and an anti-fabrication check rejects any extracted value that doesn't appear on the cited page.
- Untrusted documents. Uploaded content is data and never instructions. Agents can only call permissioned, case-scoped tools.
- Tenant isolation. The app connects as a non-owner Postgres role, so row-level security always applies.
- Real bugs we fixed with tests. For example, deskew rotated blank pages, pagination repeated page 1 because of a
+in a cursor, and two OpenCV builds broke thecv2package.
Accomplishments that we're proud of
- The demo case finds the USD 20,000 difference through real processing, with every citation pointing to the exact page and value.
- 447 backend and 68 frontend tests, including Hypothesis property tests for tenant isolation and path traversal.
- A full browser test of the shipment scenario with a live local model: upload, finding, investigation paused for review, approval and report.
What we learned
Deterministic rules first, with the model only interpreting, gives results you can reproduce and defend. Honest limits ("uncertain", severity caps, human review) are a feature in an investigative tool.
What's next for VERITAS AI
Optional LLM interpretation of findings, page-image extraction with the vision model, and embeddings with a reranker for retrieval.
All demo data is synthetic and labelled "SYNTHETIC DEMONSTRATION DATA".
Built With
- celery
- docker
- docling
- fastapi
- kiro
- langgraph
- neo4j
- nginx
- ollama
- opencv
- paddleocr
- pdf.js
- postgresql
- pymupdf
- python
- qwen
- react
- react-flow
- redis
- seaweedfs
- sqlalchemy
- tailwindcss
- typescript
- vite