LeetLab is a comprehensive full-stack coding platform designed for developers to practice coding problems, participate in contests, access premium problem sheets, and get real-time code execution feedback. Built with modern technologies and containerized for easy deployment.
- π§© Problem Solving: Extensive library of coding problems with multiple difficulty levels
- π» Real-time Code Execution: Integrated Judge0 API for instant code compilation and execution
- π Progress Tracking: Personal dashboard to track coding progress and statistics
- π Contests: Participate in timed coding competitions with leaderboards
- π Premium Sheets: Curated DSA practice sheets with Razorpay payment integration
- π Secure Authentication: JWT-based auth with refresh tokens and role-based access
- π³ Payment Integration: Razorpay integration for premium content access
- οΏ½ Responsive Design: Modern UI built with React, Tailwind CSS, and Lucide icons
- β‘ Real-time Updates: Live notifications and updates using Socket.IO
- οΏ½ Containerized: Full Docker support for development and production environments
- ποΈ Database Management: PostgreSQL with Prisma ORM for type-safe database operations
- π Redis Caching: Session management and performance optimization
- π¨ Modern Interface: Clean, intuitive design with dark theme support
- π Advanced Search: Filter problems by difficulty, tags, and completion status
- π Analytics Dashboard: Detailed progress tracking and performance insights
- π‘οΈ Admin Panel: Comprehensive admin interface for content management
- π§ Email Notifications: SMTP integration for user communications
- React 18 - Modern React with hooks and context
- Vite - Fast build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- Lucide React - Beautiful icon library
- Zustand - Lightweight state management
- Monaco Editor - VS Code-based code editor
- Node.js & Express - Server runtime and web framework
- Prisma ORM - Type-safe database client and migrations
- PostgreSQL - Primary relational database
- Redis - Session storage and caching layer
- Socket.IO - Real-time bidirectional communication
- Judge0 API - Code execution and compilation service
- Docker & Docker Compose - Containerization and orchestration
- Nginx - Reverse proxy and load balancing
- SSL/TLS - HTTPS support with certificate management
- Node.js (v18+ recommended)
- Docker & Docker Compose (for containerized setup)
- PostgreSQL (if running locally without Docker)
- Redis (if running locally without Docker)
# Clone the repository
git clone https://github.com/yourusername/leetlab.git
cd leetlab
# Copy environment template
cp .env.example .env
# Start development environment with hot reload
docker-compose -f docker-compose.dev.yml up -d
# View logs
docker-compose -f docker-compose.dev.yml logs -f# Set up environment variables
cp .env.example .env
# Edit .env with production values
# Start production environment
docker-compose up -d
# View logs
docker-compose logs -fgit clone https://github.com/yourusername/leetlab.git
cd leetlab
# Install backend dependencies
cd backend
npm install
# Install frontend dependencies
cd ../frontend
npm installCreate .env file in the backend directory:
# Database
DATABASE_URL="postgresql://myuser:mypassword@localhost:5432/leetlab"
REDIS_URL="redis://:redispassword@localhost:6379"
# Authentication
SECRET="your-super-secret-jwt-key-change-this-in-production"
REFRESH_SECRET="your-super-secret-refresh-key-change-this-in-production"
# External Services
JUDGE0_API_URL="https://judge0-ce.p.sulu.sh"
SULU_API_KEY="your-judge0-api-key"
# Payment Gateway
RAZORPAY_KEY_ID="your-razorpay-key-id"
RAZORPAY_KEY_SECRET="your-razorpay-key-secret"
# Email Configuration
SMTP_HOST="smtp.gmail.com"
SMTP_PORT="587"
SMTP_USER="[email protected]"
SMTP_PASS="your-app-password"
# Server Configuration
NODE_ENV="development"
PORT="8080"cd backend
# Generate Prisma client
npx prisma generate
# Run database migrations
npx prisma migrate dev --name init
# Seed database (optional)
npm run seed# Terminal 1: Start backend
cd backend
npm run dev
# Terminal 2: Start frontend
cd frontend
npm run dev
# Terminal 3: Start Redis (if not using Docker)
redis-server --requirepass redispassword- Frontend: http://localhost:3000
- Backend API: http://localhost:8080/api/v1
- Admin Panel: http://localhost:3000/admin (with admin credentials)
leetlab/
βββ π backend/ # Node.js Express API Server
β βββ π src/
β β βββ π controllers/ # Route handlers and business logic
β β βββ π routes/ # API route definitions
β β βββ π middleware/ # Custom middleware functions
β β βββ π libs/ # External service integrations
β β βββ π utils/ # Utility functions and helpers
β β βββ π generated/ # Prisma generated client
β β βββ π index.js # Main server entry point
β βββ π prisma/
β β βββ π migrations/ # Database migration files
β β βββ π schema.prisma # Database schema definition
β βββ π uploads/ # File upload storage
β βββ π Dockerfile # Production Docker config
β βββ π Dockerfile.dev # Development Docker config
β βββ π package.json # Backend dependencies
β
βββ π frontend/ # React Vite Application
β βββ π src/
β β βββ π components/ # Reusable React components
β β β βββ π ui/ # Base UI components
β β β βββ π layout/ # Layout components
β β β βββ π shared/ # Shared components
β β βββ π pages/ # Route-based page components
β β β βββ π auth/ # Authentication pages
β β β βββ π problems/ # Problem-related pages
β β β βββ π contests/ # Contest pages
β β β βββ π sheets/ # Sheet pages
β β β βββ π admin/ # Admin panel pages
β β βββ π contexts/ # React context providers
β β βββ π stores/ # Zustand state management
β β βββ π services/ # API service functions
β β βββ π utils/ # Utility functions
β β βββ π assets/ # Static assets
β β βββ π lib/ # Third-party library configs
β βββ π public/ # Public static files
β βββ π Dockerfile # Production Docker config
β βββ π Dockerfile.dev # Development Docker config
β βββ π vite.config.js # Vite configuration
β βββ π tailwind.config.js # Tailwind CSS config
β βββ π package.json # Frontend dependencies
β
βββ π nginx/ # Nginx Reverse Proxy
β βββ π nginx.conf # Nginx configuration
β βββ π ssl/ # SSL certificates
β βββ π logs/ # Nginx access/error logs
β
βββ π docs/ # Project Documentation
β βββ π API_DOCS.md # API documentation
β βββ π DEPLOYMENT.md # Deployment guide
β βββ π TESTING_GUIDE.md # Testing instructions
β
βββ π docker-compose.yml # Production compose config
βββ π docker-compose.dev.yml # Development compose config
βββ π init-db.sql # Database initialization
βββ π .env.example # Environment variables template
βββ π README.md # This file
# Development environment
docker-compose -f docker-compose.dev.yml up -d # Start dev environment
docker-compose -f docker-compose.dev.yml down # Stop dev environment
docker-compose -f docker-compose.dev.yml logs -f # View live logs
# Production environment
docker-compose up -d # Start production
docker-compose down # Stop production
docker-compose logs -f # View live logs
# Individual services
docker-compose up -d postgres redis # Start only database services
docker-compose restart backend # Restart backend servicecd frontend
npm run dev # Start Vite development server (http://localhost:3000)
npm run build # Build for production
npm run preview # Preview production build locally
npm run lint # Run ESLint code analysis
npm run lint:fix # Fix ESLint issues automaticallycd backend
npm run dev # Start development server with nodemon
npm run start # Start production server
npm run test # Run test suite
npm run test:watch # Run tests in watch mode
# Database operations
npx prisma migrate dev # Create and apply new migration
npx prisma migrate deploy # Apply migrations to production DB
npx prisma generate # Generate Prisma client
npx prisma studio # Open Prisma Studio (database GUI)
npx prisma db push # Push schema changes without migration
npx prisma db seed # Seed database with initial data# Setup scripts
chmod +x setup-dev.sh && ./setup-dev.sh # Automated development setup
chmod +x deploy-prod.sh && ./deploy-prod.sh # Production deployment
# Database management
psql -U myuser -d postgres -f init-db.sql # Manual database initialization
psql -U myuser -d postgres -f sample-problem.sql # Load sample problemsCreate a .env file in the root directory with the following variables:
# JWT Configuration
JWT_SECRET="your-super-secret-jwt-key-change-this-in-production"
REFRESH_SECRET="your-super-secret-refresh-key-change-this-in-production"
# Judge0 API Configuration
JUDGE0_API_URL="https://judge0-ce.p.sulu.sh"
SULU_API_KEY="your-judge0-api-key"
# Razorpay Payment Gateway
RAZORPAY_KEY_ID="your-razorpay-key-id"
RAZORPAY_KEY_SECRET="your-razorpay-key-secret"
# Email/SMTP Configuration
SMTP_HOST="smtp.gmail.com"
SMTP_PORT="587"
SMTP_USER="[email protected]"
SMTP_PASS="your-app-password"- Sign up at Judge0 or use the public API
- Get your API key and update
SULU_API_KEY - Configure rate limits and supported languages
- Create account at Razorpay
- Get API keys from dashboard
- Configure webhooks for payment verification
- Enable 2FA on Gmail account
- Generate app-specific password
- Update SMTP credentials in environment
- Users: Authentication, profiles, roles
- Problems: Coding challenges with test cases
- Sheets: Curated problem collections
- Contests: Timed competitions
- Submissions: Code submissions and results
- Payments: Transaction records
User 1---* Submission
User 1---* Payment
Problem 1---* Submission
Sheet 1---* SheetProblem *---1 Problem
Contest 1---* ContestProblem *---1 Problemcd backend
npm test # Run all tests
npm run test:unit # Unit tests only
npm run test:integration # Integration tests only
npm run test:coverage # Generate coverage reportcd frontend
npm test # Run Jest/Vitest tests
npm run test:e2e # Run end-to-end tests
npm run test:component # Component testingUse the provided Postman collection or test manually:
# Health check
curl http://localhost:8080/api/v1/health
# Authentication
curl -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","password":"password"}'# Check if PostgreSQL is running
docker-compose ps postgres
# View database logs
docker-compose logs postgres
# Reset database
docker-compose down -v
docker-compose up -d postgres# Reset migrations (CAUTION: Will lose data)
npx prisma migrate reset
# Apply pending migrations
npx prisma migrate deploy
# Generate client after schema changes
npx prisma generate# Clear node modules and reinstall
rm -rf node_modules package-lock.json
npm install
# Clear Vite cache
rm -rf .vite
npm run dev# Rebuild containers without cache
docker-compose build --no-cache
# Remove all containers and volumes
docker-compose down -v --remove-orphans
# Check container logs
docker-compose logs [service-name]| Error | Solution |
|---|---|
ECONNREFUSED |
Check if required services are running |
Prisma Client not found |
Run npx prisma generate |
Migration failed |
Check database connectivity and permissions |
Port already in use |
Change port or kill existing process |
CORS error |
Verify frontend URL in backend CORS config |
Judge0 API timeout |
Check API key and network connectivity |
- Docker Engine 20.10+
- Docker Compose 2.0+
- SSL certificates (for HTTPS)
- Domain name configured
# Clone repository
git clone https://github.com/yourusername/leetlab.git
cd leetlab
# Configure production environment
cp .env.example .env
# Edit .env with production values
# Set up SSL certificates
mkdir -p nginx/ssl
# Add your SSL certificates to nginx/ssl/
# Deploy
chmod +x deploy-prod.sh
./deploy-prod.sh
# Verify deployment
docker-compose ps
curl -k https://yourdomain.com/health- Environment variables configured
- SSL certificates installed
- Database backups configured
- Monitoring setup (logs, metrics)
- Security hardening applied
- Load testing completed
- ECS/Fargate: Container orchestration
- RDS: Managed PostgreSQL
- ElastiCache: Managed Redis
- CloudFront: CDN for static assets
- Route 53: DNS management
- App Platform: Managed container deployment
- Managed Database: PostgreSQL and Redis
- Spaces: Object storage
- Load Balancers: High availability
# Install Docker on Ubuntu/Debian
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
# Deploy application
git clone https://github.com/yourusername/leetlab.git
cd leetlab
./deploy-prod.sh- Database Indexing: Optimized queries with proper indexes
- Redis Caching: Session storage and frequent data caching
- Connection Pooling: PostgreSQL connection optimization
- Compression: Gzip compression for API responses
- Code Splitting: Route-based lazy loading
- Asset Optimization: Image compression and lazy loading
- Bundle Analysis: Webpack bundle analyzer integration
- PWA Features: Service worker for offline functionality
-- Add indexes for frequently queried columns
CREATE INDEX idx_problems_difficulty ON problems(difficulty);
CREATE INDEX idx_submissions_user_id ON submissions(user_id);
CREATE INDEX idx_sheets_type ON sheets(type);- JWT Tokens: Secure stateless authentication
- Refresh Tokens: Extended session management
- Role-Based Access: User, Admin, SuperAdmin roles
- Rate Limiting: API endpoint protection
- Input Validation: Comprehensive request validation
- SQL Injection Protection: Prisma ORM parameterized queries
- XSS Prevention: Content Security Policy headers
- HTTPS Enforcement: SSL/TLS encryption
# Update dependencies regularly
npm audit
npm audit fix
# Use security headers
helmet.js middleware configured
# Environment variable validation
joi schema validationWe welcome contributions from the community! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test thoroughly
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow existing code style and conventions
- Write comprehensive tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting
- Use meaningful commit messages
- Frontend: ESLint + Prettier configuration
- Backend: ESLint + Standard JavaScript style
- Database: Follow Prisma naming conventions
- Git: Conventional commit messages
Please use GitHub Issues to report bugs or request features:
- Bug Reports: Include steps to reproduce, expected vs actual behavior
- Feature Requests: Describe the use case and proposed solution
- Security Issues: Email [email protected] (do not use public issues)
This project is licensed under the MIT License. See the LICENSE file for details.
- React - Frontend framework
- Node.js - Backend runtime
- PostgreSQL - Primary database
- Prisma - Database ORM and migrations
- Docker - Containerization platform
- Tailwind CSS - Utility-first CSS framework
- Lucide React - Beautiful icon library
- Monaco Editor - Code editor
Special thanks to all contributors, testers, and users who help make LeetLab better!
- Documentation: Wiki
- Community: Discord Server
- Issues: GitHub Issues
- Email: [email protected]
Made with β€οΈ by the LeetLab Team