← All docs Games for Group Β· Architecture

The Big Picture

The 5-minute map of how the whole product is built. Written for a human, not a compiler β€” every technical word is explained where it first appears. Start here, then open the deep-dive pages above.

πŸ•ΉοΈ One set of game rules, written once β€” played on a single phone passed around, or online through the cloud. A third way (the host's phone serving guests with no internet) is built and tested but paused behind a launch flag.

What the product is

A group of friends plays simple party games together. Every game is learnable in under a minute β€” depth over breadth. The line-up itself lives in the code (apps/app/src/games/catalog.ts, and the site's /games page), not here. What matters for the architecture is that each game declares where it can be played, and the pickers and the referees enforce it:

A game that…Same deviceOnlineLAN (paused)Example
is a board or a turn you can take on one shared phoneβœ“βœ“βœ“Tic-Tac-Toe, Ludo
needs every player on their own screen (a secret ticket, a secret answer)β€”βœ“βœ“Tambola, Trivia Clash
only works in some languages (a grid of A–Z letters)offered only to players reading those languagesWord Search

Leaving a game out of a mode is deliberate, not missing work: pass-the-phone cannot hide a secret from the person holding the phone next.

The ways to play

Two are offered to players today. The third is complete in the codebase and switched off for launch β€” why, and how to bring it back.

Same device

Pass one phone around

The whole game runs on that one phone. No account, no setup β€” pick a game, type names, hand the phone over. Each game decides for itself whether it needs the internet.

Online

Play from anywhere

A referee in the cloud (a service called Convex) keeps one shared game that everyone watches live. The host signs in with Google or Apple; friends just type a 4-letter room code β€” no account needed.

Local network Β· paused

No internet needed

The host's phone becomes the server. Friends on the same wifi or the host's hotspot scan a QR code and play from their phone's browser β€” nothing to install. Not offered at launch: an all-iPhone group can't reach a hotspot that has no internet. The come-back note β†’

The one big idea

Game rules are written once, as plain calculations with no side-effects (developers call this "pure functions" β€” think of it as a rulebook that only answers questions). Each play mode is just a different place that same rulebook runs:

πŸ“– The rulebook Pure game rules
packages/engine + each game's game.ts β€” no clock, no dice, no network. Time and randomness are handed in from outside.
β–Ό   the exact same code runs in three places   β–Ό
Your phoneSame device β€” the app runs the rulebook locally.
The cloudOnline β€” Convex servers run the rulebook and broadcast results.
Host's phoneLAN β€” the app runs the rulebook and serves it to guests.
πŸ’‘ Why this works The rules are deterministic: give them the same inputs and they give the same answer, every time, on every device. That's what lets one rulebook referee all three modes β€” and guarantees they can never disagree about who won.

The moving parts

Seven pieces, each living in its own folder. Together they are the whole system:

The app

One codebase (built with Expo) that becomes three things: the iPhone app, the Android app, and the play website. Screens, games, and all three play modes live here.

apps/app Β· Frontend page β†’

Public pages

The home, one page per game, contact, privacy and terms are routes of the App, static-rendered on the web with their own titles and descriptions β€” what search engines and AI assistants read. No second site.

apps/app/src/site Β· Frontend page β†’

Online backend

The cloud referee: rooms, players, live game state, and content a host supplies for the room. Fully generic β€” adding a game adds zero backend code.

convex/ Β· Backend page β†’

The rulebook

Shared pure game logic: the contract every game implements, plus reusable mechanics (turns, timers, scoring, seeded dice…).

packages/engine

The LAN referee

The same "run the match" job Convex does online, packaged as a tiny library the host's phone runs during LAN games.

packages/match-host Β· LAN page β†’

The phone server

A small native module that turns the phone into a web server, so friends' browsers can load the game straight from the host's phone.

apps/app/modules/expo-lan-server

The live relay

Passes short-lived messages between the phones in an online room, like a drawer's line while it is still being drawn. Stores nothing. See the live channel.

live/

The live channel

Some things other players should see the moment they happen, but nobody needs kept: a line growing under the drawer's finger, later a pointer. So an online room also has a live channel: a small Cloudflare relay with one room object per room. The backend signs a short pass that the relay checks when a phone connects, a phone holds the channel only while a feature needs it, and the relay passes messages between the room's phones and stores no messages. The game's real moves still go through the backend, so if the relay is down, nobody sees an error. Same device and LAN have no channel.

The full page How a phone gets in, the limits, what it costs, and how to use it in a new feature: The Live Channel β†’

What ships where

The tracks go live independently β€” knowing which one you're touching is half the job. Full step-by-step commands: docs/releasing.html.

ThingWhere people see itHow it ships
The site β€” content pages + web playgamesforgroup.comManual β€” bun run deploy builds, checks and uploads to Cloudflare. A push deploys nothing
Online backend(invisible β€” powers online mode)Manual β€” and before any site change that needs it
iPhone appTestFlight β†’ App StoreLocal build on the Mac (free) β€” or an EAS cloud build when credits allow
Android appPlay internal testingLocal build on the Mac (free) β€” or an EAS cloud build when credits allow
The live relay(invisible β€” the growing line in online drawing)Manual β€” bun run deploy:live, with the shared secret set on the relay and on the backend
These docsdocs.gamesforgroup.comManual β€” bun run deploy:docs uploads the docs/ folder as it is, no build

The site and the docs are served by Cloudflare (each a "Worker" that hands out static files; www is a third, tiny one that redirects to the bare domain). Online play is counted on the backend; website visits are counted by Cloudflare's cookie-free analytics.

Read the deep-dives

πŸ—‚οΈ Folders & rules

Where everything lives, what a game folder looks like, and the few hard rules that keep the codebase safe to change.

πŸ“± Frontend

The one app, how screens are organized, the Board-vs-shell split that makes one game work in all three modes, the shared kits, and where the words live.

☁️ Online backend

What Convex is, the life of an online room, the database tables, and the one deploy rule that must never be broken.

πŸ“‘ LAN mode

How a phone becomes a game server, what travels over the wifi, and the fragile part every release must double-check.

🩹 Learnings

Bugs that fooled us β€” what broke, why it really broke, and why our testing didn't catch it. So we stop re-learning the same lesson.

🧭 Decisions

The calls we made and why β€” with the alternatives we rejected and what would make us change our minds.

Decision log

Big calls that shaped the whole system, newest first. (Each deep-dive page keeps its own log for decisions in its area.)

Last updated: 2026-09-15 Β· Maintained under the CLAUDE.md rule "Architecture docs β€” keep them in sync". If the code changed and this page didn't, that's a bug β€” fix the page. See also learnings.html and decisions.html.