A full-stack competitive programming platform where users can solve problems, battle in real-time, and track their progress on a leaderboard. Supports 9 programming languages with isolated Docker/Kubernetes sandbox execution.
- Features
- Tech Stack
- Project Structure
- Prerequisites
- Quick Start (Docker Compose)
- Environment Variables
- Seeding the Database
- Running Locally (Development)
- Kubernetes Deployment
- API Reference
- Supported Languages
- π§© Problem Library β Browse, search, and filter by difficulty and tags
- βοΈ Code Battles β Real-time 1v1 matchmaking by difficulty using Socket.io
- π Leaderboard β ELO-based global ranking with dynamic points per problem
- π₯οΈ Multi-language IDE β Monaco editor with 9 language support
- π³ Sandboxed Execution β Code runs in isolated Docker containers (or K8s pods)
- π Admin Panel β Create, edit, delete problems with tags, difficulty, and custom points
- β Solved Tracking β Problems marked as solved after a correct submission
| Layer | Technology |
|---|---|
| Frontend | React 18, Vite, Monaco Editor, Socket.io Client |
| Backend API | Node.js, Express, Socket.io |
| Queue/Worker | BullMQ (Redis-backed job queue) |
| Database | PostgreSQL 15 |
| Cache / Pub-Sub | Redis |
| Code Execution | Docker-in-Docker (DinD) or Kubernetes pods |
| Auth | JWT (jsonwebtoken + bcryptjs) |
| Deployment | Docker Compose (dev) / Kubernetes (prod) |
Execution Engine/
βββ src/ # Backend source
β βββ index.js # Express API + Socket.io server
β βββ queue.js # BullMQ worker (code execution)
β βββ db.js # PostgreSQL queries
β βββ executor.js # Docker / K8s sandbox runner
β βββ schema.sql # Database schema
βββ frontend/ # React frontend (Vite)
β βββ src/
β β βββ pages/ # Route-level page components
β β βββ components/ # Shared components
β β βββ context/ # Auth & Socket contexts
β β βββ index.css # Global styles
β βββ Dockerfile.frontend
βββ docker/ # Language runner Docker images
β βββ python-runner/
β βββ cpp-runner/
β βββ java-runner/
β βββ kotlin-runner/
β βββ go-runner/
β βββ php-runner/
β βββ dart-runner/
β βββ c-runner/
β βββ sql-runner/
βββ k8s/ # Kubernetes manifests
β βββ namespaces.yaml
β βββ backend.yaml
β βββ frontend.yaml
β βββ postgres.yaml
β βββ redis.yaml
β βββ rbac.yaml
βββ migrations/ # SQL migration files
βββ seed.js # Database seeder (sample problems + users)
βββ Dockerfile.backend
βββ docker-compose.yml
βββ deploy-k8s.ps1 # K8s deploy script (PowerShell)
βββ build_k8s_images.ps1 # Build K8s images script (PowerShell)
- Docker Desktop (with Docker Engine running)
- Node.js 18+ (only needed for running seed.js locally)
- Git
For Kubernetes deployment: Enable Kubernetes in Docker Desktop Settings β Kubernetes β Enable Kubernetes
git clone <your-repo-url>
cd "Execution Engine"cp .env .env.local # or create manually (see Environment Variables section)These sandbox images must be built before starting the API:
docker compose build cpp-runner python-runner java-runner kotlin-runner go-runner php-runner dart-runner c-runner sql-runnerdocker compose up -d db redis api frontendServices will start in order:
dbβ PostgreSQL on port5433redisβ Redis on port6379apiβ Express API on port3000frontendβ React app on port5173
On first run, seed the database with sample problems and a test admin user:
node seed.jshttp://localhost:5173
Default seeded credentials:
| Role | Password | |
|---|---|---|
| User | test@example.com |
password123 |
The .env file in the project root is used for the backend API:
PORT=3000
DB_USER=postgres
DB_PASSWORD=engine_password
DB_HOST=localhost
DB_PORT=5433
DB_NAME=postgres
JWT_SECRET=your-secret-key-here
REDIS_HOST=localhost
REDIS_PORT=6379
EXECUTION_STRATEGY=docker # 'docker' or 'k8s'
DOCKER_TEMP_VOLUME=execution_engine_tempNote: When running via Docker Compose,
DB_HOSTmust bedbandREDIS_HOSTmust beredis(the Docker service names). The.envvalues withlocalhostare for running the API natively outside Docker.
node seed.jsThis will:
- Create all tables (if they don't exist) from
src/schema.sql - Insert 10 sample problems (Easy / Medium / Hard)
- Create a default test user
To reset and re-seed:
# Stop the DB container, remove its volume, then restart
docker compose down -v
docker compose up -d db
node seed.jsTo develop without Docker (API and frontend only, DB + Redis still via Docker):
# Terminal 1 β Start DB & Redis only
docker compose up -d db redis
# Terminal 2 β Start the backend API
npm install
npm run dev
# Terminal 3 β Start the frontend
cd frontend
npm install
npm run devFrontend: http://localhost:5173
API: http://localhost:3000
Requires Kubernetes enabled in Docker Desktop.
.\build_k8s_images.ps1.\deploy-k8s.ps1Or use the slash command from the IDE:
/deploy-k8s
kubectl get pods -n code-judge
kubectl get pods -n sandboxK8s port mappings:
| Service | Port |
|---|---|
| API (LoadBalancer) | localhost:3001 |
| Frontend (LoadBalancer) | localhost:80 |
| Method | Endpoint | Description |
|---|---|---|
POST |
/register |
Register a new user |
POST |
/login |
Login, returns JWT |
GET |
/me |
Get current user (auth required) |
| Method | Endpoint | Description | Query Params |
|---|---|---|---|
GET |
/problems |
List problems (paginated) | page, difficulty, tag, search |
GET |
/problems/:id |
Get problem details + test cases | β |
POST |
/problems |
Create a problem | β |
PUT |
/problems/:id |
Update a problem | β |
DELETE |
/problems/:id |
Delete a problem | β |
Create/Update problem body:
{
"title": "Sum of Two Numbers",
"description_bn": "...",
"input_format_bn": "...",
"output_format_bn": "...",
"sample_input": "1 2",
"sample_output": "3",
"difficulty": "Easy",
"points": 5,
"tags": ["Math", "Basic"],
"test_cases": [
{ "input": "1 2", "expected_output": "3", "is_sample": true }
]
}| Method | Endpoint | Description |
|---|---|---|
POST |
/submit |
Submit code for a problem |
GET |
/submissions |
List user's submissions |
DELETE |
/submissions |
Clear submission history |
GET |
/jobs/:id |
Poll job status (playground) |
| Method | Endpoint | Description |
|---|---|---|
GET |
/leaderboard |
Paginated leaderboard |
| Language | Runner Image |
|---|---|
| Python 3 | python-runner |
| C++ 17 | cpp-runner |
| Java 17 | java-runner |
| Kotlin | kotlin-runner |
| Go 1.21 | go-runner |
| PHP 8.2 | php-runner |
| Dart | dart-runner |
| C | c-runner |
| SQL | sql-runner |
After making code changes:
# Rebuild and restart only API and frontend (preserves DB data)
docker compose up -d --build api frontendTo rebuild a specific language runner:
docker compose build python-runner| Issue | Fix |
|---|---|
Cannot connect to Docker socket |
Make sure Docker Desktop is running |
Port 5433 already in use |
Change DB_PORT in .env or stop the conflicting service |
JWT_SECRET not set |
Set JWT_SECRET in .env |
Submission stuck in Queued |
Check Redis is running: docker compose ps redis |
No runner image found |
Build runner images: docker compose build python-runner |