CodeForge is a distributed code execution platform with an async execution pipeline, secure Docker-based language runners, queue-driven workers, result caching, retry recovery, and a one-page IDE frontend.
- Async-first architecture: API responds quickly after queueing jobs.
- Multi-language execution: Python 3, Node.js 20, Java 17, C++20.
- Isolated execution with Docker limits (network off, memory/pids/cpu constraints).
- Redis-backed fast polling results.
- RabbitMQ-based job dispatch and retry flow.
- PostgreSQL durability for submissions and final results.
- Reliability services: DLQ retry processor, worker heartbeat monitor, autoscaler.
- Interactive frontend IDE with resizable panels and live status polling.
CodeForge/
backend/ # API, workers, queue processing, Docker execution engine
frontend/ # React IDE client
- Frontend sends
POST /execute. - API validates payload, stores submission, publishes job to RabbitMQ.
- Worker consumes job and executes code in language-specific runner container.
- Worker writes result to Redis cache and PostgreSQL.
- Frontend polls
GET /execute/:submissionIduntil final status.
flowchart LR
UI[React Frontend] -->|POST /execute| API[Express API]
API -->|INSERT submission| PG[(PostgreSQL)]
API -->|publish job| MQ[(RabbitMQ)]
W[Worker] -->|consume| MQ
W -->|docker run| DR[Runner Images]
W -->|cache result| RD[(Redis)]
W -->|finalize result| PG
UI -->|GET /execute/:id| API
API -->|read-through cache| RD
API -->|fallback read| PG
- Frontend sends
POST /execute. - API validates request and inserts
PENDINGsubmission. - API publishes execution job to RabbitMQ and updates submission to
QUEUED. - Worker consumes message, marks
RUNNING, executes in Docker, computes verdict. - Worker caches result in Redis and writes final state to PostgreSQL.
- Frontend polls
GET /execute/:submissionIduntil terminal status.
- Durable canonical record: PostgreSQL
submissions - Hot read path: Redis hash
exec:result:{submissionId} - Transport: RabbitMQ queue
execution.queue
Core runtime components:
- API server (Express)
- Worker process(es)
- PostgreSQL
- Redis
- RabbitMQ
- Runner images:
codeforge/runner-python3:latest,codeforge/runner-nodejs20:latest,codeforge/runner-java17:latest,codeforge/runner-cpp20:latest
- Backend: Node.js, Express, PostgreSQL, RabbitMQ, Redis
- Execution isolation: Docker
- Frontend: React (react-scripts)
- Node.js 18+
- Docker Desktop
- PostgreSQL, Redis, RabbitMQ (local or containers)
In backend, copy .env.example to .env and update values for your machine.
cd backend
npm install
cd ../frontend
npm installcd backend
npm run start:allstart:all performs:
db:initdb:migraterunners:build- Starts API + worker + retry processor + health monitor + autoscaler
Recommended: run frontend on 3001 and backend on 3000.
Windows PowerShell:
cd frontend
$env:PORT=3001; npm startFrom backend directory:
npm start-> API servernpm run start:worker-> execution workernpm run start:core-> API + workernpm run start:services-> API + worker + retry + health + autoscalernpm run setup:all-> init DB + migrate + build runner imagesnpm run start:all-> setup + all long-running servicesnpm run runners:build-> build runner imagesnpm run runners:clean-> remove runner imagesnpm run db:init-> apply base schemanpm run db:migrate-> apply resilience schema changesnpm run retry:processor-> DLQ retry processornpm run worker:health-monitor-> stuck worker detectionnpm run worker:autoscaler-> dynamic worker scalingnpm run smoke:test-> backend smoke test
POST /execute
Request body:
{
"language": "python3",
"code": "print('hello')",
"stdin": "",
"expected_output": "hello",
"timeout_sec": 10
}Response:
{
"submission_id": "uuid",
"status": "QUEUED",
"poll_url": "/execute/uuid"
}GET /execute/:submissionId
Returns in-progress or final status, output, runtime, exit code, and source (redis or postgres).
GET /health
- PENDING
- QUEUED
- RUNNING
- ACCEPTED
- WRONG_ANSWER
- TIME_LIMIT
- MEMORY_LIMIT
- RUNTIME_ERROR
- SYSTEM_ERROR
--network none--read-only- Memory/CPU/PID limits
- tmpfs mounts for execution
- Timeout-enforced command execution
This project uses Docker-based code execution from worker processes. Ensure your production host allows Docker usage by worker services.
Practical deployment model:
- Frontend on static hosting (for example Cloudflare Pages).
- Backend stack on Docker-capable VM (API + worker + Postgres + Redis + RabbitMQ).
- Run backend services as always-on processes (compose/systemd/PM2).
- CORS errors: verify
FRONTEND_URLinbackend/.env. - 400 on submit: verify request payload and
expected_outputtype. - Execution failures: confirm runner images exist and Docker is running.
- Stuck jobs: check
worker:health-monitorlogs. - Missing retries: check
retry:processorlogs.
MIT