Skip to content

Pantkartik/LETS_PREP_

Repository files navigation

LETS_PREP_ - Production-Grade Online Judge Platform

A secure, scalable online coding platform with real-time code execution, competitive programming features, and classroom management.

πŸš€ Features

Core Features

  • βœ… Secure Code Execution: Docker-isolated execution for C++, Python, Java, JavaScript
  • βœ… 30+ LeetCode-style Problems: Comprehensive test cases for each problem
  • βœ… Real-time Leaderboards: Live competition tracking
  • βœ… Classroom Management: Teacher dashboards, student progress tracking
  • βœ… Battle Mode: 1v1 coding competitions
  • βœ… Competition System: Timed contests with rankings

Security Features

  • πŸ”’ Docker Isolation: Each submission runs in isolated container
  • πŸ”’ Resource Limits: CPU, Memory, Time constraints enforced
  • πŸ”’ Network Isolation: Containers have no network access
  • πŸ”’ Seccomp Filtering: Syscall restrictions via seccomp profile
  • πŸ”’ No Privilege Escalation: Security hardening enabled
  • πŸ”’ Automatic Cleanup: Containers destroyed after execution

Technical Highlights

  • ⚑ Template Engine: Auto-generates input parsing for C++ signatures
  • ⚑ Validation Modes: Exact match, floating-point (epsilon), custom validators
  • ⚑ Async Execution: Bull queue for background job processing
  • ⚑ Real-time Updates: WebSocket support for live competitions
  • ⚑ Row Level Security: Supabase RLS for data protection

πŸ“ Project Structure

LETS_PREP_/
β”œβ”€β”€ Backend/                 # Node.js + Express API
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ execution/   # Code execution engine
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ IsolationManager.ts
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ TemplateEngine.ts
β”‚   β”‚   β”‚   β”‚   └── Validator.ts
β”‚   β”‚   β”‚   └── codeExecution.service.ts
β”‚   β”‚   β”œβ”€β”€ controllers/     # API controllers
β”‚   β”‚   β”œβ”€β”€ routes/          # API routes
β”‚   β”‚   └── definitions/     # Language configs
β”‚   β”œβ”€β”€ scripts/             # Utility scripts
β”‚   └── seccomp_profile.json # Security profile
β”œβ”€β”€ Frontend/                # Next.js 16 + React
β”‚   β”œβ”€β”€ app/                 # App router pages
β”‚   β”œβ”€β”€ components/          # React components
β”‚   β”œβ”€β”€ lib/                 # Utilities
β”‚   └── supabase/            # Database migrations
└── .github/
    └── workflows/           # CI/CD pipelines

πŸ› οΈ Tech Stack

Backend

  • Runtime: Node.js 20+
  • Framework: Express.js
  • Database: Supabase (PostgreSQL)
  • Queue: Bull (Redis)
  • Execution: Docker + Dockerode
  • Validation: Zod
  • Auth: JWT + Supabase Auth

Frontend

  • Framework: Next.js 16 (App Router)
  • UI: React 19 + Tailwind CSS
  • Components: Radix UI + shadcn/ui
  • Code Editor: Monaco Editor
  • State: React Hooks
  • Auth: Supabase Auth

DevOps

  • Containerization: Docker
  • CI/CD: GitHub Actions
  • Security: TruffleHog, Dependabot, CodeRabbit
  • Monitoring: Vercel Analytics (optional)

πŸš€ Quick Start

Prerequisites

  • Node.js 20+
  • Docker Desktop
  • Git
  • Supabase account

1. Clone Repository

git clone https://github.com/YOUR_USERNAME/LETS_PREP_.git
cd LETS_PREP_

2. Backend Setup

cd Backend

# Install dependencies
npm install

# Copy environment template
cp .env.example .env

# Edit .env with your Supabase credentials
# Get from: https://app.supabase.com/project/_/settings/api

# Pull Docker images for code execution
npx ts-node pull_images.ts

# Start development server
npm run dev

Backend runs on http://localhost:3001

3. Frontend Setup

cd Frontend

# Install dependencies
npm install

# Copy environment template
cp .env.example .env.local

# Edit .env.local with your Supabase credentials

# Start development server
npm run dev

Frontend runs on http://localhost:3000

4. Database Setup

  1. Go to Supabase Dashboard β†’ SQL Editor
  2. Run migrations in order:
    • Frontend/supabase/complete_setup.sql
    • Frontend/supabase/add_all_testcases.sql

5. Verify Installation

cd Backend
npx ts-node verify_engine.ts

Should output: βœ… All tests passed

πŸ“š Documentation

πŸ”’ Security

This project implements industry-standard security practices:

  • βœ… No secrets in source code
  • βœ… Environment variables for all credentials
  • βœ… Docker isolation for untrusted code
  • βœ… Input validation and sanitization
  • βœ… SQL injection prevention
  • βœ… XSS protection
  • βœ… CSRF protection
  • βœ… Rate limiting
  • βœ… Automated security audits

Found a security vulnerability? Email: security@lets-prep.com

πŸ§ͺ Testing

Run Tests

# Backend unit tests
cd Backend
npm test

# Frontend tests
cd Frontend
npm test

# E2E tests
npm run test:e2e

Test Code Execution

cd Backend
npx ts-node test_find_k_closest.ts

πŸ“¦ Deployment

Vercel (Frontend)

cd Frontend
npx vercel

Railway (Backend)

cd Backend
railway init
railway up

Docker Compose

docker-compose up -d

See GITHUB_PUSH_GUIDE.md for detailed deployment instructions.

🀝 Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'feat: add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open Pull Request

Note: All PRs are automatically reviewed by CodeRabbit AI.

πŸ“ Environment Variables

Backend (.env)

SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
JWT_SECRET=your_jwt_secret
DOCKER_ENABLED=true

See .env.example for complete list.

Frontend (.env.local)

NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key
NEXT_PUBLIC_API_URL=http://localhost:3001

πŸ—οΈ Architecture

Code Execution Flow

User Code β†’ API β†’ Queue β†’ Worker β†’ IsolationManager β†’ Docker Container
                                                            ↓
Expected Output ← Validator ← TemplateEngine ← Container Output

Security Layers

  1. Input Validation: Zod schemas
  2. Template Injection: Safe code wrapping
  3. Docker Isolation: Container per execution
  4. Resource Limits: CPU/Memory/Time constraints
  5. Seccomp Profile: Syscall filtering
  6. Output Validation: Normalized comparison

πŸ“Š Performance

  • Execution Time: ~2-5s per submission (including Docker overhead)
  • Concurrent Executions: Limited by Docker resources
  • Scalability: Horizontal scaling via worker nodes
  • Caching: Template compilation cached

πŸ› Known Issues

  • Nested vector types not fully supported in C++ parser
  • Python async/await requires special handling
  • Java class name must be "Solution"

See Issues for full list.

πŸ“„ License

MIT License - see LICENSE file

πŸ‘₯ Team

πŸ™ Acknowledgments

  • LeetCode for problem inspiration
  • Supabase for backend infrastructure
  • Docker for secure execution environment
  • shadcn/ui for beautiful components

⭐ Star this repo if you find it useful!

πŸ› Report bugs: GitHub Issues

πŸ’¬ Discussions: GitHub Discussions

About

A high-performance, real-time competitive programming platform featuring multiplayer battle arenas, secure code execution, and advanced analytics for students and educators.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors