Architecture
Generative BI over a governed semantic layer
A user asks a business question and gets a dashboard in seconds. The AI interprets and chooses; definitions, joins and SQL are deterministic and auditable.
Swipe the diagram sideways to see all of it.
AI (Claude)DeterministicTrust / controlData
Principles
01
The AI chooses and combines; it doesn't calculate
The model returns a typed QueryPlan (metrics, dimensions, filters). It never writes SQL or numbers.
02
Logic lives in the semantic layer
Ratio of sums, hectares counted once, required standard: rules in versioned YAML, not prompts.
03
Deterministic SQL
Same plan → same SQL, byte for byte. Declared joins only. Snapshot tests in CI.
04
Better “I don't know” than a wrong number
If a metric is missing, it refuses and offers the closest. Known gaps are declared.
05
Every number is traceable
Definition, plan, SQL, source tables, sample rows, as-of date and semantic version.
06
Evals are product
Golden set scored per stage; CI blocks if accuracy drops. Never used as few-shot.
Trust tier of every answer
| Tier | When | What the user sees |
|---|---|---|
| Verified | Matches a verified query; only parameters are filled. | Owner and verification date. AI cost: 0. |
| Governed | QueryPlan over defined metrics that passed every validator. | Full lineage and check warnings. |
| Exploratory | Free SQL behind a flag (off in the public demo). | SQL expanded and a review notice. |
| Not answered | Out of scope, ambiguous after one clarification, or failed validation. | Plain explanation and the closest metrics. |
Stack
| Layer | Demo | Production |
|---|---|---|
| Web | Next.js 15 · Recharts · Leaflet | Serverless (Node) |
| API | FastAPI · Pydantic · sqlglot | Cloud Run (min 0) |
| Analytical data | DuckDB (read-only) | Postgres + PostGIS (Neon), app_reader |
| Raw data | JSONL (Mongo-shaped) | MongoDB Atlas |
| LLM | Claude Haiku 5.5 (router) · Sonnet 5.5 (planner) | Same; model chosen on cost via evals |
| CI | GitHub Actions | Lint, tests, semantic linter, gated evals |
Patterns from production systems
| Pattern | Source | Here |
|---|---|---|
| LLM decomposes into metrics + dimensions; an engine writes SQL | dbt Labs (2023, 2026) | QueryPlan + compiler |
| Accuracy depends on the semantic layer more than the model | Cube (2026) | Model as config; compared in evals |
| Workspaces + intent agent + catalog pruning | Uber QueryGPT | Workspace router |
| Trusted assets: verified parameterised queries | Databricks Genie | Verified tier |
| Benchmarks evaluate but never feed the context | Databricks Genie | Disjointness test in CI |