CodeCrusher is a distributed system that lets users submit code, execute it safely in isolated Docker containers, and fetch execution results asynchronously.
- API + worker architecture
- Queue-based background processing
- Containerized code execution
- Service orchestration with Docker Compose
- Node.js (API server + worker)
- Express.js (HTTP API)
- Redis + BullMQ (job queue)
- MongoDB + Mongoose (result storage)
- Docker + Docker Compose (runtime and orchestration)
- Client sends code to API.
- API creates a job in Redis/BullMQ and stores submission metadata.
- Worker consumes the job and executes code in a short-lived Docker container.
- Worker stores execution status/response in MongoDB.
- Client polls result endpoint using
jobId.
server/→ HTTP API, queue producer, DB models, routes/controllersworker/→ queue consumer and code execution logicpackages/→ shared internal packages (Logger,ErrorHandler)
- Docker and Docker Compose installed
- Git installed
git clone https://github.com/ShashaankS/Codecrusher.git
cd Codecrushercp .env.example .envDefault values in .env.example are enough for local Docker usage.
Use either command below:
docker compose --env-file .env up -d --buildor
make startmake status
make logsMain containers:
code_crusher_server→ API server (default port3000)code_crusher_worker→ background code execution workercode_crusher_redis→ queue brokercode_crusher_mongo→ persistence layer
Base URL (local):
http://localhost:3000/api/v1
Endpoint: POST /submit
Supported languages: python, javascript
Request body:
{
"code": "print(1)",
"language": "python"
}Example cURL:
curl -X POST http://localhost:3000/api/v1/submit \
-H "Content-Type: application/json" \
-d '{"code":"print(1)","language":"python"}'Success response:
{
"success": true,
"jobId": "123456"
}Endpoint: GET /result?jobId=<jobId>
Example cURL:
curl "http://localhost:3000/api/v1/result?jobId=123456"If job is still processing:
{
"success": false,
"status": "Pending"
}If job is completed:
{
"success": true,
"status": "completed",
"response": "1\n"
}- This system is asynchronous: submission and result retrieval are separate steps.
jobIdis the link between submit and result APIs.- Worker-side execution is isolated using Docker for safer runtime behavior.
- Queue-based design improves scalability and decouples API response time from execution time.
