A robust backend API for the Byte Code coding practice platform. This service powers user authentication, problem management, code execution, submissions, playlists, and more, supporting a seamless coding experience for the frontend application.
- User Authentication: Secure registration, login, JWT-based sessions, and email verification.
- Problem Management: CRUD operations for coding problems, including test cases, constraints, and solutions.
- Code Execution: Integrates with Judge0 API for real-time code compilation and execution in multiple languages.
- Submissions & Evaluation: Handles user submissions, test case evaluation, and result tracking.
- Playlists: Create and manage custom playlists of coding problems.
- Progress Tracking: Track solved problems and user statistics.
- Admin Tools: Admin endpoints for problem creation and management.
- Runtime: Node.js
- Framework: Express.js
- ORM: Prisma (PostgreSQL)
- Authentication: JWT, bcryptjs
- Email: Nodemailer, Mailgen
- Code Execution: Judge0 API
- Validation: Zod
- Utilities: dotenv, morgan, express-rate-limit, cors
- Node.js (v18 or higher recommended)
- PostgreSQL database
cd backend
npm installCreate a .env file in the backend directory with the following variables:
PORT=3000
DATABASE_URL=postgresql://<user>:<password>@<host>:<port>/<db>
FRONTEND_URLS=http://localhost:5173
JWT_SECRET=your_jwt_secret
JWT_REFRESH_SECRET=your_jwt_refresh_secret
MAILTRAP_HOST=smtp.mailtrap.io
MAILTRAP_PORT=2525
MAILTRAP_USERNAME=your_mailtrap_username
MAILTRAP_PASSWORD=your_mailtrap_password
JUDGE0_URL=https://judge0-ce.p.rapidapi.com
JUDGE0_API_KEY=your_judge0_api_key
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX=100
- Run Migrations:
npx prisma migrate dev
- Generate Prisma Client:
npx prisma generate
- Seed the Database (optional):
npm run seed
npm startThe server will start on the port specified in your .env file (default: 3000).
POST /api/v1/auth/*β Authentication (register, login, verify, etc.)GET /api/v1/problemsβ List all problemsPOST /api/v1/problemsβ Create a new problem (admin)GET /api/v1/problems/:idβ Get problem detailsPOST /api/v1/code/executeβ Execute code via Judge0POST /api/v1/submissionsβ Submit a solutionGET /api/v1/playlistsβ Manage playlistsGET /api/v1/health-checkβ Health check endpoint
For detailed request/response formats, see the route and controller files in
src/routes/andsrc/controllers/.
src/controllers/β Business logic for each API modulesrc/routes/β Express route definitionssrc/middlewares/β Authentication, validation, and error handlingsrc/utils/β Utility functions (API responses, password hashing, etc.)src/config/β Configuration for DB, email, Judge0, etc.prisma/β Prisma schema, migrations, and seed scriptsdata/β Static or seed data
Contributions are welcome! Please open issues or pull requests for improvements or bug fixes.
This project is licensed under the MIT License.