Public
Football squares pool game grid
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data โ€“ all from the browser, and deployed in milliseconds.

๐Ÿ€ Gameday Squares

A live NBA squares pool you run from a link. Create a room, share the short URL, friends pick squares from their phones, and winners settle automatically off the live NBA score โ€” no manual scorekeeping.

How to play

  1. Open the app and create a room โ€” pick a short slug (e.g. okc), the team tricodes (away + home), and a stake per square.
  2. Share your-app-url/okc. Each person enters their name and taps squares to claim them. Tap again to release.
  3. When the board hits 100/100, anyone can Lock + roll numbers โ€” the row (away) and column (home) digits are shuffled 0โ€“9.
  4. During the game, the app polls the public NBA scoreboard. At the end of each quarter it derives the winning square from the last digit of each team's cumulative score and credits the payout share. Q1/Q2/Q3/Final shares are configurable (default 15/25/15/45%).
  5. Winners show up on a leaderboard with one-tap Venmo / Cash App payment links between players.

Architecture

Rendering mermaid diagram...

Files

FileRole
backend/index.tsHono HTTP handler โ€” REST API + serves the frontend
backend/nba.tsNBA scoreboard fetch (cached 20s) + quarter settlement
backend/store.tsBlob-backed room storage + number shuffle
backend/types.tsShared types + the avatar color palette
frontend/index.htmlApp shell
frontend/app.jsVanilla-JS SPA: pick view, live view, leaderboard
frontend/style.cssDark, mobile-first styling

API

Method & pathPurpose
POST /api/createCreate a room { slug, label, home, away, stake }
GET /api/:slug/stateRoom + live score (settles quarters when locked)
POST /api/:slug/joinRegister player / claim squares
POST /api/:slug/releaseRelease one of your squares
POST /api/:slug/lockLock board + roll the 0โ€“9 digits
POST /api/:slug/resetUnlock + clear numbers/settlements

Notes

  • State lives in blob storage keyed by slug โ€” no database setup needed.
  • Scores come from the public cdn.nba.com live scoreboard (no API key). It only contains today's games, so lock a room on game day.
  • Sync is poll-based (4s) since Val Town doesn't accept inbound WebSockets.
  • Money flows are just deep links โ€” the app never touches funds.