A real-time collaborative code editor built with Next.js, Socket.IO, WebRTC, and the Monaco Editor.
This project was developed for the Distributed Systems & Web Services course under the supervision of Dr. Abdelghafar Shenaway.
- Aysha Ahmed Kassem
- Nada Khamis Etman
- Maryam Ahmed Elsayed
- Mohamed Kamal Mohamed
- ABDELRHMAN MOUSTAFA SALEM
The application allows users to create private coding rooms, request access to existing rooms, collaborate on code in real time, and communicate through peer-to-peer audio/video streams.
- Real-time code synchronization using
Socket.IO - Conflict handling with Operational Transform (
OT) - Private room creation and room reservation
- Admin approval and rejection flow for join requests
- Multi-user remote cursor support
- Audio and video communication with
WebRTC - Monaco-based code editing experience
- Floating picture-in-picture video component
- Syntax highlighting for multiple languages
Next.jsReactTypeScriptSocket.IOWebRTC@monaco-editor/reactPM2Nginx
collaborative-code-editor/
├── components/
│ ├── CollabEditor.tsx
│ ├── RemoteCursors.tsx
│ └── VideoPiP.tsx
├── hooks/
│ └── useWebRTC.ts
├── lib/
│ └── ot.ts
├── pages/
│ ├── api/
│ │ └── socket.ts
│ ├── _app.tsx
│ └── index.tsx
├── styles/
│ └── globals.css
├── deploy-oracle.sh
├── ecosystem.config.js
└── README.md
- An admin creates a private room.
- The room ID becomes reserved while the admin remains inside the room.
- Another user submits a join request.
- The admin approves or rejects the request.
- Authorized users receive real-time code updates through
Socket.IO. - Audio/video signaling is exchanged through the server, while media flows directly through
WebRTC.
- A user types in the Monaco editor.
- The app computes the difference between the previous and current code.
- The diff is converted into OT operations.
- The operation is sent to the server.
- The server broadcasts it to approved room members.
- Peers transform and apply the operation locally.
npm installnpm run devhttp://localhost:3000
https://collab-editor.ddns.net
The project is currently deployed on an Oracle Cloud Ubuntu instance and served through:
PM2for process managementNginxas a reverse proxyLet's Encryptfor HTTPS
The repository includes an automated deployment script:
./deploy-oracle.shThis script:
- builds the app locally
- syncs the required files to the Oracle server
- installs production dependencies on the server
- restarts the app with
PM2
npm run buildHOSTNAME=0.0.0.0 PORT=3000 npm startpm2 start ecosystem.config.js
pm2 saveThe project uses public Google STUN servers by default. For stricter NAT environments, a TURN server should be added in useWebRTC.ts.
Example configuration:
const ICE_SERVERS = [
{ urls: 'stun:stun.l.google.com:19302' },
{
urls: 'turn:your-turn-server.com:3478',
username: 'user',
credential: 'password',
},
]- Replace OT with a CRDT-based approach such as
Yjs - Add a text chat channel
- Add sandboxed code execution
- Add a file tree sidebar
- Add export or GitHub Gist integration