Batch ELT over Formula 1 data (OpenF1 → GCS → BigQuery → dbt → Observable site) that explains race strategy — tyres, pit stops and the undercut — to people who don't follow F1.
Live dashboard: https://tomasripsky.github.io/pitwall/
flowchart LR
api[OpenF1 API] --> ingest[pitwall ingest] --> lake[(Raw lake: Parquet + markers)]
lake --> load[pitwall load] --> bq[(BigQuery raw)] --> dbt[dbt: staging → marts → reports] --> export[site-export] --> site[Site on GitHub Pages]
| Layer | Choice | Why |
|---|---|---|
| Ingestion | Python (httpx, pyarrow) | Small, testable, teaches rate limiting and idempotency — ADR 0002 |
| Storage | Parquet lake on GCS (gs://pitwall-tr-<env>-raw) |
Replayable source of truth |
| Warehouse | BigQuery (raw dataset, full reload) | Free tier, load jobs are free — ADR 0003, 0004 |
| Infrastructure | Terraform + make bootstrap |
One root, workspace per env, no keys (Workload Identity Federation) |
| Transformation | dbt (BigQuery) | Tested SQL with stated grains; unit tests pin the racing rules |
| Orchestration | GitHub Actions (cron + manual dispatch) | Free, public runs, WIF auth — ADR 0006 |
| Site | Observable Framework on GitHub Pages (site/): a story page and a BI page | Static, keyless, the lab's showcase skeleton + its own Formula 1 look — ADR 0007, 0008 |
make setup && make test
# one-off per environment: GCP project + billing link + budget alert (5 in the account currency)
make bootstrap BILLING_ACCOUNT=XXXXXX-XXXXXX-XXXXXX ORG_ID=XXXXXXXXXXXX
make apply # ENV=dev by default
make ingest ARGS="--season 2025" # OpenF1 → gs://pitwall-tr-dev-raw (~15 min: 30 requests/min limit)
make load # lake → BigQuery raw.openf1_* tables
make transform # dbt build: staging → intermediate → marts, with tests
make site-preview # the site with dev data on http://127.0.0.1:3000
PITWALL_LAKE_URI=.lake make ingest ARGS="--meeting 1255" # offline: local lake| Workflow | When | What |
|---|---|---|
pitwall-ci |
every PR | lint + tests, terraform validate, dbt build in throwaway per-run datasets ci_pr_<n>_<run>_* (dropped afterwards; their tables also expire after 1 day), site build with dev data |
pitwall-pipeline |
Mondays 06:00 UTC (prod), every release (push to main) and on demand |
ingest → load → transform → export → build and deploy the site; prod runs code from main only |
GCP access uses Workload Identity Federation: no keys exist. Each GitHub Environment (dev, prod)
holds its project, WIF provider and service account as variables — make gh-vars ENV=… republishes
them after make apply (the provider name changes after a destroy/apply cycle).
CI builds the site with data exported from the dev marts, not from the pull request's own
throwaway datasets: a PR that adds or changes a report model needs make transform ENV=dev first.
On-demand runs: Actions → pitwall-pipeline → Run workflow, or
gh workflow run pitwall-pipeline.yml -f env=prod -f mode=season -f value=2024
(mode=none reloads and rebuilds models without calling the API).
GitHub disables scheduled workflows after 60 days without repository activity (it can happen in the December–February off-season): re-enable it from the Actions tab.
| Term | Meaning |
|---|---|
| Grand Prix (meeting) | One race weekend at one circuit. |
| Race / Sprint | Sunday's full-distance race / Saturday's short race. pitwall analyses both. |
| Compound | Tyre type: SOFT (fast, wears quickly), MEDIUM, HARD (slow, durable), INTERMEDIATE/WET (rain). |
| Stint | Laps on one set of tyres, between two pit stops. |
| Degradation | Seconds per lap a car loses as its tyres wear. |
| Pit stop | Stop to change tyres: ~2–3 s stationary, ~20 s lost overall. |
| Undercut | Pitting before the car just ahead so that fresh tyres put you in front after they pit. |
| Safety Car / VSC | Everyone slows down after an incident, so pitting costs less. |
| Model | One row is | Answers |
|---|---|---|
fct_laps |
a lap of a driver | pace, tyres and running order lap by lap |
fct_stints |
a set of tyres used by a driver | how fast each compound wears (degradation) |
fct_pit_stops |
a pit stop | when, how long, which tyres, positions lost |
fct_undercut_attempts |
an undercut attempt | did pitting first work? |
fct_session_results |
a driver's race result | grid vs finish |
dim_sessions, dim_meetings, dim_session_drivers |
a race / weekend / driver-in-race | names, dates, teams, colours |
On top of these, eight report models (transform/models/marts/reports/rpt_*) hold exactly what the site reads — races, results per driver, laps, stints, pit stops, tyre wear, undercuts, neutralised laps — one grain each. pitwall site-export copies them to Parquet and nothing else, so a number on the site can always be traced to rows of a tested table (ADR 0008).
Every column is documented in the dbt YAML (transform/models/); dbt docs generate renders it.
Ingestion rejects only structurally broken data (missing keys, wrong types). Everything else is
checked in dbt: impossible values (null keys, positions or points out of range) fail the build,
so the marts and the dashboard keep their last good version; unusual-but-real values warn. Every
failing row is stored in the BigQuery audit dataset.
Empty fields that are expected (not errors):
| Field | Empty when |
|---|---|
race_control.driver_number |
the message is not about one car (~80 %) |
race_control.flag, scope, sector |
the message is not a flag |
race_control.qualifying_phase |
always in races (qualifying only) |
session_result.position, gap_to_leader, duration |
the driver was not classified (DNF/DNS/DSQ) |
pit.stop_duration |
the stationary time was not measured |
laps.lap_duration, date_start |
timing gaps, mostly lap 1 and pit laps (< 1 %) |
drivers.country_code |
always — OpenF1 does not publish it (not modelled) |
Known source defects: a few stints with missing or inverted lap ranges (kept in staging, excluded
from fct_stints), and race-control messages that name a car in the text but not in driver_number.
Known real-race outliers that only warn: red-flag pit stops of up to 22 minutes, and wet weekends
(Miami 2025) with slightly more missing lap timings.
Per environment: one GCP project with a GCS bucket (MBs), five BigQuery datasets (raw, staging, intermediate, marts, audit), a service account and a Workload Identity pool. Expected cost: 0/month — everything stays in the free tier. Guards: a budget alert (warns at 50/90/100 % of 5 EUR) and a 50 GiB/day BigQuery query quota (stops runaway queries; the default is 200 TiB/day).
make destroy ENV=dev # deletes everything Terraform created, lake data included
gcloud projects delete pitwall-tr-dev # nuclear option: the project itself- How it works inside: docs/guide.md.
- Architecture Decision Records: docs/decisions/. Specs and plans: docs/design/.
pitwall is a project of the Data Engineering Lab,
where the rules every project follows and the AI teammate that builds them are documented. It was
built inside the lab's monorepo and moved here with its history on 2026-10-13: older commits name
lab issues and pull requests as data-engineering-lab#N, and lab ADRs are cited as "lab ADR".
- Concept — one line on the insight (second-brain note:
02 - Fundamentals/...).