A comprehensive, full-stack LeetCode clone featuring a modern Angular frontend and robust Go backend with real-time code execution, user authentication, and problem management.
- JWT-based authentication system
- User registration and login
- Password reset functionality
- Admin role management
- Rate limiting for security
- Complete CRUD operations for coding problems
- Advanced filtering by difficulty, tags, and search queries
- Rich problem descriptions with examples and constraints
- Multi-language support (JavaScript, Python, Java)
- Template code generation for each language
- Public and hidden test cases
- Sandboxed code execution using Docker containers
- Multi-language support with secure runtime environments
- Performance monitoring (runtime and memory usage)
- Timeout and memory limit enforcement
- Comprehensive error handling and feedback
- Real-time code submission and evaluation
- Detailed execution results with test case feedback
- Submission history with pagination and filtering
- Performance metrics and statistics tracking
- User progress tracking and problem completion status
- Acceptance rate calculations
- Angular 17 with standalone components (zoneless)
- NgRx for state management
- NG-ZORRO UI component library
- Monaco Editor for code editing with syntax highlighting
- Tailwind CSS for responsive design
- Real-time updates and optimistic UI
- Angular 17 - Modern web framework with standalone components
- NgRx - Reactive state management
- NG-ZORRO - Enterprise-class UI components
- Tailwind CSS - Utility-first CSS framework
- Monaco Editor - VS Code editor for the web
- TypeScript - Type-safe JavaScript
- Go 1.21 - High-performance backend language
- Gin - Fast HTTP web framework
- PostgreSQL 15 - Robust relational database
- JWT - Secure authentication tokens
- Docker - Containerized code execution
- GORM - Go ORM for database operations
- Docker & Docker Compose - Containerization and orchestration
- Colima - Docker container management for macOS
- PostgreSQL - Primary database
- Nginx - Production web server
- Node.js 20+
- Go 1.21+
- Docker & Docker Compose
- Colima (for macOS users)
git clone <repository-url>
cd leetcode-clone
# Setup Colima (macOS only)
./setup-colima.sh# Quick setup with sample data
make setup-dev
# Or manual setup
docker-compose -f docker-compose.dev.yml up -d
make seed-db- Frontend: http://localhost:4200
- Backend API: http://localhost:8080
- API Documentation: http://localhost:8080/api/v1/health
POST /api/v1/auth/register - User registration
POST /api/v1/auth/login - User login
POST /api/v1/auth/password-reset - Request password reset
POST /api/v1/auth/password-reset/confirm - Confirm password reset
# Public Endpoints
GET /api/v1/problems - List problems with filtering
GET /api/v1/problems/search - Search problems
GET /api/v1/problems/:id - Get problem by ID
GET /api/v1/problems/slug/:slug - Get problem by slug
GET /api/v1/problems/:id/testcases - Get test cases
# Admin Endpoints (Authentication Required)
POST /api/v1/admin/problems - Create problem
PUT /api/v1/admin/problems/:id - Update problem
DELETE /api/v1/admin/problems/:id - Delete problem
POST /api/v1/admin/problems/:id/testcases - Create test case
PUT /api/v1/admin/testcases/:id - Update test case
DELETE /api/v1/admin/testcases/:id - Delete test case
POST /api/v1/execute/run - Run code against public test cases
POST /api/v1/execute/submit - Submit code for evaluation
POST /api/v1/execute/validate - Validate code syntax
GET /api/v1/execute/languages - Get supported languages
POST /api/v1/submissions - Create submission
GET /api/v1/submissions/:id - Get submission by ID
GET /api/v1/submissions/me - Get current user submissions
GET /api/v1/submissions/stats/me - Get user statistics
GET /api/v1/problems/:id/submissions - Get problem submissions
- Pagination:
page,page_size(max 100) - Filtering:
difficulty,tags,problem_id - Sorting:
sort_by,sort_order - Search:
q(query string)
leetcode-clone/
βββ π frontend/ # Angular Application
β βββ π src/app/
β β βββ π auth/ # Authentication module
β β β βββ π components/ # Login, register components
β β β βββ π guards/ # Route guards
β β β βββ π services/ # Auth services
β β β βββ π store/ # NgRx auth state
β β βββ π problems/ # Problem management
β β β βββ π components/ # Problem list, solve, editor
β β β βββ π services/ # Problem services
β β β βββ π store/ # NgRx problem state
β β βββ π app.config.ts # App configuration
β β βββ π app.routes.ts # Routing configuration
β βββ π package.json
β βββ π angular.json
β βββ π tailwind.config.js
β βββ π Dockerfile
βββ π backend/ # Go API Server
β βββ π pkg/
β β βββ π auth/ # JWT authentication
β β βββ π database/ # Database connection
β β βββ π execution/ # Code execution engine
β β βββ π handlers/ # HTTP handlers
β β βββ π middleware/ # HTTP middleware
β β βββ π models/ # Data models
β β βββ π repository/ # Data access layer
β β βββ π services/ # Business logic
β βββ π migrations/ # Database migrations
β βββ π scripts/ # Utility scripts
β βββ π main.go # Application entry point
β βββ π go.mod # Go dependencies
β βββ π Dockerfile
βββ π docker-compose.yml # Production compose
βββ π docker-compose.dev.yml # Development compose
βββ π Makefile # Development commands
βββ π setup-colima.sh # macOS Docker setup
make help # Show all available commands
make setup-dev # Complete development environment setup
make seed-db # Seed database with sample problems
make clean-db # Clear all database data (WARNING!)cd frontend
npm install
npm start # Development server on :4200
npm run build # Production build
npm test # Run unit tests
npm run lint # Code lintingcd backend
go mod download
go run main.go # Development server on :8080
go test ./... # Run all tests
go build # Build binary# View database schema
cd backend && go run scripts/validate_schema.go
# Seed with sample data
make seed-db
# Connect to database
docker exec -it leetcode-postgres psql -U leetcode -d leetcode# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run specific package tests
go test ./pkg/services -v
go test ./pkg/handlers -v# Unit tests
npm test
# E2E tests
npm run e2e
# Test coverage
npm run test:coverage# Build and start all services
docker-compose up --build -d
# View logs
docker-compose logs -f# Backend (.env)
DB_HOST=postgres
DB_PORT=5432
DB_USER=leetcode
DB_PASSWORD=password
DB_NAME=leetcode
JWT_SECRET=your-secret-key
PORT=8080
# Frontend (environment.prod.ts)
API_URL=http://localhost:8080/api/v1- users - User accounts and authentication
- problems - Coding problems and metadata
- test_cases - Problem validation test cases
- submissions - User code submissions
- user_progress - Problem completion tracking
- Automatic migrations on startup
- Foreign key constraints for data integrity
- Indexes for query performance
- JSON fields for flexible data storage
- JWT tokens with expiration
- Password hashing with bcrypt
- Rate limiting on auth endpoints
- Role-based access control (admin/user)
- Docker sandboxing for code execution
- Resource limits (CPU, memory, time)
- Network isolation (no internet access)
- Input validation and sanitization
- Dangerous pattern detection
- Authentication System - JWT-based auth with registration/login
- Problem Management - Full CRUD with advanced filtering
- Code Execution Engine - Sandboxed multi-language execution
- Submission System - Complete submission workflow
- Database Schema - Comprehensive data model
- API Documentation - Detailed endpoint documentation
- Testing Suite - Unit and integration tests
- Docker Setup - Development and production containers
- Frontend Components - Angular UI implementation
- Real-time Features - WebSocket integration
- Advanced Analytics - User performance insights
- Discussion Forum - Problem discussions and solutions
- Contest System - Timed coding competitions
- Social Features - User profiles and following
- Mobile App - React Native mobile client
- 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
- Follow Go and Angular best practices
- Write comprehensive tests for new features
- Update documentation for API changes
- Use conventional commits for commit messages
This project is licensed under the MIT License - see the LICENSE file for details.
- LeetCode for inspiration
- Angular Team for the amazing framework
- Go Community for excellent libraries
- Docker for containerization technology
Built with β€οΈ by the development team