Architecture¶
Service Boundaries¶
graph TD
Client[Client Request] --> Traefik[Traefik Reverse Proxy]
Traefik --> FastAPI[FastAPI Analytics Service]
FastAPI --> Cache[(Redis Cache)]
FastAPI --> DB[(PostgreSQL)]
FastAPI --> LLM[LLM Provider]
FastAPI --> Analytics[Analytics Engine]
Request Lifecycle¶
- User submits a natural-language query to
/query. - System checks Redis cache for an exact match mapped to the
dataset_version. - If miss, the LLM Provider creates a deterministic
Query Plan. - The
Analytics Enginereads the plan and executes operations againstNormalizedRecordin PostgreSQL usingDecimalarithmetic. DisagreementMetadataandCitationrecords are fetched based on the lineage.- A response is formatted, cached in Redis, and returned.
Ingestion Pipeline¶
CSVs are parsed by the Ingestion Service. If discrepancies are found between sources (e.g., source A vs source B for a stock price on the same date), a ReconciliationDecision is generated and a unified NormalizedRecord is created.