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.

Who can read what

The browser has the publishable key, which is public by design, and a session cookie. Neither can read a table. Everything goes through the server, except one Realtime channel.

BROWSER · ANYONEOUR SERVERSUPABASEPublishable key+ session cookieServer functionssecret key, server-onlySync endpointsneed the Bearer secretTablesRLS on, no policiesLease/cron functionsRealtime channelpg_cron + Vaultapp_url, sync secretcookiebypasses RLSPOST + secretpublishable key: 0 rowssigned-in token · receive only, one topic
The publishable key ships in the page, so anyone can take it. With RLS on and no policies, it reads and writes nothing. The only exception is receiving on afl:live-games, and only with a signed-in token.

How it works

  • Every table has row-level security on and no policies. A new table's migration must turn RLS on too.
  • The secret key is only ever on the server. No secret may have a VITE_ prefix, because Vite builds every VITE_* variable into the browser bundle.
  • The lease, cron and trigger functions have execute revoked from anon and authenticated. Without that, the public API could call them.
  • Realtime's "Allow public access" is off, so only private channels work. The one realtime.messages policy lets signed-in users receive on one topic. Nobody can send.
  • The sync endpoints compare the Bearer secret in constant time. A missing secret answers 503, a wrong one 401.

Why

Before the lockdown, anyone could take the publishable key from the page and read every Tip before Lockout. One gate, the server functions, is easier to get right than many policies.

Decision record: ADR 0002

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.