A full-stack online judge platform for coding problems, built with Next.js 14, Express.js, PostgreSQL (NeonDB), and Docker microservices.
Features secure code execution with microservice architecture and cloud deployment on AWS.
π Live Demo: judgeandsolve.me
π API: api.judgeandsolve.me
- User Authentication: Login, Signup, Profile management with OAuth (Google, GitHub)
- Problem Management: Browse, solve, and manage coding problems with difficulty levels
- Code Execution: Support for Python 3, C++, and JavaScript with isolated execution
- Judge System: Microservice architecture with dedicated judge service for scalability
- Real-time Results: Live submission tracking and test case results
- AI Code Review: Powered by Google Gemini API for code analysis and feedback
- Leaderboard: User rankings based on weighted scoring system
- Statistics: User performance analytics and submission history
- Admin Dashboard: Problem and user management capabilities
- Responsive Design: Mobile-friendly interface with Tailwind CSS
judgeandsolve/
βββ client/ # Next.js 14 frontend (TypeScript)
β βββ src/
β β βββ app/ # Next.js app router
β β βββ _components/ # Reusable UI components
β β βββ _services/ # API service layer
β β βββ _store/ # Zustand state management
β βββ .env
β βββ .env.development
β βββ next.config.js
β βββ tailwind.config.js
β βββ package.json
βββ server/ # Express.js backend (TypeScript)
β βββ src/
β β βββ controllers/ # Route handlers
β β βββ models/ # Sequelize models
β β βββ routes/ # API routes
β β βββ middleware/ # Authentication & error handling
β β βββ config/ # Database and app configuration
β β βββ judge/ # Judge system integration
β βββ __tests__/ # Test files
β βββ .env
β βββ .env.prod
β βββ Dockerfile
β βββ package.json
βββ judge-service/ # Microservice for code execution
β βββ src/
β β βββ index.ts # Express server
β β βββ judgeRunner.ts # Code execution engine
β β βββ types.ts # TypeScript interfaces
β βββ Dockerfile
β βββ package.json
βββ docker-compose.yml # Production deployment configuration
- Next.js 14 with App Router
- TypeScript for type safety
- Tailwind CSS for styling
- Shadcn/ui component library
- Zustand for state management
- Monaco Editor for code editing
- Deployed on Vercel
- Express.js with TypeScript
- Sequelize ORM with PostgreSQL
- NeonDB for cloud PostgreSQL database
- BullMQ for job queue management
- Redis (local instance) for caching and queues
- JWT for authentication
- Passport.js for OAuth (Google, GitHub)
- Google Gemini API for AI code reviews
- Docker for containerization
- AWS ECR for container registry
- AWS EC2 for backend deployment
- Nginx for reverse proxy with SSL
- Let's Encrypt for SSL certificates
- Judge Service microservice for code execution
- Python 3 with
python3
- C++ with
g++
compiler - JavaScript with
node
runtime
Frontend (Vercel) Backend (EC2) Judge Service (EC2)
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Next.js 14 β β Express.js β β Express.js β
β judgeandsolve. ββββ api.judgeand ββββ Port 4001 β
β me β β solve.me β β Code Execution β
β β β Port 4000 β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββββββββββ
β NeonDB β
β PostgreSQL β
βββββββββββββββββββ
β
βββββββββββββββββββ
β Redis β
β Local Instance β
βββββββββββββββββββ
- User submits code through frontend
- Backend validates and queues submission using BullMQ
- Judge service executes code in isolated environment
- Results sent back through microservice API
- Frontend displays real-time results
- Node.js (v18+)
- Docker & Docker Compose
- AWS account with ECR access
- NeonDB PostgreSQL database
- Redis instance
-
Clone the repository:
git clone https://github.com/agrpranjal07/judgeandsolve.git cd judgeandsolve
-
Setup Environment Variables:
client/.env
:NEXT_PUBLIC_API_BASE_URL=http://localhost:4000/api/v1 NEXT_PUBLIC_GITHUB_OAUTH_URL=http://localhost:4000/api/v1/auth/github NEXT_PUBLIC_GOOGLE_OAUTH_URL=http://localhost:4000/api/v1/auth/google
server/.env
:PORT=4000 DATABASE_URL=your-neondb-postgresql-url REDIS_URL=redis://localhost:6379 JWT_SECRET=your-jwt-secret REFRESH_SECRET=your-refresh-secret CLIENT_URL=http://localhost:3000 JUDGE_SERVICE_URL=http://localhost:4001 GEMINI_API_KEY=your-gemini-api-key # OAuth Configuration OAUTH_GITHUB_CLIENT_ID=your-github-client-id OAUTH_GITHUB_CLIENT_SECRET=your-github-client-secret OAUTH_GOOGLE_CLIENT_ID=your-google-client-id OAUTH_GOOGLE_CLIENT_SECRET=your-google-client-secret
judge-service/.env
:PORT=4001
-
Install Dependencies:
# Frontend cd client && npm install # Backend cd ../server && npm install # Judge Service cd ../judge-service && npm install
-
Start Development Servers:
# Start Redis locally redis-server # Frontend (Terminal 1) cd client && npm run dev # Backend (Terminal 2) cd server && npm run dev # Judge Service (Terminal 3) cd judge-service && npm run dev
-
Access the Application:
- Frontend: http://localhost:3000
- Backend API: http://localhost:4000
- Judge Service: http://localhost:4001
- Frontend: Deployed on Vercel at judgeandsolve.me
- Backend: AWS EC2 with Docker containers
- Database: NeonDB PostgreSQL (cloud)
- Redis: Local instance on EC2
- Container Registry: AWS ECR
- SSL: Let's Encrypt with Nginx
- Domain: api.judgeandsolve.me
-
Build and Push Images to ECR:
# Build judge service cd judge-service docker build -t judgeandsolve-judge . docker tag judgeandsolve-judge:latest 471112932256.dkr.ecr.ap-south-1.amazonaws.com/judgeandsolve-judge:latest docker push 471112932256.dkr.ecr.ap-south-1.amazonaws.com/judgeandsolve-judge:latest # Build and push server cd ../server docker build -t judgeandsolve-server . docker tag judgeandsolve-server:latest 471112932256.dkr.ecr.ap-south-1.amazonaws.com/judgeandsolve-server:latest docker push 471112932256.dkr.ecr.ap-south-1.amazonaws.com/judgeandsolve-server:latest
-
Deploy on EC2:
# Login to ECR aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 471112932256.dkr.ecr.ap-south-1.amazonaws.com # Start services using docker-compose docker compose up -d
-
Setup Nginx with SSL:
# Install Nginx (Amazon Linux) sudo yum install nginx -y # Configure SSL with Let's Encrypt sudo yum install python3-pip -y sudo pip3 install certbot certbot-nginx sudo certbot --nginx -d api.judgeandsolve.me
version: '3.8'
services:
redis:
image: redis:7
container_name: redis_server
ports:
- "127.0.0.1:6379:6379"
networks:
- judge-network
restart: unless-stopped
judge-service:
image: 471112932256.dkr.ecr.ap-south-1.amazonaws.com/judgeandsolve-judge:latest
container_name: judge_service
ports:
- "127.0.0.1:4001:4001"
environment:
- PORT=4001
networks:
- judge-network
restart: unless-stopped
backend:
image: 471112932256.dkr.ecr.ap-south-1.amazonaws.com/judgeandsolve-server:latest
container_name: judge_server
ports:
- "127.0.0.1:4000:4000"
depends_on:
- redis
- judge-service
env_file:
- ./server/.env
environment:
- JUDGE_SERVICE_URL=http://judge-service:4001
- CLIENT_URL=https://judgeandsolve.me
networks:
- judge-network
restart: unless-stopped
networks:
judge-network:
driver: bridge
POST /api/v1/auth/login
- User loginPOST /api/v1/auth/signup
- User registrationGET /api/v1/auth/github
- GitHub OAuthGET /api/v1/auth/google
- Google OAuthGET /api/v1/auth/me
- Get current user
GET /api/v1/problems
- List problems with paginationGET /api/v1/problems/:id
- Get problem detailsPOST /api/v1/problems
- Create problem (admin only)GET /api/v1/problems/:id/testcases/public
- Get sample test cases
POST /api/v1/submissions
- Submit code for judgingGET /api/v1/submissions/:id
- Get submission detailsPOST /api/v1/submissions/testcases
- Test sample casesGET /api/v1/recentSubmissions
- Get recent submissions
GET /api/v1/stats/leaderboard
- Get leaderboardGET /api/v1/stats/user/:username
- User statistics
POST /api/v1/ai/review
- Get AI code review
# Run backend tests
cd server && npm test
# Run frontend tests
cd client && npm test
- JWT-based authentication with refresh tokens
- Docker containerization for code execution isolation
- Input validation and sanitization
- Rate limiting on API endpoints
- HTTPS enforcement in production
- OAuth integration for secure login
- Environment variable management
- Redis caching for improved response times
- Database query optimization with Sequelize
- Async job processing with BullMQ
- Microservice architecture for scalability
- Container reuse for faster code execution
- CDN integration through Vercel
Variable | Description | Required |
---|---|---|
DATABASE_URL |
NeonDB PostgreSQL connection string | β |
REDIS_URL |
Redis connection string | β |
JWT_SECRET |
JWT signing secret | β |
GEMINI_API_KEY |
Google Gemini API key | β |
CLIENT_URL |
Frontend URL for CORS | β |
JUDGE_SERVICE_URL |
Judge service internal URL | β |
OAUTH_GITHUB_CLIENT_ID |
GitHub OAuth client ID | β |
OAUTH_GOOGLE_CLIENT_ID |
Google OAuth client ID | β |
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js for the frontend framework
- Express.js for the backend framework
- NeonDB for cloud PostgreSQL
- Shadcn/ui for UI components
- Monaco Editor for code editing
- Docker for containerization
- AWS for cloud infrastructure
- Vercel for frontend deployment
For questions or support:
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- Frontend: https://judgeandsolve.me
- API: https://api.judgeandsolve.me
Happy Coding! π