System map · September 2026

How Bài Chắn is deployed

A guided map of the website, playable table, private rooms, rules questionnaire, and the services that keep each one running.

1 personal website3 Cloudflare Workers2 Cloudflare data storesWorkers Free

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 introduces the project. The game and public questionnaire open on their own Cloudflare URLs.
Select a box above

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.

1

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.

Browser→Game page→Local practice
2

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.

Game page→Room Worker→Room object
3

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.

Questionnaire→Rules Worker→D1

03 / Publishing

How changes reach the internet

Two repositories and two deployment paths. The website deploys automatically; game services currently use Wrangler commands.

Website

Personal site

Public content and links

personal-website repo→GitHub Actions→Azure Static Web Apps→michaelnguyen.net
Pushing the website’s main branch starts the Azure deployment workflow. The domain’s DNS points to Azure.
Game

Playable web app

Pages and static assets

bai-chan-game repo→public build + Wrangler→bai-chan-play Worker
Vinext builds the public routes. Only game tiles and audio are copied; private family questionnaire files are excluded from this bundle.
Backends

Rooms and rules

Separate release units

bai-chan-game repo→Wrangler deploy→rooms Workerrules Worker
The room Worker binds to Durable Objects. The rules Worker binds to D1. A rule form deployment does not replace a game room deployment.

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.