Skip to content

Orb-20/Leetcode_AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Leetcode AI — Your Smart Coding Coach 🚀


🌌 Overview

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.


⚙️ Tech Stack

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)

🧩 Features

  • 🧠 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

🗂 Folder Structure


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


🚀 Getting Started

1️⃣ Clone the Repository

git clone https://github.com/Orb-20/Leetcode_AI.git
cd Leetcode_AI/backend

2️⃣ Install Backend Dependencies

pip install -r requirements.txt
uvicorn main:app --reload

Your FastAPI server will start at:

http://localhost:8000/analyze


3️⃣ Load the Chrome Extension

  1. Open Chromechrome://extensions/
  2. Turn on Developer Mode
  3. Click Load Unpacked
  4. Select the extension/ folder

Now open any LeetCode problem and click the Leetcode AI popup to analyze your code.


💻 Example Code Snippet

🧠 Backend — main.py

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."}

🌐 Chrome Manifest — manifest.json

{
  "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"
  }
}

🧠 Machine Learning

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."}

🧭 Roadmap

  • FastAPI backend setup
  • Chrome extension integration
  • Dataset generation script
  • Full model fine-tuning integration
  • Cloud deployment
  • Advanced UI & performance dashboard

🧾 License

This project is licensed under the MIT License — free for personal and commercial use.


🖤 Built to make coding smarter, faster, and more human.

```

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published