← brewedinsights.me

How it is built

Everything on this site comes from a small data platform that runs on one laptop: no servers, no cloud warehouse, no monthly bill. Public data is collected, stored as open files, modeled and tested in SQL, and then baked into this static site. The source is on GitHub.

Browse the dbt docs and lineage graph →

Architecture

1. Sources
Public APIs and open data portals (FRED, City of Denton, US Census geocoder)
2. Raw (bronze)
Files landed exactly as received, never edited, deduplicated by content hash
3. Staging (silver)
dbt models that type, rename and deduplicate, written as Parquet
4. Marts (gold)
Fact and dimension tables in DuckDB, tested on every build
5. This site
Evidence runs the page SQL at build time; Cloudflare Pages serves the static result

Each layer reads only from the one before it. Every path comes from one setting (LAKE_ROOT), so the lake can move from a laptop folder to object storage (S3, MinIO or Cloudflare R2) without changing any model.

The everyday loop

  1. Land it. One command copies a file or URL into the raw layer, skips it if the same bytes were already landed, and records it in an ingestion log.
  2. Query it right away. DuckDB reads the raw CSV or JSON directly, so a new dataset can be explored in SQL minutes after it arrives, before any modeling.
  3. Keep it. When a dataset is worth keeping, it gets a dbt source, a staging model, tests, and then marts. Recurring sources (like the daily Denton refresh) run the same steps on a timer.

The tools, and why

Tool Job Why this one
DuckDB Query engine and warehouse One file, no server, fast on millions of rows, reads Parquet and CSV in place
Parquet Storage format Open, columnar and compressed; any tool can read it, so nothing is locked in
dbt Transformations SQL models with tests, documentation and lineage, built in dependency order
Evidence This site Pages are Markdown plus SQL; the build bakes results into static files, so hosting needs no database (why the open-source version)
Cloudflare Pages Hosting Free static hosting with HTTPS on a custom domain (why Pages)

Choices that are not obvious from the code are written down as short decision records: what was picked, what it costs, and when to revisit it.

Testing

dbt tests run on every build, and a failing test stops the build:

  • Every model's primary key is tested unique and not_null.
  • Relationships between facts and dimensions are tested, so no incident points at a missing offense or location.
  • Allowed-value tests catch new codes the models don't handle yet.
  • Data checks catch problems at the source: every police offense code must map to a crime category, and a warning fires if fewer than 90% of incidents can be placed on the map.
  • Source freshness checks flag a feed that has stopped updating.
  • A custom test fails the build if a column that looks like personal information reaches a model.

The dbt docs list every test on every published model.

What gets published

The site can only read the tables below. Pages cannot query anything else in the warehouse.

No Results

Some rules about what is published, and why:

  • Personal data never leaves the laptop. It is modeled separately, never runs in the publishing pipeline, and is never committed to git.
  • Crime locations are block-level only, as the city publishes them, and slightly offset so stacked incidents stay visible. Locations of sex offenses and human trafficking are withheld. (Full rules)
  • The dbt docs show only the models behind published pages. They are built from an allowlist, and the build refuses to publish them if anything outside it slips in.