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.
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.
How it works
- 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.
- 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.
- 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.
- 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.
- 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.
Where it lives
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.
- 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.