A modern, AI-powered coding problem generator built with Astro, Svelte, and Python Flask. Generate custom LeetCode-style problems with intelligent difficulty scaling, topic selection, and an integrated code editor.
cd frontend
npm install
npm run dev
The frontend will be available at http://localhost:4321
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
# Copy environment variables
cp .env.example .env
# Edit .env with your configuration
python app.py
The backend API will be available at http://localhost:5000
Create a .env
file in the frontend directory:
BACKEND_URL=http://localhost:5000
PUBLIC_APP_NAME="AI LeetCode Generator"
Create a .env
file in the backend directory:
# MongoDB Configuration
MONGO_URI=mongodb://localhost:27017/leetcode_generator
# Redis Configuration
REDIS_URI=redis://localhost:6379
# Judge0 API Configuration
JUDGE0_API_KEY=your_judge0_api_key_here
JUDGE0_API_URL=https://judge0-ce.p.rapidapi.com
# Unsloth AI Model Configuration
UNSLOTH_MODEL_PATH=unsloth/llama-2-7b-chat-bnb-4bit
UNSLOTH_MAX_SEQ_LENGTH=2048
UNSLOTH_DTYPE=float16
UNSLOTH_LOAD_IN_4BIT=true
# Flask Configuration
FLASK_ENV=development
FLASK_DEBUG=true
SECRET_KEY=your_secret_key_here_change_in_production
# Rate Limiting
RATE_LIMIT_STORAGE_URL=redis://localhost:6379
RATE_LIMIT_DEFAULT=100 per hour
# CORS Configuration
CORS_ORIGINS=http://localhost:3000,http://localhost:4321
# Logging
LOG_LEVEL=INFO
LOG_FILE=app.log
POST /api/problems/generate-problem
Content-Type: application/json
{
"topic": "Array",
"difficulty": "medium",
"additional_requirements": "Focus on two-pointer technique"
}
POST /api/submissions/submit
Content-Type: application/json
{
"problem_id": "problem-id",
"code": "function solution() { ... }",
"language": "javascript"
}
frontend/
โโโ src/
โ โโโ components/ # Svelte components
โ โ โโโ LeetCodeGenerator.svelte
โ โ โโโ CodeEditor.svelte
โ โโโ layouts/ # Astro layouts
โ โโโ pages/ # Astro pages and API routes
โ โ โโโ index.astro
โ โ โโโ api/generate.js
โ โโโ styles/ # Global styles
โโโ astro.config.mjs # Astro configuration
โโโ tailwind.config.mjs # Tailwind configuration
โโโ package.json
backend/
โโโ app/
โ โโโ models/ # Database models
โ โ โโโ problem.py
โ โ โโโ submission.py
โ โโโ routes/ # API routes
โ โ โโโ problems.py
โ โ โโโ submissions.py
โ โ โโโ ai.py
โ โ โโโ code_exec.py
โ โ โโโ health.py
โ โโโ services/ # Business logic services
โ โโโ database.py # Database configuration
โโโ db/ # Database management
โ โโโ __init__.py # Unified database manager
โโโ services/ # Core services
โ โโโ ai_service.py # AI service integration
โ โโโ code_exec.py # Code execution service
โ โโโ problem_gen.py # Problem generation service
โโโ models/ # AI models
โ โโโ llama_model.py
โ โโโ mistral_model.py
โโโ utils/ # Utility functions
โ โโโ formatters.py # Response formatting
โ โโโ validators.py # Input validation
โ โโโ prompt_templates.py # AI prompt templates
โโโ app.py # Flask application
โโโ requirements.txt
cd frontend
npm run test
npm run test:e2e
cd backend
python -m pytest tests/
npm run build
# Deploy dist/ folder
docker build -t leetcode-generator-backend .
docker run -p 5000:5000 leetcode-generator-backend
git checkout -b feature/amazing-feature
git commit -m 'Add amazing feature'
git push origin feature/amazing-feature
This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions or need help:
Happy Coding! ๐