01 / Runtime
The system at a glance
Follow the arrows from a visitor’s browser. Select any box for a plain-language explanation.
The website is the front door
From Michael’s Bài Chắn page, visitors can learn the rules, open the playable game, or share their family’s rules. The game and questionnaire are separate services, so each can be updated without moving the personal website.
02 / What happens
Three ways people use it
The same game page supports local practice and multiplayer. The rules form has its own path and storage.
Practice with bots
After loading the game, the hand and bots run in the browser. The current practice hand is saved on that device. It does not create a multiplayer room.
Play in a private room
The browser makes an HTTP request to create a room, then opens a WebSocket. Draw, Ăn, Chíu, Bốc, and Ù are messages on that connection. One Durable Object decides valid moves, runs server bots, and stores the table.
Share family rules
The bilingual form saves a draft in the visitor’s browser. Sending it makes a same-origin POST to the rules Worker, which stores a private row in D1 for review.
03 / Publishing
How changes reach the internet
Two repositories and two deployment paths. The website deploys automatically; game services currently use Wrangler commands.
Personal site
Public content and links
Playable web app
Pages and static assets
Rooms and rules
Separate release units
04 / Boundaries
What is stored where
Room access
The invitation URL contains a random 128-bit room ID. The six-digit table number only helps friends confirm they opened the same room. A returning player’s separate token restores their seat.
Room persistence
Each private room has its own SQLite-backed Durable Object. It owns the wall, player seats, actions, bots, and game state. A public browser sees only the view it is allowed to see.
Rule submissions
D1 stores public questionnaire submissions. There is no public endpoint for listing or reading them. The older private family questionnaire and its responses stay outside the public game build.
Monitoring
The game page loads New Relic Browser monitoring for page events, JavaScript errors, and game actions. Cloudflare Workers have sampled logs and traces. Multiplayer moves appear as WebSocket frames, so they do not make a new HTTP POST for every action.