IHNYC Games keeps the public site and admin interface separate from the API and database, while Cloudflare Access protects administrative work.

System overview

flowchart TD
    people[Residents and organizers] --> pages[Cloudflare Pages<br/>Public site and admin UI]
    pages --> worker[Cloudflare Worker<br/>Public and admin APIs]
    worker --> d1[(Cloudflare D1<br/>Events, results, imports, submissions)]
    access[Cloudflare Access<br/>Admin route protection] -.-> pages
    access -.-> worker
  • Pages serves the public site and the /admin UI.
  • Worker provides JSON APIs for public + admin flows.
  • D1 stores events, results, imports, and submissions.

Admin access model

  • /admin should be protected at the edge with Cloudflare Access.
  • Admin API endpoints (/api/admin/*) require either:
    • Cloudflare Access headers, or
    • X-Admin-Token matching ADMIN_TOKEN (dev only).

Data flow

  1. Events + Results are created in Admin Console.
  2. CSV Import ingests Google Forms exports into signup_submissions.
  3. Standings are computed on read from results.

Deploy flow

  • API: npx wrangler deploy (Worker)
  • UI: Cloudflare Pages build from repo (apps/web)
  • D1 schema: npx wrangler d1 execute ihnyc-games --file=../../infra/d1/schema.sql --remote