A bilingual document intelligence platform that connects extraction, reviewed facts, policy evidence and bounded AI investigation. Every authoritative outcome has an explicit path back to its source.
Business documents contain useful facts, but extracting a plausible value is only the beginning. A policy decision also depends on the correct source, current permissions, reviewed data and the meaning of the applicable rule. English and Arabic inputs add parsing, normalization and OCR challenges.
NEXUS separates proposing information from granting it authority. Models extract candidates and investigate with bounded tools. Shared eligibility checks, explicit human decisions and deterministic Python govern the official result. Source quotations and audit records let a reviewer reconstruct that decision.
Context & contribution
An individual engineering project spanning a Next.js interface, FastAPI services, persistent workflows, retrieval, authorization and evaluation. Designed and verified in a local development environment.
Explore the system
Follow a document to its decision.
Select a component to inspect its contract.
Document → evidence → decisionIllustrative system map
Document upload
Accept bounded, authorized source files.
Input
PDF, DOCX, PPTX, UTF-8 text and image files.
Output
Persisted original, document record and queued processing job.
Authority boundary
Session, CSRF, ownership, byte and structure limits apply before processing.
The workflow summarizes the end-to-end lifecycle. Policy ingestion and approval can happen independently. Restricted specialists investigate, while canonical data and verified rules determine the final evaluation.
Engineering challenges
Where the difficult work lives.
An approval can become stale
Changing a source, reviewed field or permission can invalidate an earlier result. Workflow fingerprints, current source validation and resource checks on resume prevent historical approval from silently becoming current authority.
A retry must not overwrite newer work
Database-backed jobs use expiring claims, bounded attempts and completion fencing. Business writes and job completion commit together, so a worker holding an expired claim cannot publish a stale result.
Bilingual support needs separate measurements
Unicode and RTL rendering are distinct from reliable Arabic OCR and semantic interpretation. Search normalization preserves original quotations, while OCR and extraction quality have separate development evidence and outstanding release gates.
Implementation & trade-offs
Every choice has a boundary.
Authorize before ranking
SQL scopes the candidate passages to the current organization, policy and enabled index before BM25 or vector ranking. Citation reads revalidate source hashes and offsets.
Trade-offThis maintains a clear access boundary. Exact vector scans and the 5,000-candidate bound limit scale. Scoped ANN retrieval is a future option when measurements justify it.
Make hybrid retrieval optional
Keyword retrieval is the default. A pinned local multilingual ONNX encoder adds 384-dimensional vectors, cosine ranking and reciprocal rank fusion with BM25.
Trade-offOptional model assets keep the basic path lightweight. Semantic retrieval adds memory and model-version management, while better recall still does not establish answer correctness.
Persist review interruptions
LangGraph coordinates separate Document and Policy specialists with disjoint tools. SQLite checkpoints persist review pauses, and canonical facts are reloaded before evaluation.
Trade-offA single-host checkpoint store keeps the system understandable. Distributed orchestration, retention and production recovery still require further work.
Evaluate the complete approved rule set
Search passages support investigation. The deterministic evaluator independently loads current, source-verified approved rules and reviewed document fields.
Trade-offA narrow supported monetary grammar favors inspectable behavior. Unsupported wording stays review-gated, and field review does not itself approve an expense.
Built with
Python
FastAPI
Next.js
TypeScript
Gemini
LangGraph
PostgreSQL / SQLite
SQLAlchemy
BM25 / ONNX embeddings
Docker
Pytest
Playwright
Results & evaluation
The evidence, with its scope.
Historical repository results. Methods and limitations travel with the numbers.
Hybrid Recall@5
87.5%
Fixed 40-query synthetic bilingual development benchmark
Hybrid MRR@5
0.9635
Same benchmark, with original source quotations preserved
Backend tests passed
401
October 31, 2026 documentation checkpoint · 9 opt-in skips
Retrieval on the fixed bilingual development set
32 source policies, 40 queries split equally between English and Arabic, and 8 unanswerable queries. Each answerable label includes both translated sources. Recall@5 measures recovery of both.
Repository-reported retrieval benchmark
Method
Recall@5
MRR@5
Abstention
Keyword
50.0%
0.8333
87.5%
Semantic
79.7%
0.8750
87.5%
Hybrid
87.5%
0.9635
75.0%
Hybrid improves recall here, while unanswerable abstention drops to 75%. Arabic abstention is 50% on four unanswerable queries. These are small development samples.
Inspect an actual application captureRepository application capture using synthetic fixtures and scripted generation. The authorization, review and deterministic evaluation paths are the actual application.
Limits & lessons
What the work establishes. What needs more evidence.
The retrieval benchmark has 32 policies and 40 queries, including 8 unanswerable queries. It is synthetic development evidence, with no held-out enterprise accuracy claim.
Hybrid Arabic unanswerable abstention is 50% (2 of 4 queries), and relevance precision across returned citations is 43.75%. Exact quotation integrity does not guarantee relevance.
Documented Arabic scanned-field accuracy is 50% on four development scans. Broader OCR, extraction and live model-quality evaluation remain open.
Public deployment, independent security review, SSO/MFA, production backups and sustained load/SLO validation remain outstanding. Investigation/workflow frontend gateways are development-only.
Engineering takeaway
Reliability comes from the boundaries around the model. A shared review predicate, current source checks and fenced state transitions are as important to an explainable result as the prompt or retrieval strategy.
Inspect the work
Go to the source.
Selected implementation and documentation reviewed for this case study.