A fully-featured, scalable LeetCode-style online judge built using a modern microservices architecture. Includes real-time code execution, WebSockets, problem solving interface with Monaco Editor, authenticated user system, distributed queues, and Docker-based isolated execution.
This project uses a microservices architecture with 7 independent services communicating through an API Gateway.
| Service Name | Port | Description |
|---|---|---|
| API Gateway | 5000 | Entry point, routing, WebSocket support |
| Users Service | 5001 | User profiles and account management |
| Auth Service | 5002 | Authentication, JWT tokens, sessions |
| Problems Service | 5003 | Problem CRUD, metadata, difficulty |
| Tags Service | 5004 | Problem categorization and filtering |
| Companies Service | 5005 | Company tags and frequency tracking |
| Submissions Service | 5006 | Code submission tracking and history |
| Execution Service | 5007 | Async code execution via BullMQ workers |
- Real-time code execution with live feedback
- Monaco Editor with syntax highlighting
- Docker-based sandboxed execution environment
- Distributed job processing with BullMQ
- Full monitoring stack (Prometheus + Grafana + Loki)
- CI/CD pipeline with GitHub Actions
- JWT authentication with refresh tokens
- Email verification and password reset
- Beautiful UI with shadcn/ui
- Problem-solving interface with Monaco Editor
- Live submission updates using Socket.IO
- Global state management with Zustand
- Fully typed with TypeScript
- Form handling with React Hook Form
- API interactions using Axios
- Tailwind CSS styling
- Day.js for handling timestamps and dates
- NestJS for all microservices
- Redis + BullMQ for distributed queues
- PostgreSQL (shared DB, Prisma ORM)
- Socket.IO (real-time communication)
- Docker containers for isolated code execution
- JWT authentication
- Event-driven architecture
- Docker & Docker Compose - Containerized microservices orchestration
- GitHub Actions - Automated CI/CD pipeline
- Prometheus - Metrics collection and monitoring
- Grafana - Visualization dashboards for system metrics
- Loki - Centralized log aggregation
- BullMQ + Redis - Distributed job queues for async processing
- Nginx - Reverse proxy and load balancing
- User clicks "Submit" β Frontend sends code via WebSocket to API Gateway
- API Gateway β TCP request to Submission Service
- Submission Service β Publishes job to execution-queue (BullMQ)
- Execution Service β Consumes job from queue
- Execution Service β Runs code in sandboxed Docker container
- Workers β Return execution result
- Execution Service β Publishes result to results-queue
- Submission Service β Consumes result from queue
- Submission Service β Updates database with status/results
- Submission Service β Publishes notification to notifications-queue
- API Gateway β Consumes notification event
- API Gateway β Pushes real-time update through WebSocket to user's browser
- Each service deploys independently
- Execution workload isolated from main API
- Faster horizontal scaling
- Services communicate through queues β highly resilient
- Matches real LeetCode-scale architecture
Clone the repo
$ git clone https://github.com/naman22a/leetcode-microservices
$ cd leetcode-microservicescopy env files
$ cp .env.example .env
$ cp ./apps/client/.env.example ./apps/client/.envrun the backend (microservices)
$ docker compose uprun the frontend
$ cd ./apps/client
$ pnpm install
$ pnpm devAfter running docker compose up, access:
- Grafana: http://localhost:3001 (default: admin/admin)
- Prometheus: http://localhost:9090
$ pnpm testThis project includes a complete OAS 3.0 compliant REST API.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users |
Get all users |
| PATCH | /api/users |
Update own user details |
| GET | /api/users/me |
Get authenticated user |
| GET | /api/users/{id} |
Get user by ID |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
User registration |
| POST | /api/auth/confirm-email/{token} |
Email verification |
| POST | /api/auth/login |
Login using credentials |
| POST | /api/auth/logout |
Logout and invalidate session |
| POST | /api/auth/refresh_token |
Refresh JWT access token |
| POST | /api/auth/forgot-password |
Generate password reset link |
| POST | /api/auth/reset-password/{token} |
Reset password |
| Method | Endpoint |
|---|---|
| GET | /api/problems |
| POST | /api/problems |
| GET | /api/problems/{slug} |
| DELETE | /api/problems/{id} |
| PATCH | /api/problems/{id} |
| Method | Endpoint |
|---|---|
| GET | /api/tags |
| GET | /api/tags/{id} |
| POST | /api/tags/bulk |
| Method | Endpoint |
|---|---|
| GET | /api/companies |
| GET | /api/companies/{id} |
| POST | /api/companies/bulk |
| Method | Endpoint |
|---|---|
| GET | /api/submissions/{id} |
.
βββ apps
β βββ api-gateway
β βββ auth-service
β βββ client
β βββ companies-service
β βββ execution-service
β βββ problems-service
β βββ submissions-service
β βββ tags-service
β βββ users-service
βββ assets
β βββ architecture.png
β βββ problems.png
β βββ two-sum.png
βββ docker-compose.dev.yml
βββ docker-compose.yml
βββ Dockerfile.base
βββ Dockerfile.web
βββ .dockerignore
βββ .env
βββ .env.example
βββ .env.test
βββ .gitignore
βββ LICENSE
βββ nginx.conf
βββ .npmrc
βββ package.json
βββ packages
β βββ config
β βββ constants
β βββ database
β βββ eslint-config
β βββ types
β βββ typescript-config
βββ pnpm-lock.yaml
βββ pnpm-workspace.yaml
βββ .prettierignore
βββ .prettierrc
βββ README.md
βββ tsconfig.json
βββ turbo.json
Contributions, issues, and suggestions are welcome! Feel free to fork the repository and submit pull requests.
- Author - Naman Arora
- Twitter - @naman_22a
Leetcode is GPL V3



