How natesil/trout-api works
trout-api is a read-only Connecticut trout-stocking history API backed by a warehouse rebuilt from daily trout-data snapshots. Its main workflow checks for a new source commit, downloads snapshots, builds a DuckDB warehouse through dbt, and swaps in the successful build while retaining the prior one on failure. API routes query that store for sites, events, metadata, and health. The graph preserves the documented staging-to-intermediate-to-marts pipeline and major warehouse tables; unsampled dbt model internals are represented at their exact tree paths.
Main entry points: store.py Build and query store · intermediate Intermediate models · main.py HTTP routes · source.py Snapshot source
Components 18
API
- HTTP routes
app/main.py - Site endpoints
app/main.py - Event endpoint
app/main.py - Metadata and health
app/main.py - Rate limiting
app/ratelimit.py
Refresh and storage
- Refresh scheduler
app/main.py - Build and query store
app/store.py - Snapshot source
app/source.py - DuckDB warehouse
Warehouse transforms
- Staging models
dbt/models/staging - Intermediate models
dbt/models/intermediate
Warehouse marts
- Stocking events
dbt/models/marts/fct_stocking_event.sql - Site dimension
dbt/models/marts/dim_site.sql - Site-town bridge
dbt/models/marts/bridge_site_town.sql - Town dimension
dbt/models/marts/dim_town.sql - Date dimension
dbt/models/marts/dim_date.sql
Other components
- API client
- GitHub trout-data
Connections 18
- API client → HTTP routes: requests
README.md - HTTP routes → Rate limiting: applies limits
app/main.py - HTTP routes → Refresh scheduler: starts refresh
app/main.py - Refresh scheduler → Build and query store: refreshes
app/main.py - Build and query store → Snapshot source: checks and downloads
app/store.py - Snapshot source → GitHub trout-data: reads snapshots
app/source.py - Build and query store → Staging models: runs dbt build
app/store.py - Staging models → Intermediate models: transforms into
README.md - Intermediate models → Stocking events: builds marts
README.md - Intermediate models → Site dimension: builds marts
README.md - Intermediate models → Site-town bridge: builds marts
README.md - Intermediate models → Town dimension: builds marts
README.md - Intermediate models → Date dimension: builds marts
README.md - Build and query store → DuckDB warehouse: opens and swaps
app/store.py - Site endpoints → Build and query store: queries
app/main.py - Event endpoint → Build and query store: queries
app/main.py - Metadata and health → Build and query store: checks and queries
app/main.py - Build and query store → DuckDB warehouse: serves query results
app/store.py