How the Atom Reaction backend was built
By Swapnil Shah · Updated 2026-11-24
Atom Reaction looks simple on screen, but a real-time multiplayer game needs a server that every player trusts. This is the story of how I built the backend: the choices I made, what worked, and what I would do differently.
Starting point: one server is the referee
In a multiplayer board game nobody should be able to cheat by editing their own browser. So the rule I started with was simple: the server owns the game. The browser sends a move, such as "place an orb in this cell", and the server decides whether it is legal, runs the explosions and sends the result back to everyone in the room.
I chose Python with FastAPI because it handles WebSocket connections natively, is quick to write and easy to test. React and Vite sit on the front, and the same server serves the built frontend, so the whole game is one small deployable unit.
Rooms live in memory
Each game room is a Python object holding the board, the players, whose turn it is and a timer. Keeping rooms in memory makes moves instant, because there is no database round trip on every click. The trade-off is that the server must run as a single worker process, otherwise two players in the same room could land on different workers and see different games.
That constraint is fine for a game of this size, and I added a cleanup loop that removes empty rooms after five minutes and abandoned ones after a couple of hours, plus a hard cap on the number of rooms, so memory cannot grow without limit.
The game engine
The heart of the backend is the engine that resolves a move. It places the orb, checks whether the cell has reached critical mass and, if so, explodes it, sending an orb to each neighbour and flipping them to the mover's colour. Then it repeats for every cell that has become critical, wave after wave, until the board is stable.
The server does not send every intermediate board to the browser. It sends the first wave in full and then only the cells that changed in each following wave. The browser replays those waves as an animation. This keeps messages small even when a single move sets off dozens of explosions.
Turns, timers and bots filling in
Every turn has a timer so a game cannot stall. If a player's connection drops, the server waits a short grace period and then lets a bot play for them, so the remaining players are never stuck. A player who has no legal move is eliminated automatically instead of freezing the game.
Testing the engine hard
A game engine bug is painful because players see wrong boards. I wrote tests that play thousands of random games and check invariants after every move, for example that orb counts never go negative and no cell is above critical mass. I also compared the new engine against the old one on tens of thousands of moves to prove they matched.
The same logic exists in JavaScript for pass and play and the bots, so I replay random games through both implementations and check that they agree move for move. Any mismatch is a bug in one of them.
What I would do differently
I would add the endless-chain guard from day one (see the next post), design the room store so it could move to more than one process, and write the replay comparison tests before the second implementation, not after. But the core idea, a small authoritative server and a thin client, has held up well.