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.
Live scores
One connection to Squiggle for the whole site, held in runs of about five minutes. A database trigger fans every change out to signed-in tabs over Supabase Realtime.
How it works
- Takes the lease, a single database row that only one run can hold. If another run has it, this one stops straight away.
- Checks afl_games for a Game that's live or starts within 30 minutes. If there's none, it stops.
- Opens sse.squiggle.com.au/events, which covers every Game, with the site's User-Agent.
- Writes each event's live fields to afl_games. A Game that finishes without a winner gets one from the scores, and a Draw gets none.
- If the connection drops, it reconnects after 2, 4, 8, 16, then 30 seconds. A refusal such as a 403 stops the run.
- At about 290 seconds it closes, releases the lease, and records a live run.
Rules
- In the browser, a tab joins the channel only while a Game is live or about to start, and leaves when the last one finishes.
- It gets a short-lived access token from getRealtimeToken, never the refresh token, and refreshes it 5 minutes before it expires.
- If the channel drops, it rejoins (2 s, doubling to 60 s), then refetches Games once in case it missed an update.
Where it lives
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.
- 0001A missed Tip becomes a Home-team Auto-tip.
- 0002Supabase is reached only from the server, and RLS denies everyone else.
- 0003Every App lives on one origin, so the Hub and each App can be installed as a PWA.
- 0004The Demo runs in the browser over a snapshot.
- 0005Live scores came through the site's own relay. Replaced by 0010.
- 0006Supabase Auth replaces Clerk: invite-only, with cookies only the server touches.
- 0007Tipsters enter each Season's Competition by opening the App during it.
- 0008Times show in the viewer's time zone.
- 0009Squiggle is read on a schedule, never because a visitor opened a page.
- 0010Live scores come from one ingest connection, through Supabase Realtime.