A full-fledged backend system for an online coding judge platform — built with Node.js, Express, MongoDB, and Docker. It supports multi-language code execution (C++, Python, JS), problem management, user authentication, automated evaluation, and plagiarism detection.
- 🔐 JWT Authentication with user/admin roles
- 📄 Problem Management with test cases (admin only)
- 📤 Code Submission and result evaluation
- 🧪 Unit Tests for major APIs
- 📊 Leaderboard to showcase top performers
- 🐳 Dockerized Execution for code safety and isolation
- 🚫 Plagiarism Detection via token-based similarity
- 📈 Rate Limiting to prevent abuse
- Node.js + Express
- MongoDB + Mongoose
- JWT, bcryptjs
- Docker (with separate images per language)
- Jest + Supertest (unit testing)
- Esprima + string-similarity (for plagiarism)
- Swagger (API docs)
git clone https://github.com/yourusername/coding-judge-backend.git
cd coding-judge-backend/servernpm installPORT=5000
MONGO_URI=mongodb://127.0.0.1:27017/coding_judge
JWT_SECRET=supersecret123To add a demo admin, user, and a sample problem:
npm run seedThis will create:
- 👤 Admin:
admin@example.com/admin123 - 👤 User:
student@example.com/user123 - 📘 Problem: Count Vowels
Useful for quickly testing the full judge flow.
npm run devSupported Languages:
cpppythonjavascript
Dockerfiles are located at the root level:
.
├── Dockerfile-cpp
├── Dockerfile-python
├── Dockerfile-js
Each submission spins up a temporary container, runs user code in isolation, and returns the output.
npm testCovers:
- Auth (register/login)
- Problem CRUD
- Code submission and fetch APIs
- Tokenization via
esprima - Similarity via
string-similarity - Flags submissions with >80% token match
Ranks users based on:
- Number of problems solved
- Accuracy (accepted submissions / total)
GET /api/leaderboard- Limits excessive submission requests
- Implemented using middleware per IP/user
Available at:
http://localhost:5000/api-docs
/server
├── controllers/
├── routes/
├── models/
├── middleware/
├── utils/
├── tests/
├── temp/ ← code + input temp files
├── Dockerfile-* ← Docker sandboxes
├── .env
PRs welcome for:
- Frontend integration
- Improved judging logic
- Advanced plagiarism
MIT
Made with ❤️ by Shikhar Rai