How vaibhavdevelopor/real-time-collaborative-code-editor works
MaxHeap is a browser-based collaborative code editor. Users create or join a room, edit shared code, and receive synchronized edits and presence; they can also chat, save sessions, browse recent saves, and run code remotely. The room page orchestrates client UI and socket/OT hooks; server socket handlers coordinate room events and authoritative edits, with Redis document state and MongoDB session persistence. README documents seven execution languages and Redis/MongoDB tiers, but sampled code does not establish every persistence path or client execution wiring, so those edges are omitted where unverified.
Main entry points: Room.jsx Room orchestration · editorHandler.js Edit event coordinator · server.js HTTP and socket host · rooms.js Room and run API
Components 21
Client experience
- Route shell
client/src/App.jsx - Room discovery
client/src/pages/Home.jsx - Room orchestration
client/src/pages/Room.jsx - Code editor
client/src/components/Editor.jsx - Remote cursors
client/src/components/UserCursors.jsx - Editor toolbar
client/src/components/Toolbar.jsx - Room chat
client/src/components/Chat.jsx - Execution output
client/src/components/Output.jsx
Realtime collaboration
- Socket client
client/src/hooks/useSocket.js - Client OT state
client/src/hooks/useOT.js - Client transform
client/src/ot/transform.js - Room presence events
server/src/socket/roomHandler.js - Edit event coordinator
server/src/socket/editorHandler.js - Server OT engine
server/src/ot/transform.js
Server services
- HTTP and socket host
server/server.js - Authentication API
server/src/routes/auth.js - Room and run API
server/src/routes/rooms.js
Session storage
- Redis document cache
- Session model
server/src/models/Session.js
Code execution
- Paiza execution service
Other components
- Collaborator
Connections 24
- Collaborator → Route shell: opens editor
client/src/App.jsx - Route shell → Room discovery: routes to
client/src/App.jsx - Route shell → Room orchestration: routes to
client/src/App.jsx - Collaborator → Room discovery: creates or joins
README.md - Room orchestration → Socket client: manages connection
client/src/pages/Room.jsx - Room orchestration → Client OT state: manages OT
client/src/pages/Room.jsx - Room orchestration → Code editor: renders
client/src/pages/Room.jsx - Room orchestration → Room chat: renders
client/src/pages/Room.jsx - Room orchestration → Editor toolbar: renders
client/src/pages/Room.jsx - Room orchestration → Execution output: renders
client/src/pages/Room.jsx - Code editor → Remote cursors: renders
client/src/components/Editor.jsx - Client OT state → Client transform: transforms operations
client/src/hooks/useOT.js - Socket client → Edit event coordinator: sends edit events
- Socket client → Room presence events: sends room events
- HTTP and socket host → Authentication API: mounts routes
server/server.js - HTTP and socket host → Room and run API: mounts routes
server/server.js - HTTP and socket host → Room presence events: registers handler
server/server.js - HTTP and socket host → Edit event coordinator: registers handler
server/server.js - Edit event coordinator → Server OT engine: transforms edits
server/src/socket/editorHandler.js - Edit event coordinator → Redis document cache: reads and writes
server/src/socket/editorHandler.js - Edit event coordinator → Session model: saves snapshots
server/src/socket/editorHandler.js - Room and run API → Session model: reads and saves
server/src/routes/rooms.js - Room and run API → Paiza execution service: submits and polls
server/src/routes/rooms.js - Room orchestration → Room and run API: requests execution