A powerful, real-time collaborative Integrated Development Environment (IDE) that runs in the browser. Built with the MERN stack and Docker, it allows users to write code, manage files, and execute commands in a secure, isolated environment.
- Real-time Collaboration: Code with others in real-time using operational transformation (via Socket.io).
- File System Management: Create, read, update, and delete files and directories.
- Integrated Terminal: Execute commands directly in the browser (powered by Docker containers).
- Syntax Highlighting: Support for multiple languages using Monaco Editor.
- Secure Execution: User code runs in isolated Docker containers.
The core of the isolation mechanism relies on Docker.
- Controller: The
server/controllers/playground.controller.jsmanages the lifecycle of containers usingdockerode. - Dynamic Provisioning: When a user opens a project, a dedicated Docker container is spun up.
- Networking:
- Each container exposes port
1000(for the internal runner agent) and3000(for the user's preview server). - The host machine maps these to dynamic available ports (starting from 9000).
- Each container exposes port
- Persistence: The project files are stored on the host machine at
../Project/{userId}/{projectId}and mounted into the container at/app. This ensures that even if the container is destroyed, the user's code is safe.
- Control Plane (HTTP):
- The client sends requests (create project, get list) to the Main Server (Express).
- The Main Server talks to the Docker Daemon to manage containers.
- Data Plane (Socket.io):
- Once a container is running, the Client connects directly to the container's
runneragent via Socket.io (on the dynamically mapped port). - File Operations: File saves/reads are sent over this socket. The
runnerwrites to the mounted volume. - Terminal: Keypresses are sent to the
runner, which pipes them into anode-ptyprocess (pseudo-terminal). Output is streamed back to the client. - Cursors: Cursor movements are broadcasted to other users in the same room via the
runner.
- Once a container is running, the Client connects directly to the container's
Inside each container runs a lightweight agent called the Runner (BaseImage/runner/index.js).
- It acts as a bridge between the frontend and the container's shell/filesystem.
- It uses
chokidarto watch for file changes and syncs them. - It uses
node-ptyto spawn a shell (shorbash) allowing users to run commands likenpm installornode index.js.
- Framework: React (Vite)
- State Management: Redux Toolkit
- Styling: TailwindCSS, DaisyUI
- Editor: Monaco Editor
- Communication: Socket.io-client
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB (Mongoose)
- Containerization: Dockerode (Docker API)
- Communication: Socket.io
- Docker: For container orchestration and code execution isolation.
- Docker Compose: For managing multi-container applications.
-
Clone the repository:
git clone <repository-url> cd CollaborativeCloudIDE
-
Start the application:
docker-compose up --build
-
Access the application:
- Frontend:
http://localhost:5173 - Backend:
http://localhost:1001
- Frontend:
-
Navigate to the server directory:
cd server -
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile in theserverdirectory and add your MongoDB URI and other configs. -
Start the server:
npm run dev
-
Navigate to the client directory:
cd client -
Install dependencies:
npm install
-
Start the development server:
npm run dev
Contributions are welcome! Please feel free to submit a Pull Request.