B7.1.2 · dive 2 of 3 · module B7.1
The four layers.
Codemojex stands on four layers: a Postgres record of truth for money, the secret, and state; an EchoStore cache of what is immutable for a game; an EchoMQ real-time tier; and a Phoenix surface.
The idea
codemojex · the layeringCodemojex stands on four layers, and each keeps the job the course gave it. The floor is Postgres: the record of truth for money, for a game’s secret and its commitment, and for game state, durable and constrained. Money is real and a game hides a secret, so both must survive a restart and stay auditable, which is why they live here and nowhere else as a source.
Above the floor sits EchoStore, a read-hot cache: a game’s secret and its emoji set do not change for the game’s life, so they are held in memory under the game’s version and read without touching Postgres on the hot path, falling back to the floor on a miss. Above that, EchoMQ on Valkey carries the real-time work — the per-player guess lanes, the leaderboard, the locks, the tier claims — all of it derived from the floor and the guesses, and all of it reconstructable.
At the top, Phoenix is the surface: a JSON and channel API behind privacy-safe views, and an operator console. Nothing above the floor is a second source of truth; the cache can be dropped and refilled, and the real-time tier can be rebuilt from the record. The reference implementation places money and the secret on the floor and treats everything above it as a fast, disposable view.
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)entities keyed by id, and a record of truth a game can audit
- Erlang/OTP — the ets modulethe read-hot cache that holds a game's immutable secret and set
- Kreps — The Log (LinkedIn Engineering)the queues and streams the real-time tier is built from
Related
- BCS — the course homethe law, the id anatomy, the chapter map
- Echo Persistencethe durable floor beneath the bus