A full-stack web application for solving coding problems with JavaScript and Python support, featuring an online code editor with real-time code execution and accuracy scoring.
- User Authentication: JWT-based register/login system
- Problem Management: Browse problems by difficulty (Easy/Medium/Hard)
- Monaco Code Editor: Professional code editing experience
- Multi-Language Support: JavaScript and Python
- Code Execution: Safe code execution with timeout handling
- Accuracy Tracking: Percentage-based scoring system
- Submission History: Track all your submissions with detailed results
- React.js with TypeScript
- Tailwind CSS for styling
- Monaco Editor for code editing
- React Router for navigation
- Axios for API calls
- Node.js with Express
- TypeScript
- MongoDB with Mongoose
- JWT authentication
- bcrypt.js for password hashing
- Node.js child_process for safe code execution
- Timeout handling (5 seconds)
- Test case validation
- Node.js (v18+)
- MongoDB (v5+)
- Python 3 (for Python code execution)
cd backend
npm install
cp .env.example .env
# Edit .env with your MongoDB URI and JWT secret
npm run devcd frontend
npm install
cp .env.example .env
# Edit .env with your API URL
npm run devcd backend
node seed.jsPORT=5000
MONGO_URI=mongodb://localhost:27017/codepractice
JWT_SECRET=your-secret-key
NODE_ENV=development
VITE_API_URL=http://localhost:5000/api
POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/auth/profile- Get user profile (protected)
GET /api/problems- Get all problemsGET /api/problems/:id- Get problem by IDPOST /api/problems- Create problem (protected)PUT /api/problems/:id- Update problem (protected)DELETE /api/problems/:id- Delete problem (protected)
POST /api/submissions/submit- Submit code (protected)POST /api/submissions/run- Run code (protected)GET /api/submissions- Get user submissions (protected)GET /api/submissions/:id- Get submission by ID (protected)
- Register/Login: Create an account or log in
- Browse Problems: View problems filtered by difficulty
- Solve Problem:
- Read problem description
- Write code in Monaco editor
- Switch between JavaScript/Python
- Run code to test with first test case
- Submit to test against all test cases
- View Results: See accuracy percentage and detailed results
- Track Progress: View submission history
Accuracy (%) = (Passed Test Cases / Total Test Cases) Γ 100
Status Types:
- Accepted: 100% accuracy
- Partial: 1-99% accuracy (shown as "Wrong Answer")
- Runtime Error: Code execution error
- Timeout: Execution exceeded 5 seconds
{
name: string
email: string (unique)
password: string (hashed)
solvedProblems: ObjectId[]
createdAt: Date
}{
title: string (unique)
description: string
difficulty: 'Easy' | 'Medium' | 'Hard'
tags: string[]
testCases: [{
input: string
expectedOutput: string
}]
starterCode: {
javascript: string
python: string
}
createdAt: Date
}{
userId: ObjectId
problemId: ObjectId
code: string
language: 'javascript' | 'python'
status: string
accuracy: number
passedCases: number
totalCases: number
error?: string
createdAt: Date
}- Password hashing with bcrypt
- JWT token authentication
- Protected routes
- Input validation
- Code execution timeout
- MongoDB injection protection
- Set production environment variables
- Build:
npm run build - Start:
npm start
- Set production API URL
- Build:
npm run build - Serve the
distfolder
- Timeout: 5-second execution limit
- Isolated Execution: Each submission runs in separate process
- Temp Files: Automatic cleanup after execution
- Error Handling: Graceful error messages
Problems can be added through the API or by modifying the seed script:
{
title: "Problem Title",
description: "Problem description...",
difficulty: "Easy", // or "Medium" or "Hard"
tags: ["Array", "String"],
testCases: [
{
input: "test input",
expectedOutput: "expected output"
}
],
starterCode: {
javascript: "// JS starter code",
python: "# Python starter code"
}
}- No Docker containerization (uses child_process)
- Admin features not role-protected
- Limited to JavaScript and Python
- Single server execution (not distributed)
- No rate limiting on submissions
This is a portfolio project. Feel free to fork and customize!
MIT License - Free to use for learning and personal projects
This project demonstrates:
- Full-stack TypeScript development
- RESTful API design
- JWT authentication
- MongoDB schema design
- Safe code execution
- React state management
- Professional UI/UX with Tailwind
- Real-time code editing with Monaco
Built with β€οΈ as a mid-level developer portfolio project