How preethu13/insurance-rag-system works
This repository is an insurance-document RAG question-answering product, with both a documented CLI flow and a web/API interface backed by a Phase 2 multi-agent pipeline. The documented document path is PDF OCR and extraction, clause-aware indexing, hybrid retrieval, then grounded answers; the API routes queries into the orchestrator. Phase 2’s workflow sequence names query understanding, retrieval, verification, reasoning, risk, and contradiction stages. Observability is a separate internal capability. Some implementation details are unsampled, so uncertain internal dispatch links are marked dashed.
Main entry points: orchestrator.py Agent orchestrator · workflow_engine.py Workflow sequence · query.py Query endpoint · app.py CLI query interface
Components 25
Document preparation
- OCR extraction
ingest.py - Extracted JSON
- Clause indexing
index.py - ChromaDB
- BM25 index
User interfaces
- Query dashboard
frontend/src/components/QueryDashboard.tsx - Frontend API client
frontend/src/services/apiClient.ts - Query endpoint
backend/app/routers/query.py - CLI query interface
app.py
Answer pipeline
- Agent orchestrator
phase2/orchestrator/orchestrator.py - Workflow sequence
phase2/orchestrator/workflow_engine.py - Query understanding
phase2/agents/query_agent.py - Query processing
phase2/services/query_processing_service.py
Evidence analysis
- Evidence retrieval
phase2/agents/retrieval_agent.py - Hybrid retrieval
phase2/services/retrieval_service.py - Evidence verification
phase2/agents/verification_agent.py - Policy reasoning
phase2/agents/reasoning_agent.py - Risk assessment
phase2/agents/risk_agent.py - Contradiction analysis
phase2/agents/contradiction_agent.py - Response builder
phase2/agents/response_builder.py
Observability
- Observability facade
phase2/observability/facade.py - SQLite telemetry store
phase2/observability/storage/sqlite_storage.py - JSONL telemetry store
phase2/observability/storage/json_storage.py
Other components
- Question asker
- Policy PDFs
Connections 35
- Policy PDFs → OCR extraction: extracts text
README.md - OCR extraction → Extracted JSON: writes JSON
README.md - Extracted JSON → Clause indexing: chunks documents
README.md - Clause indexing → ChromaDB: builds vector index
README.md - Clause indexing → BM25 index: builds keyword index
README.md - Question asker → Query dashboard: asks question
frontend/src/components/QueryDashboard.tsx - Query dashboard → Frontend API client: submits query
frontend/src/components/QueryDashboard.tsx - Frontend API client → Query endpoint: sends API request
- Question asker → CLI query interface: asks question
README.md - CLI query interface → ChromaDB: retrieves evidence
README.md - CLI query interface → BM25 index: retrieves evidence
README.md - CLI query interface → Question asker: returns grounded answer
README.md - Query endpoint → Agent orchestrator: orchestrates query
backend/app/routers/query.py - Agent orchestrator → Workflow sequence: gets execution sequence
- Workflow sequence → Query understanding: names stage
phase2/orchestrator/workflow_engine.py - Workflow sequence → Evidence retrieval: names stage
phase2/orchestrator/workflow_engine.py - Workflow sequence → Evidence verification: names stage
phase2/orchestrator/workflow_engine.py - Workflow sequence → Policy reasoning: names stage
phase2/orchestrator/workflow_engine.py - Workflow sequence → Risk assessment: names stage
phase2/orchestrator/workflow_engine.py - Workflow sequence → Contradiction analysis: names stage
phase2/orchestrator/workflow_engine.py - Query understanding → Query processing: processes query
phase2/agents/query_agent.py - Agent orchestrator → Query understanding: dispatches query
- Agent orchestrator → Evidence retrieval: dispatches stage
- Agent orchestrator → Evidence verification: dispatches stage
- Agent orchestrator → Policy reasoning: dispatches stage
- Agent orchestrator → Risk assessment: dispatches stage
- Agent orchestrator → Contradiction analysis: dispatches stage
- Evidence retrieval → Hybrid retrieval: uses retrieval service
- Hybrid retrieval → ChromaDB: searches vectors
- Hybrid retrieval → BM25 index: searches keywords
- Agent orchestrator → Response builder: builds final response
- Query endpoint → Policy reasoning: reads reasoning result
backend/app/routers/query.py - Query endpoint → Question asker: returns response
- Observability facade → SQLite telemetry store: stores telemetry
- Observability facade → JSONL telemetry store: stores telemetry