CollabBoard
A real-time collaborative whiteboard. A Spring Boot server syncs every shape edit over STOMP and WebSocket to everyone in the room, with live cursors and a presence roster.
- sync bugs, each reproduced by a failing test first
- 8
- tests passing
- 241
- channels: REST for rooms, WebSocket for live edits
- 2
- Java 17
- Spring Boot
- WebSocket (STOMP)
- PostgreSQL (Neon)
- React
- JUnit 5
- Docker

The problem
Drawing on a canvas is the easy part. The hard part is keeping everyone's board identical when two people act at the same moment, or when someone's connection drops.
Pipeline
- Browser draws
- STOMP over WebSocket
- Validate and sanitise
- Row lock and save
- BroadcastYour tabEveryone else
How it works
The browser draws immediately and sends the event over STOMP on a WebSocket. The Spring Boot server validates it, updates the room's snapshot in PostgreSQL inside a transaction, and broadcasts it to everyone subscribed to the room.
REST handles creating and loading rooms, because that is one question and one answer. WebSocket handles drawing, cursors and presence, because the server has to push.
Events that change the board persist; cursor and laser events are relayed with no database write.
It ships as one Docker image on Render that serves the React app, the API and the WebSocket from a single address. Boards live in Neon's free PostgreSQL, which, unlike Render's free database, does not expire.
Each sync bug below was reproduced with a failing test before it was fixed, including tests that connect real STOMP clients to a live server.

The decision
- I chose
- Lock the room's row (SELECT … FOR UPDATE) for every change.
- Instead of
- Writing the snapshot without a lock.
- Because
- With two people drawing at once, an unlocked write silently drops one person's stroke from the saved board. The lock serialises writes to a room, which costs some throughput in a busy room and never loses work.
What broke, and the fix
Two people draw at once and one stroke disappears from the saved board.
Every change runs in a transaction holding a database row lock.
A draw and a delete arrive in the wrong order and leave a zombie shape.
Each client's messages are handled strictly in the order they were sent.
Work done offline is lost, and missed changes never arrive.
Changes queue and flush in order on reconnect, then the board resyncs from the server.
Undo erases what a teammate drew since.
Undo is per person and operation-based, so it reverses only your own action.
A long stroke exceeds the 8 KB frame limit and drops the connection.
Raised the frame limit, and the client thins and caps strokes.
Anyone with a room code can send arbitrary JSON to every other browser.
Every event is rebuilt from an allowlist with size and range limits.
What I would do next
- Load-test a busy room to find where the per-room lock starts to hurt.
- Move from a single JSON snapshot to an operation log if boards grow large enough that rewriting the snapshot on every change gets expensive.