This is the backend service for CodeRush, a multi-language coding platform where users can solve randomized, topic-specific problems and track their coding progress. The backend is responsible for user authentication, question management, Docker-based code execution, and MongoDB data storage.
-
🧑💻 User Authentication (JWT)
- Sign up, log in, and manage secure sessions using JSON Web Tokens.
-
📚 Topic-Based Question Generation
- Serve random coding questions based on selected topics and programming languages.
-
🐳 Secure Code Execution
- Run submitted code inside Docker containers for C++, Python, JavaScript, and Java.
- Each container is isolated for safety and consistency.
-
📊 Progress & Submission Tracking
- Store solved problems, user history, and growth insights for later retrieval.
-
🧩 REST API for Frontend Integration
- Clean and modular API routes that power the frontend application.
Layer | Tech Used |
---|---|
Server | Node.js, Express.js |
Auth | JWT (JSON Web Tokens) |
DB | MongoDB + Mongoose |
Execution | Docker (per-language images) |
Utilities | Dockerode, fs, child_process |
/coderush-backend
├── controllers/
├── routes/
├── services/ # Code execution logic
├── models/ # User & Question schemas
├── utils/ # Docker helpers, validators
├── .env
├── server.js
└── package.json
- Node.js v18+
- Docker (installed and running)
- MongoDB (local or Atlas)
# Clone the repo
git clone https://github.com/HYDRO2070/Code-Complier.git
cd Code-Complier
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Start the server
npm run dev
Ensure Docker is running locally and that .env
is properly configured.
Create a .env
file with the following:
PORT=5000
MONGO_URI=your_mongodb_uri
JWT_SECRET=your_jwt_secret
DOCKER_SOCKET=/var/run/docker.sock
Base URL:
http://localhost:5000/api
Method | Endpoint | Description |
---|---|---|
POST | /auth/signup |
Create a new user |
POST | /auth/login |
Authenticate user and return token |
GET | /user/profile |
Get logged-in user's profile |
POST | /questions/random |
Fetch a random question by topic |
POST | /code/execute |
Run submitted code via Docker |
GET | /user/history |
Get solved problems by user |
- Each submission is sent to a language-specific Docker container.
- Output, errors, or runtime exceptions are captured and returned to the client.
- Prevents direct code execution on the host machine for maximum security.
Supported languages:
- ✅ C++
- ✅ Python
- ✅ JavaScript
- ✅ Java
# Lint with ESLint
npm run lint
# Format with Prettier
npm run format
- ✅ Execution timeout safeguards
- 🔜 Container reuse with lifecycle management
- 🔜 Rate limiting & abuse protection
- 🔜 Caching frequently used questions
- 🔜 Unit & integration testing with Jest
We welcome contributions! Please open an issue or submit a pull request for improvements, bug fixes, or features.