Skip to content

rohansen856/codeaider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🧠 CP Assistant — Competitive Programming AI Mentor

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.


🏗️ Architecture

Extension UI (Vanilla JS)
     │
Content Scripts (DOM Scraping)
     │
Background Service Worker
     │
Backend API (Node.js + Express)
     │
Gemini API

📂 Project Structure

├── 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

🚀 Quick Start

1. Backend Setup

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

2. Extension Setup

  1. Open Chrome → chrome://extensions
  2. Enable Developer mode
  3. Click Load unpacked
  4. Select the extension/ folder
  5. Navigate to any LeetCode or Codeforces problem page
  6. The sidebar auto-opens! Click ⚡ Analyze to get AI insights.

🎯 Features

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

🛡️ Security

  • 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

🧠 AI Behavior Rules

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

📊 Storage

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.


🔧 Mode Flags

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

📜 License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages