Leetcode AI is an advanced AI-powered Chrome Extension that analyzes your LeetCode code submissions and provides intelligent feedback, performance insights, and suggestions to improve your problem-solving skills.
It integrates a FastAPI backend, a browser extension frontend, and a machine learning pipeline capable of training and analyzing code data.
| Layer | Technology |
|---|---|
| Frontend (Extension) | HTML, CSS, JavaScript (Manifest v3) |
| Backend API | FastAPI, Python |
| Machine Learning | HuggingFace Transformers, JSONL datasets, Phi-2 model |
| Communication | REST (via fetch requests from popup.js) |
- 🧠 AI-powered code feedback
- 🔗 Direct integration with LeetCode problem pages
- ⚡ Instant insights via popup interface
- 🧰 Modular structure (backend, extension, ML separated)
- 🧮 ML pipeline for dataset generation & fine-tuning
- 🔒 Local-first design — runs via your backend endpoint
Leetcode_AI/
├── backend/ # FastAPI server
│ ├── main.py
│ └── requirements.txt
│
├── extension/ # Chrome extension (Manifest v3)
│ ├── manifest.json
│ ├── popup.html
│ ├── popup.js
│ ├── content.js
│ ├── styles.css
│ └── icons/
│ ├── icon16.png
│ ├── icon48.png
│ └── icon128.png
│
├── machine_learning/ # ML training setup
│ ├── generate_dataset.py
│ ├── input_problems.jsonl
│ ├── training_dataset.jsonl
│ └── leetcode-ai-coach-phi2/
│ ├── adapter_model.safetensors
│ └── tokenizer_config.json
│
└── test_ollama.py # Testing and model verification script
git clone https://github.com/Orb-20/Leetcode_AI.git
cd Leetcode_AI/backendpip install -r requirements.txt
uvicorn main:app --reloadYour FastAPI server will start at:
- Open Chrome →
chrome://extensions/ - Turn on Developer Mode
- Click Load Unpacked
- Select the
extension/folder
Now open any LeetCode problem and click the Leetcode AI popup to analyze your code.
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["*"],
allow_headers=["*"],
)
@app.post("/analyze")
async def analyze_code(request: Request):
data = await request.json()
code = data.get("code", "")
return {"analysis": f"AI Feedback: Great structure! Try optimizing loops."}{
"manifest_version": 3,
"name": "Leetcode AI Coach",
"version": "1.0.0",
"description": "Get AI-powered insights on your LeetCode solutions.",
"permissions": ["activeTab", "scripting"],
"host_permissions": ["*://leetcode.com/problems/*"],
"action": { "default_popup": "popup.html" },
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
}
}The ML module (machine_learning/) is designed to:
- Generate a training dataset from LeetCode problems
- Fine-tune a lightweight model like Phi-2
- Store model weights and tokenizer configs locally
Example dataset format (training_dataset.jsonl):
{"input": "Two Sum problem", "output": "Use hashmap for O(n) solution."}- FastAPI backend setup
- Chrome extension integration
- Dataset generation script
- Full model fine-tuning integration
- Cloud deployment
- Advanced UI & performance dashboard
This project is licensed under the MIT License — free for personal and commercial use.
🖤 Built to make coding smarter, faster, and more human.
```