System diagram
What runs where
A few api endpoints are public:
GET /api/quotes (stock prices), GET /api/rooms (clubs open now) and
GET /api/city (the City’s venues).
Trust model
The whole design follows one sentence: the browser asks, the server settles.The simulation is pure
All game logic lives in the simulation core: no DOM, no network, no clock, no
Math.random(). Randomness comes from a
seeded deterministic PRNG stored in the game state, so a night replays bit-for-bit.Value moves only on the server
Anything that changes NYX Points, Credits, stock units or access is decided in the api, inside a single SQL
transaction, with a ledger row written next to the balance change.
The chain is read, not reported
For a deposit the browser sends only a transaction hash. The api reads amount, sender and recipient from the chain
itself and waits for BNB Chain to confirm the transfer.
Identity comes from the token
The api verifies the Privy JWT itself (signature, issuer, audience, expiry). The player id is the token’s subject,
never a field in the request body.
The relay is a dumb pipe
The relay routes binary frames by a 3-byte header and never parses the payload. It stamps the sender id on every
frame a guest sends, so a guest cannot pretend to be someone else.
The books match the chain
The platform’s wallet and stock are reconciled with the chain: Credits owed to players must be covered by the
stablecoins the platform holds, and stock units in the books by the tokenized stock it holds on-chain.
One night, end to end
1
Day: prepare in the browser
The CEO orders stock, books staff and a DJ, runs promotion. Each action is a pure core function that returns a new
state or a typed failure. Live stock prices come from
GET /api/quotes (Binance RWA feed, cached briefly).2
Open the club
startNight begins a 360-minute night at 22:00. If the CEO goes live, the browser opens a relay room and announces it
to the api every few seconds, so it shows up in “Clubs open now”.3
Night: the host simulates, everyone watches
tickNight advances one in-game minute every second (or two or three per second at 2× and 3×). After any change the
host sends a gzipped snapshot of the club, at most four times per second. Guests and the DJ send only intents
(buy, mix); the host applies them and the next snapshot shows the result to everyone.4
Close at 04:00
endNight produces the night report. The career autosaves locally and syncs to the api (newest save wins), so it
follows the player to any device.5
Settle on the server
A guest’s night is settled by the api inside one transaction: the wallet can only shrink by what was spent, and the
tokens taken home cannot cost more than that. At City parties, purchases of real tokenized stock are paid in Credits:
the api holds the Credits and the stock until the party is settled, then pays the club owner their margin.
