FEC Search: Querying 200 Million Campaign Finance Records in Milliseconds
The Problem
The FEC publishes campaign finance data as bulk CSVs. California’s CalAccess does the same. Searching either is painful — the official FEC website is slow, can’t connect federal and state data, and doesn’t tell you how a donation compares to the broader dataset.
FEC loads ~200 million federal records and ~13 million California records into SQLite with pre-computed lookup tables, FTS5, and percentile rankings. Sub-second queries on a Raspberry Pi. Weekly cron updates from the bulk endpoints.
The Architecture
Two Flask web applications:
- Federal (port 5000) — ~200M+ contribution records from the FEC bulk data files
- California (port 5001) — ~13M+ records from CalAccess
Both backed by SQLite with extensive indexing, FTS5 full-text search, and WAL mode for concurrent reads. The federal database is 1.3 GB. Automated weekly cron jobs pull fresh data from the FEC and CalAccess bulk download endpoints.
Making SQLite Fast at Scale
Pre-computed lookup tables. Instead of computing aggregates at query time, the data pipeline pre-builds recipient lookup tables — total contributions, recent activity, unique contributor counts — with FTS5 for fuzzy name search. A query for a candidate or committee hits the pre-computed table, not a 200M-row scan.
Percentile rankings. Every donor has a pre-computed percentile rank: “this person’s $2,700 contribution puts them in the 99.2nd percentile of all individual donors.” The percentile builder runs offline against the full dataset; the web app just looks up the pre-computed value.
Cascading search logic. Searches start with the most specific filters and automatically relax them if results are too sparse. Search for “John Smith, San Francisco” first tries both filters; if that returns nothing, it drops the city. The user gets the best available results without manually adjusting filters.
Conduit filtering. ActBlue and WinRed are conduits — they process contributions on behalf of candidates but appear as the “recipient” in raw FEC data. Without filtering, every search is dominated by conduit entries. The platform separates conduit passthrough from direct contributions.
Person Profiles
Each donor gets a profile page: contribution history over time, recipients, geographic distribution, and percentile ranking. Cross-database linking connects a donor’s federal and California contributions.
There’s also a JSON API for programmatic access and embedded Google search integration for quickly finding public information about a donor.
Deployment
Runs on a Raspberry Pi with memory-optimized configuration. Nginx fronts both Flask apps. The weekly update pipeline downloads, decompresses (zstd), and rebuilds the lookup tables and indexes. The whole system costs the electricity to run a Pi.
What I Learned
SQLite scales further than people think. 200M records with sub-second queries on a Raspberry Pi. The key is doing the expensive work offline — pre-computing aggregates, building indexes, and materializing lookup tables during the weekly update rather than at query time. SQLite is fast at reading pre-computed results; it’s slow at computing them on the fly.
Conduit filtering is essential for usable campaign finance data. ActBlue alone processes billions of dollars. Without filtering conduit passthrough, every search returns thousands of ActBlue entries that obscure the actual donations. This is a domain-specific data quality issue that the FEC website itself handles poorly.
Links
- FEC — campaign finance search platform