Skip to content

Build Bellingham Tidal Observatory (FastAPI + Vite/React/TS)#1

Merged
Sean-Michael merged 2 commits into
mainfrom
bellingham-tidal-observatory
May 27, 2026
Merged

Build Bellingham Tidal Observatory (FastAPI + Vite/React/TS)#1
Sean-Michael merged 2 commits into
mainfrom
bellingham-tidal-observatory

Conversation

@Sean-Michael

@Sean-Michael Sean-Michael commented May 27, 2026

Copy link
Copy Markdown
Owner

Summary

Replaces the starter stub (main.py + bare pyproject.toml) with a complete Bellingham Tidal Observatory — a Grafana/Ganglia-style tide dashboard backed by real NOAA CO-OPS predictions. Structure deliberately mirrors the navigator project: clean FastAPI backend on uv, a Vite/React/TS frontend, a multi-stage Dockerfile, a docker-compose dev stack, and CI.

What's included

Backend (backend/) — FastAPI on uv, BTO_ settings prefix, health + CORS + SPA-static fallback.

  • noaa.py — async wrapper over the (sync) noaa_coops package via asyncio.to_thread, with an in-memory TTL cache.
  • tides.py — half-cosine interpolation between real NOAA hi/lo predictions (verified to match official NOAA exactly), plus per-station snapshot (height/rate/trend/day-range/next hi-lo).
  • astro.py — sun/moon facts via astral.
  • api.py/api/bootstrap returns the 6 Bellingham Bay / San Juan stations + extrema + sun/moon in one call.
  • Tests: tide math, API shape, health, and static SPA serving.

Frontend (frontend/) — the "Tides Tracker" design from the handoff, recreated in React/TS:

  • Glacier-glass sidebar, KPI strip, station grid (density / sort / group), focus drilldown with an interactive SVG chart, compare overlay, tweaks panel, keyboard shortcuts.
  • Tide curve math ported to TS, fed by the real extrema from /api/bootstrap.

Infra — root multi-stage Dockerfile (build frontend → serve from FastAPI), .dockerignore, docker-compose.yml (hot-reload dev), and .github/workflows/ci.yml (ruff + pytest, eslint + vitest + build, container scan).

Reviewer notes

  • This is the standalone reference app. The same tides feature also ships integrated into the Sean-Michael.dev site (homepage widget + /tides route); this repo is the canonical source for the dashboard.
  • NOAA only publishes hi/lo for these subordinate stations, so the smooth curve is interpolated between the real hi/lo points (standard approach).
  • Root stubs (main.py, pyproject.toml, uv.lock) were removed; the Python project now lives under backend/.

Test plan

  • cd backend && uv sync && uv run pytest (backend tests pass)
  • cd frontend && npm ci && npm run build (type-check + build)
  • docker compose up --build → UI on :5173, API on :8000
  • docker build -t bto . && docker run -p 8000:8000 bto → app on :8000

CI: initial run failed because frontend/src/lib/tweaks.ts matched the repo's .gitignore lib/ rule and wasn't committed; moved it to frontend/src/tweaks.ts. All checks now green (backend lint+test, frontend lint+test+build, and the three grype image scans).

Replace the starter stub with a full tides dashboard scaffolded to mirror the
navigator project's structure (clean FastAPI backend on uv, Vite/React/TS
frontend, multi-stage Dockerfile, docker-compose dev stack, CI).

Backend (backend/): async noaa_coops wrapper with TTL cache, half-cosine
interpolation between real NOAA hi/lo predictions, astral sun/moon, and a
/api/bootstrap endpoint serving 6 Bellingham Bay / San Juan stations. Tests
cover the tide math, API shape, health, and static SPA serving.

Frontend (frontend/): the Grafana/Ganglia-style "Tides Tracker" dashboard from
the design handoff — glacier sidebar, KPI strip, station grid (density/sort/
group), focus drilldown with an interactive SVG chart, compare overlay, tweaks
panel, and keyboard shortcuts.
frontend/src/lib/ matched the repo .gitignore "lib/" rule, so tweaks.ts was
never committed and CI's type-check failed to resolve it. moved to
src/tweaks.ts and updated imports.
@Sean-Michael Sean-Michael merged commit 0908619 into main May 27, 2026
6 checks passed
@Sean-Michael Sean-Michael deleted the bellingham-tidal-observatory branch May 27, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant