Architecture overview

A 30,000-foot tour of how the pieces fit together.

Stack

  • Next.js 16 App Router, React 19, React Compiler.
  • Supabase: Postgres, Auth, Storage (resumable TUS uploads via Uppy), pgvector for embeddings, RLS-first.
  • Mapbox GL for 3D terrain, satellite imagery, globe view.
  • Vercel AI SDK v7 + Anthropic Claude (Haiku / Sonnet / Opus) via Vercel AI Gateway, one model per task slot.
  • Model Context Protocol server (Streamable HTTP + SSE).
  • Langfuse + OpenTelemetry for tracing and token accounting; prompt versions stored in Postgres.
  • TanStack Query (server cache) + Jotai (atomic local state).
  • Vercel for deploy and cron.

Why TanStack Query + Jotai (not Redux)

TanStack Query owns server state — caching, invalidation, optimistic updates. Jotai owns ephemeral UI state — playback position, selected POI, filter atoms. The split keeps server data normalized in one place and lets components stay tiny.

Data flow at a glance

  • Strava webhooks (plus a 15-minute cron safety net) → activity streams → metrics, CP fit, ride card → Postgres. Direct FIT uploads → FIT parser → same pipeline.
  • Ride TSS → fitness model (Bannister) → CTL/ATL/TSB. FTP and LTHR resolved at each ride's date → power and HR zones.
  • Chat → intent router → tool-using coach with profile + episodic memory → streamed response; memory extracted in the background.
  • MCP server exposes ride, zone, POI, profile, fitness, workout and coach tools plus resources and prompts — scope-gated.

Read the full write-up on Orbital →