How Hot Shots is built

The code runs in four places: the Tipster's browser, the TanStack Start server on Vercel, the Supabase database, and Squiggle, the AFL data service. Click a box on the map, or a topic under it, to open that part of the system.

The browser only ever talks to the site's own server, plus a Realtime WebSocket during Games. Only the two sync endpoints call Squiggle, and Supabase's own scheduler starts them. Every other read comes from the site's own tables.

Opening a page

Pages draw from a cache in the browser first, then refresh it from the server. The server reads the site's own tables, never Squiggle.

BrowserServer functionSupabase1. Shows the cached Games at once2. Refetch if over a minute old3. getClaims(): is the session valid?4. Read afl_games with the secret keyrows5. Games, mapped to AflGame6. Saves it to localStorage (24 h)
One page load. The page is on screen at step 1. Steps 2–6 only run when the cached Games are over a minute old, and they never reach Squiggle.

How it works

  1. Each page asks for data with a TanStack Query key that starts with the Season, like ["afl", "season", 2027, "games"]. Switching Seasons switches every query at once.
  2. Queries don't call the server directly. They ask the service registry for a service, such as squiggleService.getGames. The live site registers services that call server functions. The Demo registers its own.
  3. A server function runs on Vercel. It checks the session cookie, then reads through squiggleDataRepository or a tips repository using the server-only secret key.
  4. The whole query cache is saved to localStorage for 24 hours, and cleared by each deploy. An installed app opens straight onto its last screen.
  5. Games count as stale after one minute. Live updates keep them current while the app is open. Reopening or refocusing the app refetches them from the database.

Why

The pages don't know whether data comes from the server or the Demo's snapshot, so the same code runs both.

Decision record: ADR 0004

Stack and testing

Built with

  • React 19, the interface
  • TanStack Start and Router, file-based routes and server functions
  • TanStack Query, server state, cached in the browser
  • Supabase, Postgres, Auth and Realtime
  • Vercel, hosting for the server
  • Tailwind CSS v4 and shadcn/ui, styling and components
  • Zod, validating what Squiggle sends and what the server receives

How it's tested

  • Vitest unit and component tests, next to the code they cover.
  • Storybook stories for components and diagrams, including this page's.
  • The Demo: the whole site running in the browser over a snapshot, so every page can be exercised end to end with no accounts or live data.

Read the code in the repository, the decision records, or AGENTS.md, the guide the project's contributors and coding agents work from.

Decisions

Each decision record explains what was chosen and the alternatives it beat.