A Chromium browser extension + Node.js backend that provides AI-powered guidance for competitive programming problems on LeetCode and Codeforces.
Philosophy: Never gives full solutions. Only intuition, approaches, mistake analysis, and learning paths.
Extension UI (Vanilla JS)
│
Content Scripts (DOM Scraping)
│
Background Service Worker
│
Backend API (Node.js + Express)
│
Gemini API
├── backend/
│ ├── src/
│ │ ├── server.js # Express API server
│ │ ├── ai/
│ │ │ ├── gemini-client.js # Gemini API wrapper
│ │ │ ├── prompt-builder.js# Prompt construction
│ │ │ └── response-schema.json
│ │ ├── db/
│ │ │ ├── pool.js # PostgreSQL connection pool
│ │ │ └── migrate.js # Database migrations
│ │ └── routes/
│ │ ├── analyze.js # Main analysis endpoint
│ │ ├── verdict.js # Post-submission analysis
│ │ └── sync.js # Cloud sync endpoints
│ ├── package.json
│ └── .env.example
│
├── extension/
│ ├── manifest.json # Manifest V3
│ ├── icons/
│ ├── src/
│ │ ├── background/
│ │ │ └── service-worker.js
│ │ ├── content/
│ │ │ ├── main.js # Content script entry
│ │ │ ├── site-detector.js # Platform detection
│ │ │ ├── scraper-dispatcher.js
│ │ │ ├── context-builder.js
│ │ │ ├── sidebar-controller.js
│ │ │ ├── sidebar.css
│ │ │ └── scrapers/
│ │ │ ├── leetcode-scraper.js
│ │ │ └── codeforces-scraper.js
│ │ ├── sidebar/ # Sidebar iframe
│ │ ├── popup/ # Extension popup
│ │ ├── dashboard/ # Analytics dashboard
│ │ └── storage/
│ │ ├── indexeddb-store.js
│ │ └── sync-manager.js
│ └── README.md
cd backend
cp .env.example .env
# Edit .env — add your GEMINI_API_KEY and DATABASE_URL
npm install
npm run migrate # Create PostgreSQL tables
npm run dev # Start with auto-reload- Open Chrome →
chrome://extensions - Enable Developer mode
- Click Load unpacked
- Select the
extension/folder - Navigate to any LeetCode or Codeforces problem page
- The sidebar auto-opens! Click ⚡ Analyze to get AI insights.
| Feature | Description |
|---|---|
| 💡 Intuition | Core idea, why the problem exists, concept tested |
| 🛤️ Approaches | Common patterns from community solutions with complexities |
| 📖 Code Explanation | What your code does, algorithm, data structures |
| 🐛 Mistake Finder | Logical errors, edge cases, off-by-one, overflow |
| ⚖️ Verdict Analyzer | Post-submission analysis for WA/TLE/RTE |
| 🎯 Recommendations | Next 3 problems based on Striver A2Z, LC, CF lists |
| 📊 Dashboard | Stats, charts, heatmap, streak tracking |
| ☁️ Cloud Sync | Optional bidirectional sync to PostgreSQL |
- API key stored only on backend (never in extension)
- Rate limiting: 30 requests/minute per IP
- All scraped HTML is sanitized server-side
- No user code stored unless opted in
- CORS restricted to extension origin
The AI is configured to:
- ✅ Provide reasoning, patterns, high-level steps
- ✅ Show small pseudocode snippets (≤5 lines)
- ✅ Identify conceptual mistakes
- ❌ Never output full working solutions
- ❌ Never produce code that can be submitted directly
Local (IndexedDB): Browser-based, privacy-first, works offline.
Cloud (PostgreSQL): Optional sync for backup and cross-device access.
Both layers share the same schema: users, problems, attempts, code_snapshots, mistakes, recommendations, daily_stats, topic_progress, platform_stats, settings, achievements, streaks.
Toggle in the sidebar settings:
{
"leetcode_mode": true,
"codeforces_mode": true,
"features": {
"intuition": true,
"approaches": true,
"mistake_analysis": true,
"bug_localization": true,
"wrong_answer_analysis": true,
"next_question_recommendation": true
}
}MIT