Real-Time Collaborative Code Editor & Runner
Browser-based collaborative IDE supporting multi-user concurrent code editing via Operational Transformation (CRDT / Yjs), real-time WebSockets, Monaco Editor, and containerized code execution.
Problem Statement & Objectives
Engineering teams and technical interviewers require synchronized, zero-latency code sharing where multiple developers edit the same file simultaneously without keystroke clobbering, race conditions, or editor desynchronization.
Key Project Objectives:
- •Integrate Microsoft Monaco Editor into a React TypeScript interface supporting syntax highlighting for 10+ languages.
- •Implement real-time bidirectional synchronization over WebSockets with room isolation so each collaborative session remains private.
- •Resolve concurrent text edit conflicts gracefully using CRDTs (Conflict-Free Replicated Data Types).
- •Provide a secure code execution sandbox evaluating Python, JavaScript, and C++ code with strict timeout limits.
System Architecture
React client hosts the Monaco Editor connected via WebSocket to a Node.js signaling cluster. Text mutations are structured as Yjs CRDT operations, eliminating central conflict resolution bottlenecks. Redis Pub/Sub synchronizes messages across multiple Node.js socket server instances. A decoupled sandbox worker executes user-submitted code in disposable, resource-constrained Docker containers.
+-----------------------+ +-----------------------+
| BROWSER CLIENT A | | BROWSER CLIENT B |
| (Monaco Editor + Yjs)| | (Monaco Editor + Yjs)|
+-----------------------+ +-----------------------+
\ /
\ (WebSocket WSS) / (WebSocket WSS)
v v
+-------------------------------------------------------------+
| NODE.JS / TYPESCRIPT GATEWAY |
| (Socket.io Room Hub + Authentication Handshake) |
+-------------------------------------------------------------+
|
v
+-------------------------------------------------------------+
| REDIS PUB/SUB & STATE |
| - Room State Presence & Cursor Position Broadcasting |
| - Active Collaboration Session Registry |
+-------------------------------------------------------------+
|
v
+-------------------------------------------------------------+
| SANDBOXED CODE EXECUTION RUNNER |
| - Isolated Docker Containers (CPU/RAM/Network Throttled) |
| - Subprocess Execution with 5-Second Timeout Deadlines |
+-------------------------------------------------------------+Database Design (Document & Cache (MongoDB / Redis))
Stores saved code snippets, revision histories, and active room connection metadata.
Active and archived collaborative coding sessions.
Audit trail of executed scripts and exit codes.
REST API Specifications
Generates a unique 6-character room token and initializes editor document state.
{
"room_code": "DEV-492",
"language": "javascript",
"websocket_url": "wss://api.example.com/ws/DEV-492"
}Executes provided code in an isolated sandbox and returns standard output stream.
{
"stdout": "Hello, World!\nCalculated Fibonacci(10) = 55\n",
"stderr": "",
"execution_time_ms": 84,
"exit_code": 0
}Step-by-Step Implementation Guide
Step 1: WebSocket Room Management in Node.js
Set up a Socket.io server with room joins, peer presence broadcasts, and disconnect cleanup handlers.
Step 2: Monaco Editor Binding with Yjs Provider
Connect React component state to Monaco editor instances, syncing CRDT updates seamlessly across all peers.
Placement Viva & Technical Questions
Questions commonly asked by college examiners and product company interviewers regarding this project architecture.