End-to-End Architecture
The system transforms raw insurance PDFs through a multi-stage pipeline into a queryable knowledge layer that combines vector similarity, graph traversal, and LLM synthesis with full regulatory-grade provenance.
◆ Core Design Principles
The architecture follows a three-tier storage hierarchy (raw → processed → semantic) with bidirectional traceability. Every chunk knows its parent page and PDF. Every PDF knows all its chunks and its TTL representation. This means when a document is updated, the system invalidates only the affected TTL files and re-embeds only the changed chunks — avoiding a full reprocessing cycle across all 100K documents.
◆ Why Hybrid Retrieval?
Pure vector RAG systems offer fast fuzzy matching but can return semantically similar yet factually contradictory chunks. Pure graph queries are precise but brittle — they break when terminology varies. The orchestrator intelligently routes each query to the optimal retrieval pattern, combining broad vector recall with the structural precision of SPARQL graph traversal.
Hierarchical ID System & File Layout
A deterministic naming convention that lets you reconstruct full paths from any chunk ID — critical when returning search results with regulatory-grade source citations.
◆ Directory Structure
◆ Chunk Metadata Schema
Every chunk carries three critical pieces of metadata that enable full provenance tracing from the final answer back to the exact PDF page and paragraph:
Intelligent Database Routing
The orchestrator classifies each incoming query by intent, entity density, comparison indicators, and reasoning depth — then routes it to the optimal retrieval pattern among five distinct strategies.
◆ DatabaseRouter Implementation
See the Orchestrator in Action
Enter a query (or pick an example) and watch the system classify it, route it to the right databases, retrieve context, and synthesize a cited answer — step by step.
▶ Query Flow Simulator
InteractivePDF Page Attribution & Dual-Pane UI
In financial services, every AI-generated statement must trace back to an exact source page. Click any citation in the answer pane below to see the corresponding PDF text highlight.
Critical illness coverage under the Prudential Term Life policy includes heart attack, stroke, and major organ transplant. The policy specifies that for pre-existing conditions, a mandatory waiting period of 90 days applies before any claims can be filed. However, it's important to note that accidental injuries carry no waiting period and are covered from day one of the policy.
Section 4.2 — Critical Illness Coverage
Critical illness coverage includes heart attack, stroke, cancer, kidney failure requiring regular dialysis, major organ transplant, coronary artery bypass surgery, and paralysis of limbs. Additional riders may be purchased for enhanced coverage.
Section 7.1 — Waiting Periods
For pre-existing conditions disclosed at the time of policy issuance, a mandatory waiting period of 90 (ninety) days shall apply before any claims related to such conditions may be filed.
Section 7.3 — Exceptions
Accidental injuries resulting from unforeseen events shall carry no waiting period. Coverage commences from the date of policy activation (Day 1).
◆ How Provenance Tracking Works
Each chunk carries bounding box coordinates (x, y, width, height) from pdfplumber extraction. When the LLM generates an answer, it includes chunk IDs in square brackets, such as [C042]. After generation, the system parses these IDs, maps them to page numbers and bounding boxes, and renders a semi-transparent highlight overlay on the PDF viewer at those coordinates. This produces a Bloomberg Terminal-style dual-pane experience: the AI answer on the left, the highlighted source document on the right.
Semantic Clustering for 100K Files
A two-level TTL strategy: individual files for precision updates, plus semantic cluster files for efficient cross-policy SPARQL queries. Clusters are rebuilt quarterly based on query co-occurrence patterns.
◆ Cluster Size Guidelines
Based on GraphDB performance benchmarks, each cluster TTL file should stay under 50MB and contain no more than 1,000 policies. Larger clusters slow SPARQL query planning. If a semantic category exceeds this threshold (for example, 2,000 term life policies), split by time period — such as term_life_2020_2022.ttl and term_life_2023_2024.ttl.
◆ Dynamic Re-clustering Logic
Every quarter, analyze query logs to find frequently co-accessed policies. If users often compare "Prudential Term Life" with "HDFC Term Life," those should reside in the same cluster regardless of their provider classification. The Louvain community detection algorithm on the query co-occurrence graph identifies these natural groupings automatically.
How Knowledge Graphs Prevent Fabrication
Knowledge graphs enforce ontological constraints that vector search alone cannot provide. The graph structure forces precision — you literally cannot retrieve contradictory waiting periods without also retrieving their qualifying conditions.
Query: "What's the waiting period for this policy?"
Retrieved Chunk A: "Waiting period is 90 days."
Retrieved Chunk B: "No waiting period for accidents."
LLM Output: "The waiting period is 45 days for accidents."
The LLM "averaged" two contradictory facts because it had no structural context about which condition each clause applies to. This is a dangerous hallucination in financial services.
Query: "What's the waiting period for this policy?"
Graph Path 1: Policy → Clause_WaitingPeriod → appliesTo → PreExistingConditions → 90 days
Graph Path 2: Policy → Clause_AccidentCoverage → appliesTo → AccidentalInjury → 0 days
LLM Output: "The waiting period is 90 days for pre-existing conditions. Accidental injuries have no waiting period."
The ontology forces the LLM to distinguish conditions. Each waiting period is structurally bound to its qualifying context, making fabricated averages impossible.
◆ TTL Representation — Ontological Constraints in Action
◆ Contradiction Detection SPARQL Query
Run this query periodically to catch data quality issues before they cause hallucinations. If it returns results, two clauses claim different waiting periods for the same condition — a red flag that must be resolved at the data layer.
Real-World Database Choices
What major financial and legal organizations actually use in production — and the recommended stack for an insurance/wealth planning domain with heavy FIBO ontology usage.
| Organization | Vector DB | Graph DB | Document Store | Orchestration |
|---|---|---|---|---|
| Bloomberg Terminal | Elasticsearch dense_vector | Neo4j | MongoDB | Custom Python + GraphQL |
| Thomson Reuters | Pinecone migrated from Faiss | Ontotext GraphDB + FIBO | PostgreSQL + JSONB | Airflow + FastAPI |
| LexisNexis | Azure Cognitive Search hybrid BM25+vec | Amazon Neptune | Azure CosmosDB | Azure Durable Functions |
| JPMorgan AI | Faiss custom sharding | Neo4j Enterprise + Bloom | Oracle DB | Kubernetes microservices |
★ Recommended Stack for Insurance + FIBO Domain
Pinecone
Serverless, hybrid search, production-ready
Ontotext GraphDB
Best SPARQL 1.1, FIBO-optimized
PostgreSQL 15+
ACID, JSONB indexing, proven
Redis
Frequent query results
LangGraph
Custom tools for vector/graph switching