Building StarSync: realtime chat, editor sync, and code execution
Behind the scenes of building StarSync, a full-stack realtime collaboration workspace with native WebSockets and sandboxed Docker code execution.
Realtime collaboration workspaces require highly responsive synchronizations. When I designed StarSync, my goal was to combine DMs, room presence, shared text/code editing, and a canvas whiteboard into a single, cohesive experience.
The Realtime Sync Strategy
Instead of using higher-level abstractions like Socket.IO, I chose to work with native ws WebSockets on the backend. This decision kept overhead minimal and let me design custom frame protocols for:
- Collaborative Monaco Editor synchronization
- Active rooms typing indicator broadcasts
- Online presence tracking
// Example WebSocket message dispatcher
socket.send(JSON.stringify({
type: 'presence:update',
payload: { userId, roomState }
}));Running Code Safely in Docker
For safe execution of C, C++, Python, and TypeScript inside the Monaco editor, I integrated the backend with a Docker-based Piston runtime executor. Code is isolated inside brief sandboxed processes to prevent malicious operations from hitting the main servers.