At a glance
Plain-English answers, fully on device
Our capstone team built a web app that tracks congressional bills, lobbyist spending and campaign contributions. I owned the backend and built PolicyAI, the assistant that lets anyone question that data in plain English instead of writing SQL or building a report. It sits on every page of the app as a chat window.
The journey
From a chat box to an analyst that knows the data
-
September 2025
The problem: the data was there, the answers weren't
Policy teams run on fast answers: what a bill does, who is lobbying on it, how much a campaign has raised. The app already held all of it, but getting an answer out meant knowing exactly where to look or writing SQL.
My brief: anyone asks a question in plain English and gets a correct answer drawn from the data.
-
The foundation
Curated data to stand on
The app's data follows a Medallion design. Bronze holds raw pulls from public APIs: Congress.gov for bills, members and laws, the Senate's lobbying disclosures, and the FEC for campaign finance. Silver cleans and types them. Gold joins them into tables an analyst can trust. For example, each bill appears once with its summary, whether it became law, its latest action and a readable ID like “H.R. 10-119”.
I built the assistant to answer from that Gold layer alone, so the model only ever sees clean, curated records.
-
Late September
A fluent model that knew nothing about us
Version one was a plain chat model. It could talk about Congress in general, but it had never seen our database, so it had nothing to base an answer on. Retrieval closes that gap: find the right rows first, then answer only from them.
-
October
The bug that looked like a bad model
I built a first retrieval prototype over exported tables, then upgraded to a stronger embedding model. Search still came back wrong: a query for bill H.R. 3746 returned S. 3949.
Swapping the model would have been the obvious guess, and the wrong one. The stored vectors and the question's vector came from differently sized embeddings. Once I made both sides match, H.R. 3746 ranked first out of 715 bills.
What I foundWhen search looks random, check the pipeline before the model. Make sure both sides were embedded the same way.
-
November
Moving search into the database
Then I rebuilt search inside the database itself. Every row across seven Gold tables got a 768-number embedding stored right beside it in Postgres with pgvector. A question is embedded the same way, each table returns its closest rows, and the model receives them as numbered sources with instructions to cite them. The old CSV path was retired.
I built in guardrails: queries are read-only, search stays inside the curated Gold tables, and a user's question is never written to the database. Along the way I caught bill summaries long enough to crash the embedder, and capped row text at 12,000 characters.
-
November
Nothing leaves the machine
I set one firm rule for the stack: every model runs locally, and nothing touches the network when someone asks a question. A 20-billion-parameter open language model and the embedding model run through Ollama, in Docker alongside Postgres, the API and the web app.
The whole system runs on one machine. Questions, data and answers never leave it.
What I foundPrivacy is an architecture decision, not a trade-off. Public data flows in through ingestion; when someone asks a question, nothing flows out.
-
December 2025
From prototype to client demo
The finished assistant sits on every page of the app and answers plain-English questions about bills, lobbying and campaign finance from the Gold tables, entirely on device. We demoed it to the client as part of the capstone. Five versions got it there:
- v1 · ChatA plain chat model. Fluent, but it had never seen our data.
- v2 · CSV searchFirst retrieval prototype over exported tables.
- v3 · Better embeddingsA stronger embedding model, and the mismatch that made search look random.
- v4 · Gold searchSearch moved into the Gold tables in Postgres, one row per source.
- v5 · On deviceModel, search, data and app in Docker on one machine.
What's next
Where it goes from here
- A benchmark of real analyst questions with known answers, to score accuracy on every change.
- A vector index on every Gold table, so search stays fast as the data grows.
- Make every remaining Gold table searchable, so anything the app tracks is one question away.