A cloud-native Integrated Development Environment (IDE) built using cutting-edge technologies like Kubernetes (K8s), Docker, Node.js ,Next.js and AWS. Designed with scalability, isolation, and seamless developer experience in mind, this Cloud IDE allows users to edit code, access terminals, and execute code in isolated environments. The system leverages WebSockets, xterm.js, and PTY for terminal emulation, with a robust architecture comprising several microservices.
- Scalable Architecture: Built using Kubernetes and Docker to ensure high scalability and isolation.
- Cloud-Native Approach: Environment isolation for secure and efficient resource utilization.
- Terminal Access: Real-time terminal interaction using PTY and xterm.js.
- File Editing and Execution: Edit files and execute code via WebSockets for real-time collaboration.
- Automatic Cleanup: Pods and resources are automatically cleaned up after inactivity (~5 minutes with 0 WebSocket connections).
- Auto-Destruction of Pods: If a user is inactive for ~5 minutes, the associated pod is automatically destroyed to free up resources.
- Kubernetes (K8s): Orchestrates the pods for isolated environments.
- Docker: Provides containerized environments for user sessions.
- AWS S3: Stores base images and other assets.
- Node.js & TypeScript: Backend services and business logic.
- Next.js: Frontend for user interaction.
- xterm.js: Terminal emulation.
- WebSocket: Real-time communication for terminal and file execution.
The Cloud IDE is divided into four main services:
- Built with Next.js.
- Provides a responsive and user-friendly interface for:
- Code editing.
- Terminal access.
- Real-time feedback on execution.
- Initializes the environment by copying the base image to AWS S3 and setting up the necessary configurations.
- Prepares the environment for user sessions..
- Manages the AWS configuration via
aws.ts
.
- WebSocket-based service for terminal code execution.
- Features:
- Starts an independent runner for each user session.
- Displays a loading screen while the environment initializes.
- Manages pods and environment orchestration:
- Tells Kubernetes to start a pod for each user.
- Ensures environment isolation and efficient resource allocation.
- Destroys pods when no active WebSocket connections exist for ~5 minutes.
- Handles code execution and terminal access.
- Enables users to edit files and execute code over the WebSocket layer.
- Cleans up resources by destroying idle pods.
- Node.js (v16+)
- Docker
- Kubernetes
- AWS CLI
- S3 Bucket (for storing base images)
-User Access: A user accesses the Cloud IDE through the frontend (Next.js application).
-Environment Initialization: The Init Service prepares the environment by copying the base image to AWS S3.
-Runner Initialization: The Runner Service starts an independent runner for the user, establishing a WebSocket connection for terminal access and code execution.
-Pod Creation: The Orchestrator starts a Kubernetes pod for the user session.
-Code Execution: The user writes and edits code in the frontend. The code is sent to the Execution Service via WebSockets, where it is executed in the isolated environment.
-Terminal Access: The user can access a terminal in the browser using xterm.js, which communicates with the backend via WebSockets.
-Auto-Destruction: If the user is inactive for ~5 minutes, the Orchestrator destroys the associated pod to free up resources.
git clone https://github.com/your-username/cloud-ide.git
cd cloud-ide
Navigate to each folder (frontend, init-service, runner-service, orchestrator, execution-service) and install dependencies:
cd frontend
npm install
cd ../init-service
npm install
cd ../runner-service
npm install
cd ../orchestrator
npm install
cd ../execution-service
npm install
Create a .env
file in each service folder with the required configurations. Example for the init service:
AWS_REGION=your-region
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
S3_BUCKET=your-bucket-name
-
Frontend:
cd frontend npm run dev
-
Init Service:
cd init-service npm start
-
Runner Service:
cd runner-service npm start
-
Orchestrator:
cd orchestrator npm start
-
Execution Service:
cd execution-service npm start
Build and push Docker images for each service:
cd service-folder
docker build -t your-docker-repo/service-name .
docker push your-docker-repo/service-name
Deploy services to Kubernetes:
-
Create a Kubernetes namespace:
kubectl create namespace cloud-ide
-
Apply Kubernetes manifests:
kubectl apply -f k8s-manifests/
-
Verify the pods:
kubectl get pods -n cloud-ide
Method | Endpoint | Description |
---|---|---|
GET | /start |
Start a new runner. |
POST | /execute |
Execute user commands. |
DELETE | /destroy/:id |
Destroy a runner pod. |
Method | Endpoint | Description |
---|---|---|
POST | /orchestrate |
Start a pod for a user session. |
DELETE | /cleanup/:id |
Destroy inactive pods. |
We welcome contributions to improve this Cloud IDE. Follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name
- Commit your changes:
git commit -m 'Add feature-name'
- Push the branch:
git push origin feature-name
- Open a pull request.
This project is licensed under the MIT License.