Homefelt · architecture map · 26 November 2026 · main at 115a7ff8 · issues to #288

One spec, three cores, one table.

How Homefelt fits together today, what is being built, and what comes after. Canasta is the only game so far, so every game box below says Canasta; the platform boxes say Homefelt.

01 the big picture

Three clients, one small server.

The browser is the only client that can go online, and so far only against a server on your own machine: the game server is not deployed yet. The iPhone and Android apps play on the device against the computer and read only the status feed.

swipe sideways →

The Homefelt system today The browser loads the web game from Vercel and talks to the game server over HTTPS and WebSockets; the server is built but not yet deployed to Fly.io, so today that works against a local server only, and the docs site is not set up either. The server holds each table in memory, runs moves through the Canasta rules engine and saves to Postgres on Neon. It checks Apple and Google sign-in tokens itself. The iPhone and Android apps play locally and read the status feed; the iPhone's online play is in progress (#258) and Android's is planned. Ads, purchases and deploys from GitHub Actions are planned; analytics and a second game are future work. browserReact + Wasm iPhone appSwiftUI · local Android appCompose · local VERCEL · STATIC play.homefelt.ioweb game · .wasm homefelt.iosite · status feed docs.homefelt.ionot set up · #133 ○ FLY.IO · IAD · NOT DEPLOYED YET · #50 WebSocketone per player table taskone writer each canasta-rulesengine · bots HTTP APItables · invites authJWKS · ES256 seat viewfails closed TableStore → PgStoresaved at seat changes, hand ends, idle and stop ○ NEON · AWS US-EAST · NOT CREATED YET 18 tablesaccounts · invites · tables · snapshots · results Apple · Googlekeys · revoke HTTPS + WSS · local server today TLS loads ◐ iPhone online play, #258 · Android, #259 ● status feed — request — reply, per seat ··· storage NOT BUILT YET adsAdMob · consent formapps only · #239 Remove ads, $2.99StoreKit · Play Billing#237 #238 #240 deploy on mergeGitHub Actions → Fly#225, waits on #53 analyticsPostHog EU · opt-indraft plan a second gamean engine per game idHand and Foot first

The server's code and its deploy files are built; the Fly.io app, the Neon database and api.homefelt.io do not exist yet, and neither does the docs site (#50, and Eduardo's steps in #133). Once deployed, one always-on machine (512 MB, shared CPU) holds every table in memory, capped at 200 connections. It is never scaled past one, because two machines would each believe they own a table. The web game and both apps read the status feed at homefelt.io/app-status/v1.json, at most every 15 minutes. Sign-in needs the Apple and Google keys as well (#48, #51).

What runs where

Rules run on the device for local games (Swift, Kotlin, or Rust compiled to Wasm) and on the server for online ones. The server is the only thing that talks to Postgres; no client ever does.

What a player can see

The server builds each seat's view from an allowlist. A new field stays hidden until someone lists it, and the shuffle's seed never leaves the server.

What it costs to run

Today, two static Vercel projects: the site and the web game. Once deployed, add one small Fly machine and Neon's smallest compute, which sleeps between games, so the first save after a quiet spell is slow. The ceiling is $25 a month.

02 one spec

No shared code. One shared spec.

Built the way Shopify built Reflex: the rules exist three times, in Swift, Kotlin and Rust, and one folder of scenarios decides what is correct.

swipe sideways →

The spec feeds every platform The spec folder pins a cards module and a game core in each of Swift, Kotlin and Rust. Each core has a command-line driver. The Swift core runs the iPhone app, the Kotlin core the Android app, and the Rust core runs the game server and, compiled to WebAssembly, the web game. One behaviour suite tests every command-line driver and the Wasm module the same way. SPEC/ · DECIDES scenarios425 files invalid264 parity15 + 4 long rulesets3 decks3 saves7 tutorials2 app-status149 protocol2 docs ads · purchases128 official · family ·modern-american french · spanish-40 ·spanish-48 SWIFT HomefeltCardsdecks · PCG32 CanastaCorerules · bots · saves CanastaCLI iPhone app KOTLIN kotlin/cardshomefelt.cards kotlin/corecanasta.core kotlin/cli Android app RUST homefelt-cardsdecks · PCG32 canasta-rulesrules · bots · saves canasta-cli canasta-wasm → web/ canasta-server ONE SUITE spec/behaviour same tests,every driver

A behaviour exists once a scenario pins it. House rules are settings in spec/rulesets/*.json, never an if on a rule set's name. File, type and field names match across the three languages, so a change in one can be read straight across into the other two.

03 three flows

One move, on the device and at a table.

Every core has the same shape: state out, actions in, one update function. The server puts the same engine behind a queue.

A local move · all three clients · built

A move at an online table · web today · native planned

Sign in and sit down · web today · native planned

A table saves when it is created, when a seat changes, when the host acts, when a hand ends, when it goes idle and when the server stops. Every move a person makes in between is queued for the move log (table_moves) and written a moment later, so a turn never waits for the database; a table loaded after a crash replays it. Only a move answered in the last moment before a crash can be lost (proposal 1 below, built in #253).

04 inside the server

The server, layer by layer.

rust/canasta-server: one Axum binary. The rows here are the same rows as the client map in section 05, so the two can be read side by side.

swipe sideways →

layer
canasta-server Rust · Axum · tokio · sqlx
surfacewhat the outside touches
app.rsrouter · /health · WebSocket upgrade
ws.rshello, limits, a reader and a writer
http_auth.rs/auth/apple · google · guest · refresh · logout · DELETE /account
http_tables.rstables · invites · join requests · /me/tables
http_profile.rsGET and PATCH /me
web.rsCORS · refresh cookie · origin check
clients.rsthe hello's client: updateRequired, close 4426
groups, friends, table readsthe queries exist, the routes don't
/metricsPrometheus, internal port 9091 only · never on api.homefelt.io
alerts.rs · notify.rslog, metrics and ntfy pushes: load, move log, invite guessing
outside /health checkVercel Function, pinged every 5 min by cron-job.org
sessionwho holds the game
table.rsone task per table: seats, lobby, host actions, 120 s to reconnect, idle eviction
view.rswhat one seat may see; an allowlist that fails closed
protocol.rshello · do · host · leave → welcome · table · node · error
move logtable_moves, a bounded queue, replay on load
spectators · turn timersnamed in the docs, not designed
hand a seat to someone elsenot designed
game corepinned by spec/
canasta-rulesplay · meld · score · deal · special hands
botseasy · normal, played by the table itself
saved gamesthe move log and the bots' random sources
rule setsofficial · family · modern-american
a game idtables, invites, the table message · decision 0016
an engine per gamewhen game two arrives
cardsknows no game
homefelt-cardsfrench · spanish-40 · spanish-48 · PCG32 shuffle
platformnamed for Homefelt
auth/jwks · providers · tokens (ES256) · Apple revocation
sessions.rsidentities · refresh-token families
groups.rs · invites.rslinks, 6-symbol codes, join requests, failure budgets
alerts.rsinvite-guessing warnings in the log
config.rsHOMEFELT_* settings · rule set loader
production sign-in keysApple and Google setup · #48 #51
guests.rsguest seats from invite links, one table per token · decision 0018 · #255
email sign-in · keep a guest's games#256 · #262
money and signalsstore, ads, analytics
entitlementsverify purchases, share across devices · #240
analytics eventsdraft plan · PostHog EU
push: your turnsuggested · proposal 8
edgesside effects, passed in
TableStorePgStore in production · NoStore in tests
db/pool · 11 migrations compiled in · run at start
SeedsOS random in production · the parity deal in tests
deploy filesfly.toml · Dockerfile · deploys by hand
the first deployFly.io and Neon · #50 · #133
deploy on merge#225 · waits on CI, #53

Connections never touch a game. They send commands down a channel to the table's task, which answers each seat on that seat's own bounded outbox. Two players acting at once are put in order by the channel, so there are no locks around a game.

05 inside a client

Three clients, built as mirrors.

The same rows as the server, three columns. The game rows match file for file. The platform rows are where the web is ahead: it has the network, sign-in and online tables, and the native apps have none of them yet.

swipe sideways →

layer
iPhone swift/App · SwiftUI
Android kotlin/app · Compose
web web/src · React · Vite
surfacescreens
RootView · TableViewActionBar · CardViews · HandScoreView · RefusalCard
CoachBubble · TutorialOfferguided first hand
SettingsView
status banner and sheetat safe points · blocking view at a sunset
lobby · online tablesign-in, lobby; TableView fed by the seat view · #258
join as a guestfrom an invite link, one table · #258
RootView · TableViewActionBar · CardViews · HandScoreView · RefusalCard
CoachBubble · TutorialOfferguided first hand
SettingsView
status banner and sheetat safe points · blocking view at a sunset
lobby · online tableOnlineModel · OnlineViews; the solo TableView fed by the seat view · #259
join as a guestfrom an invite link, one table · #259
RootView · TableViewActionBar · CardViews · HandScoreView · RefusalCard
CoachBubble · TutorialOfferguided first hand
Home · routes · gamesthe game registry, lazy engines
StatusLayerbanner, reload at a safe point
online/OnlineApp · Lobby · MyTables · OnlineTable · NameForm
join as a guestGuestJoin on /join/t/*, their table only · #255
sessionwho holds the game
NodeStatedrives the core as the CLI does · Refusal
Session · TableClientHomefeltOnline, pinned by spec/online
NodeStatedrives the core as the CLI does · Refusal
Session · TableClienthomefelt.online, every spec/online transcript
nodeState · tableModeldrives the Wasm session
onlineStatethe same table, fed by the server
session · tableClientpure machines, pinned by spec/online
game corepinned by spec/
CanastaCorePlay · Meld · Score · Deal · Bot · SavedGame · Tutorial · GameScreen
kotlin/corethe same files, in canasta.core
canasta-wasmcanasta-rules itself, behind engine.ts
cardsknows no game
HomefeltCards
kotlin/cards
homefelt-cardsinside the Wasm module
above this line a game owns the code · below it, the Homefelt platform does
platformnamed for Homefelt
SaveStoreone saved-game.json
DisplaySettingsUserDefaults
strings · themegenerated from design/
HomefeltStatusfeed selection, wired into the app
HomefeltNetnetwork layer over URLSession · decision 0015
StatusClient · StatusStorefetch and cache · dismissals and select
AuthClient · ServerClient · GameSocketHomefeltNet; dev sign-in, Apple off until #51 · #258
SaveStoreone saved-game.json
DisplaySettings
strings · themegenerated from design/
kotlin/statusfeed selection, wired into the app
kotlin/netnetwork layer over one OkHttpClient · decision 0015
StatusClient · StatusStorefetch and cache · dismissals and select
AuthClient · ServerClient · GameSocketkotlin/net over OkHttp; dev sign-in, Google and Apple off until #48 #51 · #259
saveStore · storageKeyslocalStorage, a namespace per game
settings
i18n · icu · theme cssgenerated from design/
status/statusClient · statusStore · reload
net/http · socket · errors
online/ clientsauth · providers · serverClient · gameSocket
security headers, CSPreport-only for now
enforced CSP#270, after sign-in is deployed
money and signalsstore, ads, analytics
adSlot · EntitlementStateHomefeltAds; pure, every spec/ads and spec/purchases case
StoreKit 2#237
AdMob · consent#239
analyticsdraft plan
adSlot · EntitlementStatehomefelt.ads; pure, every spec/ads and spec/purchases case
Play Billing#238
AdMob · consent#239
analyticsdraft plan
no ads on the webdecided
adSlot · EntitlementStateweb/src/ads; always skips with web, passes the shared cases
entitlement from the server#240
analyticsdraft plan
installable, offlinesuggested · proposal 9
edgesside effects, passed in
RandomSource · SaveStorageprotocols, in the constructor
Transport · FeedCache · StatusMemoryStorageURLSession, files; FakeTransport in tests
RandomSource · SaveStorageinterfaces, in the constructor
Transport · FeedCache · StatusMemoryStorageOkHttp, files; FakeTransport in tests
SaveStorage · FeedCache
Transport · SocketFactory · LocksLikefetch, WebSocket and Web Locks, all replaceable in tests

The gap worth noticing is the platform row. Everything else a native app needs to go online (sign-in, the server client, an online state holder, a lobby) exists only in TypeScript; the network layer is built on all three, and none of it is pinned by spec/ the way the rules are.

06 what's next

Built, moving, decided, later.

From the project board and the plan documents on 25 November. The board shows 193 items done, 6 in progress or in review, 15 to do and 6 waiting on Eduardo.

swipe sideways →

area
built
in progress
planned
future
rules and spec

Three mirrored cores and the behaviour suite

Official, Family and Modern American rule sets

Easy and Normal bots

Beginner aids and the guided first hand

Decks as data, French and Spanish

Beginner aids settings #99

Show a declared special hand's cards #245

Bot tests on unusable views #191

Record a real family hand #49

Cross-core fuzzing proposal 6

server

Sign-in checked by the server; sessions

Tables, lobby, host handover, invites

Postgres persistence, restored tables

Limits and invite defences

A game id on tables and invites 0016

Move log: every accepted move, replayed after a crash

Metrics, ntfy alerts, an outside health check, the scaling rule 0017

Outdated clients refused (protocol 1.0.0)

Guest seats from an invite link #255

Production sign-in keys #48 #51

Entitlements #240

Email sign-in, keep a guest's games #256 #262

Rematch at the same table, guests kept #287

Groups and friends endpoints

Spectators, turn timers

Push proposal 8

iPhone and Android

Solo play, saved games, tutorial

Spanish, from one string catalog

Date versions and build numbers

Status feed selection logic

Status client, banner and blocking views

Network layer, a client per service 0015

Ad slots and entitlement cores

Online play before the stores #258 #259 #261

StoreKit 2, Play Billing #237 #238

AdMob and consent #239

One Homefelt shell app decision 0007

web

Wasm engine, solo play, Continue

Homefelt home and per-game routes

Sign-in, lobby, online tables

Status messages and reload banner

Security headers, CSP report-only

Session and TableClient machines, pinned by spec/online

Join as a guest from an invite link #255

Enforce the CSP once sign-in is deployed #270

Spanish e2e in the online build #188

Installable and offline proposal 9

infra and ops

Deploy files for Fly.io and Neon

Two Vercel projects: the site and the web game

Neon point-in-time restore

Local verification gate decision 0005

App-status runbook, checked by bin/test app-status

First deploy to Fly.io and Neon, waiting on Eduardo #50 #133

Docs site on Vercel #133

CI back on #53

Deploy on merge #225

Off-provider backup proposal 10

A second machine, past 100 connections proposal 10

money and messaging

App-status feed spec, hosted at homefelt.io

Ads and purchases spec, checked by bin/test ads

Online client spec: Session, TableClient, transcripts, a hand against the server

Decision: no RevenueCat 0014

Spanish store listings #138

Three-month review #241

Analytics on PostHog EU draft

Ad mediation past $100 a month

games

Canasta

Hand and Foot, then Buraco

Spades, Hearts, Ludo

Chinchón, Brisca, Tute, Escoba

The board lags the repository in places: #213 shows as in review but is merged. Draft plans stay in the future column until Eduardo accepts them.

07 review

What I'd change, and when.

The foundations are unusually sound for a project this young: one writer per table, a view that fails closed, injected randomness, decisions written down. These are the places I'd push.

now · decided · built1 · small

Log every accepted move

A crash loses every move since the last hand ended. The saved game is already a seed plus a move log, so appending each accepted move to a table_moves row makes any crash recoverable by replay.

Write it off the hot path through a bounded queue, so Neon waking up never stalls a turn.

now2 · small

See the server before family does

Today the only signals are fly logs and the dashboard. Add counters (connections, tables in memory, move and save latency, refusals by code), an outside check on /health, and an alert that reaches your phone.

The first real game night is the worst time to learn what normal looks like.

risk3 · yours

CI has been off since 19 November

Every merge rests on local runs, and deploy-on-merge (#225) waits on it. A spending limit on Actions, or a self-hosted runner on the Mac, restores the gate.

With agents opening most pull requests, an independent check matters more, not less.

decided · built4 · large

Pin the online client in the spec

Native online play is the largest unbuilt block, and it now comes before the store release (#257 to #259). Before writing it twice more, turn the web's sign-in, reconnect and lobby logic into pure state machines with scenarios in spec/: given these server frames, the client state is this. Built for the web in #257 (spec/online, 72 transcripts, bin/test online-server) and for Swift as HomefeltOnline (#258) and for Kotlin as kotlin/online (#259).

It is the Reflex rule applied to the platform row, and it lets the behaviour suite drive the server too.

decided · built5 · small

Freeze protocol v1 before the stores

Done in #233: every hello carries client with the protocol version, 1.0.0 in spec/protocol/version.json. The server refuses another major, an app below its platform's minimum (HOMEFELT_MIN_CLIENT_VERSIONS) and a hello without client, with updateRequired and close 4426.

The game id goes in with the same change.

next6 · medium

Fuzz the three cores against each other

The bots alone are about 1,600 lines, three times over, and four long parity games guard them. Play thousands of seeded bot games through all three CLIs each night and compare the logs.

Scenarios catch the rules someone thought of. Differential runs catch the ones nobody did.

next7 · medium

Make entitlements a platform table

For #240, store user, product, source, verified_at with no game in the name, verified against Apple's and Google's servers, with an offline grace period on the device.

"Remove ads" will want to cover every Homefelt game, and the web needs to read it.

later8 · large

Tell people it's their turn

Nothing sends a push today. For families playing from different houses, a "your turn" or "Ana invited you" notification may matter more than any other feature. It needs device tokens, APNs, FCM and web push.

Games are played in one sitting for now, so this waits.

later9 · small

Let the web game install and work offline

Local play already needs no server, and there is no service worker. A small one would make play.homefelt.io installable and playable on a plane.

It must respect the reload-at-a-safe-point logic the status layer already has.

later10 · small

Keep a backup outside Neon, and write the way past one machine

Point-in-time restore protects against mistakes but not against losing the provider; a nightly dump elsewhere and one restore drill covers that. Separately, record now how a second machine would work (a lease per table in Postgres, or Fly's replay header) and what load would trigger it.

Neither is urgent at 200 connections. Both are cheaper to think through before they are.

08 decisions

Twelve decisions, nothing left open.

Decided on 25 November