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.

Submitting a Tip

One server function decides whether a Tip may be saved and whether it's an Underdog tip, using the site's copy of the Game and the Model tip as they stand at that moment.

submitTip(season, gameId, teamId, margin)Enter the Season's Competition if newafl_competition_entries · entered_at = nowRead the Game and its Model tipafl_games · afl_model_tips (the site's copy)Game started?yesRefuse: game-startedLockout is the first bouncenoUnderdog tip = team ≠ Model's pickneither, if the Model hasn't tipped yetUpsert the Tip in afl_tippingseason, game, user, team, margin, is_underdog
The rules in judgeTip. A Game that isn't in the site's tables, or belongs to a different Season, is refused as game-not-found before the diamond.

How it works

  • Lockout is the moment the Game starts. Until then a Tip can be changed and nobody else can see it. Group tips hides other people's teams until the start.
  • An Underdog tip is judged against the Model tip as it stood when the Tip was made. It stays an Underdog tip even if the Model changes its mind later.
  • The Margin is only kept for the Margin game, the first Game of the Round by start time.
  • Saving the same Game again replaces the earlier Tip, keyed on Game and Tipster.

Why

The submitTip function used to fetch the whole Season from Squiggle to check one Game. It now reads one row of the site's own copy.

Decision record: ADR 0009

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.