Inspiration

What it does

How we built it

Challenges we ran into

Accomplishments that we're proud of## Inspiration

I run the British Resilience Index, a civic data site where every figure has to trace to a primary government source. A year of that teaches you two things: UK official data is astonishingly deep, and almost nobody can actually use it. The spreadsheets are hostile, the APIs are inconsistent, and when people ask ChatGPT instead, it just makes numbers up with a confident face.

I wanted three things. To build a genuinely top level RAG system, not a demo. To take a swing at the government at their own game, since the ONS prototyped a stats chatbot and shelved it because they could not trust its answers. And to finally ship something that generates income, not another free civic project and not another failing indie hacker idea on the pile.

What it does

Britain by the Facts answers questions about the UK from official statistics alone. Ask in plain English and you get the exact figures, a chart, the SQL it ran, and the series and publisher cited. 6.2 million observations from 367 official sources, reaching from consumer prices in 1209 and Bank Rate in 1694 to last month's NHS waiting list.

The feature I am proudest of is what it does NOT do. If the data is not held, it refuses and names the official dataset that could answer it. It never estimates, never fills gaps from general knowledge. Right, or silent.

How I built it

The moat is the ingestion gate. Every source has its own parser, and nothing enters the DuckDB warehouse unless its computed totals reconcile against the publisher's own headline figures. If the numbers do not match, the data does not load. Most RAG systems index whatever is there and hope. This one audits the corpus before retrieval ever happens.

The answer engine is Claude running an agentic text to SQL loop over the warehouse, read only, with a contract: every figure must come from a query it actually ran, derived figures must be computed in SQL, every answer ends with sources. A 40 case eval suite with forbidden figure regexes keeps it honest. I fleeted the data collection out to dozens of cheap model agents, each building and gate testing parsers in parallel, then ingested everything serially through the gates. The iOS app is SwiftUI with RevenueCat credit packs: curated answers are instant and free, fresh questions cost credits because they cost real compute.

Challenges

The fact check that caught my own engine inventing a derived subtotal it never queried. Every stated figure has to come from a query the engine actually ran, and a reviewer found one that did not: a difference computed in the model's head. The fix became a rule in the briefing and an eval case, so that exact failure can never pass again.

The government's own files. I found published workbooks that disagree with themselves, and a survey where regions and their sub areas were both presented as leaves, which would have silently doubled every aggregate. The honest answer was to load the data as published, gate every load against the publisher's own headline, and document the contradiction rather than paper over it.

Prompt injection hardening, because a hostile question runs code on the server. The engine runs unprivileged with a minimal environment, can only read the data and write to a scratch directory, and never holds a credential: the API's bearer token never reaches it, and the model key sits behind a loopback proxy it can use but not read.

Launch week taught me that a working engine is not a working product. Answers that took four minutes looked dead on a phone, a proxy that closes silent connections after sixty seconds killed long answers, and the app had no way to say "the connection dropped". Now the stream heartbeats, the answer arrives even if you leave the app, and every failure says what happened and that no credit was taken.

Accomplishments

The warehouse doubled to 6.2 million observations in the final push while integrity stayed clean. Ten viral questions fact checked to the last digit. A privacy model I am genuinely proud of: questions are never stored server side, full stop.

What I learned

Retrieval quality is a data engineering problem, not a prompting problem. The reconciliation gate caught every serious bug before any user could see it. And refusal is a feature people trust more than fluency.

What's next

TestFlight, launch, and the remaining gap sources in the registry. The long game: prove an independent builder can ship the statistics assistant the government could not.

What we learned

What's next for Britain by the Facts

Built With

Share this project:

Updates

Submission history