B7.6.1 · dive 1 of 3 · module B7.6
The JSON API.
Phoenix exposes a thin JSON facade that turns a request into a command — a guess returns an accepted status while scoring runs behind the boundary — and a read into a privacy-safe view, owning no per-room state of its own.
The idea
codemojex · the json apiThe surface is a thin facade, not the game. Phoenix exposes a JSON API that turns a request into a command on the systems and a read into a view, and it owns no game state of its own: there is no process per room, no in-memory copy of a game on the web tier. State lives where it belongs — on the Postgres floor, in the cache, in the Valkey tier — and the surface reaches for it.
A guess is a command that returns at once. The endpoint validates, charges, and enqueues, then answers with an accepted status while the scoring runs behind the boundary; the player’s request does not wait for a score. Reads go the other way, into privacy-safe views: a player can ask for their own attempts, their best total, and the leaderboard ranked by best total, and for nothing else.
The view is shaped at the boundary, not by trusting the caller. A response never carries another player’s guesses or the secret, because the query that builds it cannot reach them, so a curious client gains nothing by asking a different way. The same surface carries the idempotent webhook that confirms a star purchase, an endpoint among endpoints, while the game keeps moving only its own currencies.
The doors
the sibling coursesEchoMQ — the protocol, in depth
The bus B3 narrates, taught rung by rung: the keyspace, the Lua inventory, and the 3.0 Stream Tier — XADD, XREADGROUP, XACK — with conformance on Valkey.
Redis Patterns Applied
The substrate patterns under the bus: sorted sets, atomic Lua moves, locks, and streams — the judgement layer.
/echo-persistenceEcho Persistence — the durable floor
Beneath the volatile tiers: the Graft page engine built twice, the commit-LSN loop, and the stream archive on Tigris. Where Part I says state lives somewhere, this says where it lives durably.
References
sources · relatedSources
- Helland — Life Beyond Distributed Transactions (CIDR 2007)the surface as a facade over entities, owning none of the game’s state
- Erlang/OTP — the gen_server behaviourthe supervised processes the bus, its workers, and the endpoint run as
- The Go Blog — Share Memory By Communicatingthe worker decoupled from the crowd, scaling as more trees by message
Related
- BCS — the course homethe law, the id anatomy, the chapter map
- Echo Persistencethe durable floor beneath the bus