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.

The Squiggle sync

A schedule, not visitors, decides when Squiggle is asked for data. Every 10 minutes Supabase calls the sync endpoint, and a planner works out whether anything is due.

pg_cronevery 10 minutesSync endpointchecks secret → 202PlannerplanSquiggleSyncSquiggle client≤10/run · ≤300/daySquiggleStandard APIUpsert tableskeeps live scoresRecord the runsquiggle_sync_runsPOST + secretload statedue requestsGETresultsnext run reads it:backoff, today's budget
Most ticks plan nothing and make no Squiggle request. Off-season that's about two requests a day: next year's Fixture and the Model tips.

What it fetches, and how often

DataWhenPer day
FixtureHourly in-Season (Games not yet complete). A full reconcile daily. Daily off-Season. A finished Season: never again.≤ 25
Next year's FixtureDaily, until Squiggle has Games for it1
Model tipsHourly for Rounds with a Game in the next 7 days, otherwise daily≤ 48
Ladder10 minutes after a Game completes, plus a daily reconcile in-Season≤ 10
TeamsWeekly, or when a Game names a team the tables don't have (at most hourly)< 1

How it works

  • At most 10 requests a run and 300 a day. Past that, the planner plans nothing.
  • After a failure, that job waits 1, 2, 4 ... up to 60 minutes.
  • A response that doesn't match its Zod schema writes nothing, so the last good data stays.
  • Live data rule: for a Game the live ingest updated in the last 10 minutes, the sync doesn't overwrite its scores. Squiggle's Standard API runs up to 60 seconds behind its Event API.
  • Every request carries a User-Agent with a contact email, so Squiggle can reach the site's owner.

Why

Squiggle's terms say it isn't a backend for user-facing sites. The site's traffic to it now depends on the calendar, not on how many Tipsters there are.

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.