A distributed microservices platform for online coding challenges and automated code evaluation
- Overview
- System Architecture
- Microservices
- Tech Stack
- Prerequisites
- Quick Start
- Data Flow
- API Gateway
- Deployment
- Contributing
- License
AlgoForge is a scalable microservices-based platform for competitive programming and code evaluation. It provides a complete solution for creating coding challenges, submitting solutions, executing code in isolated environments, and delivering real-time results to users.
Key Features:
- 🏗️ Microservices Architecture - Independent, scalable services
- 🔒 Secure Code Execution - Isolated Docker containers with resource limits
- ⚡ Real-time Notifications - WebSocket-based instant feedback
- 📊 Queue-based Processing - Reliable async job handling with BullMQ
- 🌐 Multi-language Support - Python, Java, C++, JavaScript
- 🗃️ Distributed Data - MongoDB for persistence, Redis for caching/queuing
The platform consists of four core microservices communicating via REST APIs and message queues:
- Client submits code to Submission Service
- Submission Service fetches problem details from Problem Service
- Code with test cases is queued to Submission Queue
- Evaluator Service consumes job, executes code in Docker container
- Results are published to Evaluation Queue
- Submission Service updates database and notifies Socket Service
- Socket Service sends real-time update to connected client
Repository: Algoforge-problem-service
Manages coding challenges, test cases, and code stubs.
- Tech: Node.js + Express.js + MongoDB
- Port: 3000
- Responsibilities:
- CRUD operations for coding problems
- Test case storage and retrieval
- Language-specific code template management
- Markdown sanitization for XSS prevention
Quick Start:
cd Problem-Service
npm install
cp .env.example .env
npm run devRepository: Algoforge-submission-service
Orchestrates the entire code evaluation workflow.
- Tech: Node.js + Fastify + MongoDB + BullMQ
- Port: 3003
- Responsibilities:
- Accept user code submissions
- Fetch problem metadata and inject code stubs
- Queue jobs for evaluation
- Process results and update submission status
- Trigger real-time notifications
Quick Start:
cd Submission-Service
npm install
cp .env.example .env
npm run devRepository: Algoforge-evaluator-service
Executes user code in isolated Docker containers.
- Tech: Node.js + TypeScript + Docker + BullMQ
- Port: 3001
- Responsibilities:
- Consume jobs from submission queue
- Execute code in isolated Docker containers (256MB, 2s timeout)
- Validate output against expected results
- Publish results to evaluation queue
Quick Start:
cd Evaluator-Service
npm install
cp .env.example .env
npm run devRepository: Algoforge-socket-service
Provides real-time bidirectional communication.
- Tech: Node.js + Socket.IO + Redis
- Port: 3002
- Responsibilities:
- Maintain WebSocket connections
- Store userId to socketId mappings in Redis
- Deliver instant submission results to connected clients
Quick Start:
cd Socket-Service
npm install
cp .env.example .env
npm run dev- Node.js 18+ - Runtime environment
- Express.js / Fastify - HTTP frameworks
- TypeScript - Type-safe development (Evaluator)
- MongoDB 6.0+ - Primary data store
- Redis 6.0+ - Caching and message queuing
- BullMQ - Job queue management
- Socket.IO - Real-time communication
- Docker - Code execution isolation
- Dockerode - Docker API client
- Winston - Structured logging
- Bull Board - Queue monitoring UI
Before running AlgoForge, ensure you have:
- Node.js >= 18.0.0
- Docker Desktop - Running and accessible
- MongoDB >= 6.0 (local or Atlas)
- Redis Server >= 6.0
Quick Verification:
node --version
docker --version
mongosh --eval "db.adminCommand('ping')"
redis-cli ping# Create project directory
mkdir algoforge && cd algoforge
# Clone all services
git clone https://github.com/yourusername/algoforge-problem-service Problem-Service
git clone https://github.com/yourusername/algoforge-submission-service Submission-Service
git clone https://github.com/yourusername/algoforge-evaluator-service Evaluator-Service
git clone https://github.com/yourusername/algoforge-socket-service Socket-Service# Start MongoDB
mongod --dbpath /path/to/data
# Start Redis
redis-serverCreate .env files in each service directory based on the examples provided in individual READMEs.
# Install dependencies for all services
cd Problem-Service && npm install && cd ..
cd Submission-Service && npm install && cd ..
cd Evaluator-Service && npm install && cd ..
cd Socket-Service && npm install && cd ..# Terminal 1 - Problem Service
cd Problem-Service
npm run dev
# Terminal 2 - Socket Service
cd Socket-Service
npm run dev
# Terminal 3 - Evaluator Service
cd Evaluator-Service
npm run dev
# Terminal 4 - Submission Service
cd Submission-Service
npm run devcurl http://localhost:3000/ping # Problem Service
curl http://localhost:3002/ping # Socket Service
curl http://localhost:3001/ui # Evaluator Bull Board
curl http://localhost:3003/api/v1/ping # Submission Service1. Client sends POST /api/v1/submissions to Submission Service
2. Submission Service requests problem details from Problem Service
3. Code stubs are injected into user code
4. Submission saved to MongoDB with status "Pending"
5. Job added to SubmissionQueue (Redis)
6. Client receives submission ID
7. Evaluator Service consumes job from SubmissionQueue
8. Docker container created with user code and test cases
9. Code executed with 2s timeout and 256MB memory limit
10. Output compared against expected results
11. Result published to EvaluationQueue
12. Container removed
13. Submission Service consumes result from EvaluationQueue
14. Database updated with final status (Accepted/Wrong Answer/Error)
15. Notification sent to Socket Service
16. Socket Service emits result to connected client via WebSocket
17. Client displays result in real-time
Currently, services are accessed directly. For production deployment, consider adding an API Gateway (e.g., Kong, Nginx, AWS API Gateway) for:
- Unified entry point
- Authentication and authorization
- Rate limiting
- Request routing
- Load balancing
Recommended Structure:
Client → API Gateway → [Problem Service | Submission Service]
→ WebSocket Gateway → Socket Service
Create docker-compose.yml at root:
version: "3.8"
services:
mongodb:
image: mongo:6.0
ports:
- "27017:27017"
volumes:
- mongo-data:/data/db
redis:
image: redis:7-alpine
ports:
- "6379:6379"
problem-service:
build: ./Problem-Service
ports:
- "3000:3000"
depends_on:
- mongodb
socket-service:
build: ./Socket-Service
ports:
- "3002:3002"
depends_on:
- redis
evaluator-service:
build: ./Evaluator-Service
ports:
- "3001:3001"
depends_on:
- redis
volumes:
- /var/run/docker.sock:/var/run/docker.sock
submission-service:
build: ./Submission-Service
ports:
- "3003:3003"
depends_on:
- mongodb
- redis
volumes:
mongo-data:Start all services:
docker-compose up -dFor production, consider:
- Kubernetes - Container orchestration
- AWS ECS/EKS - Managed container services
- Horizontal Scaling - Multiple instances per service
- Load Balancers - Distribute traffic
- Monitoring - Prometheus + Grafana
- Logging - ELK Stack (Elasticsearch, Logstash, Kibana)
Access Bull Board UIs:
- Evaluator Service: http://localhost:3001/ui
- Submission Service: http://localhost:3003/ui (if configured)
# Check service health
curl http://localhost:3000/ping
curl http://localhost:3002/ping
curl http://localhost:3003/api/v1/pingEach service uses Winston for structured logging. Check logs in:
Problem-Service/logs/Submission-Service/logs/Evaluator-Service/logs/Socket-Service/logs/
We welcome contributions to any of the AlgoForge microservices!
- Fork the repository you want to contribute to
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Follow the coding standards of each service
- Write tests for new features
- Commit your changes (
git commit -m 'Add AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Use ESLint configurations provided in each service
- Follow RESTful API design principles
- Write clear commit messages
- Document new endpoints in README
- Add JSDoc comments for complex functions
This project is licensed under the ISC License.
-
Inspired by platforms like LeetCode, HackerRank, and Codeforces
-
Special thanks to the open-source community
Made with ❤️ by Krrish Kumar
Main Repository •
Report Bug •
Discussions
⭐ Star this project if you find it helpful!
