CodeForge is a comprehensive, production-ready code execution platform. It features a scalable microservices architecture, a sleek modern React frontend with integrated Monaco Editor, and a high-performance Go-based job dispatcher that spins up isolated Docker sandboxes for secure code execution.
- Isolated Code Execution: User submitted code is executed inside hardened Docker containers (
--network none,--read-only, and strict Seccomp profiles). - Microservices Architecture: Independently scalable services for Auth, Problems, and Submissions, routed seamlessly via Traefik.
- High-Performance Dispatcher: A lightweight Go worker that listens to Redis and natively interfaces with the Docker SDK.
- Premium Frontend: A Vite React application featuring a glassmorphism dark-mode UI, smooth micro-animations, and a fully functional IDE experience via
@monaco-editor/react. - Robust Backend: Python FastAPI REST services with Pydantic validation, JWT authentication, and SQLAlchemy/Alembic database management.
CodeForge uses a robust microservices architecture to ensure scalability and separation of concerns.
graph TD
Client[Web Browser / React Frontend] -->|HTTP/REST| Gateway[Traefik API Gateway]
Gateway -->|/api/v1/auth| Auth[Auth Service FastAPI]
Gateway -->|/api/v1/problems| Problems[Problems Service FastAPI]
Gateway -->|/api/v1/submissions| Submissions[Submissions Service FastAPI]
Auth --> DB[(PostgreSQL)]
Problems --> DB
Submissions --> DB
Submissions -->|Enqueue Job| Redis[(Redis Broker)]
Redis -->|Consume Job| Worker[Go Execution Dispatcher]
Worker -->|Create & Run| Sandbox[(Docker Sandbox)]
- Frontend: React, Vite, React Router, Monaco Editor, Vanilla CSS
- API Gateway: Traefik
- Backend Services: FastAPI, Python 3.11, PostgreSQL (SQLAlchemy + Alembic)
- Message Broker & Cache: Redis
- Worker/Dispatcher: Go
- Infrastructure & Orchestration: Docker, Docker Compose, Kubernetes
When a user submits code, the system processes it asynchronously to ensure high performance and non-blocking operations.
sequenceDiagram
participant User
participant Frontend as React Frontend
participant API as FastAPI Backend
participant DB as PostgreSQL
participant Redis as Redis Queue
participant Worker as Go Worker
participant Sandbox as Docker Sandbox
User->>Frontend: Clicks "Run Code"
Frontend->>API: POST /api/v1/submissions
API->>DB: Save Submission (Status: PENDING)
API->>Redis: Enqueue Execution Job
API-->>Frontend: Return Submission ID
Worker->>Redis: Dequeue Job
Worker->>Sandbox: Spin up secure container
Sandbox->>Worker: Return Execution Output/Logs
Worker->>DB: Update Submission (Status: COMPLETED, Output)
loop Polling
Frontend->>API: GET /api/v1/submissions/{id}
API->>DB: Check Status
API-->>Frontend: Return Status & Output
end
Frontend-->>User: Display Results
- Docker and Docker Compose
- Node.js 18+ (for frontend development)
- Python 3.11+ (for backend development)
- Go 1.21+ (for worker development)
To spin up the database, Redis, the API Gateway, the Python microservices, and the Go execution worker simultaneously, use Docker Compose:
docker-compose -f docker-compose.microservices.yml up --build -d- The API Gateway (Traefik) will route requests on
http://localhost:8000 - The Traefik dashboard will be available at
http://localhost:8080
Navigate to the frontend directory and start the Vite development server:
cd frontend
npm install
npm run devThe frontend application will be available at http://localhost:3000.
The backend includes a comprehensive Pytest suite for the FastAPI application.
pip install -e .[dev]
pytest tests/- Container Hardening: Sandboxes run with
--network noneto prevent external network access and data exfiltration. - Read-only Filesystems: The execution environment mounts as read-only to prevent malicious scripts from altering the base image.
- Resource Limits: CPU and memory bounds are enforced to prevent fork bombs and memory exhaustion attacks.
- Seccomp Profiles: System calls are strictly limited.