Skip to content

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

⚡ CodeSense AI — Real-Time AI Code Reviewer & Interactive IDE

CodeSense AI Django Python Monaco Vercel License

A full-stack, cloud-native developer environment combining real-time LLM code review, an authentic VS Code interactive terminal, polyglot remote code execution, and seamless workspace management.

🌐 Explore Live Application »

Key Features • Architecture • Tech Stack • Getting Started • API Docs • Author


🌐 Live Production Deployment


📸 Workspace Overview

CodeSense AI Interface


✨ Key Features

1. 🧠 Real-Time Streaming AI Assistant

  • Token-by-Token SSE: Streaming responses via Server-Sent Events for near-instant latency without buffering.
  • xKiro AI Engine with Fallback: Powered primarily by Qwen 3.8 Omni Flash via xKiro API, with automatic graceful fallback to Meta Llama 3.1 8B on NVIDIA NIM.
  • Context-Aware Review: Analyzes editor code, selected language, and syntax trees to highlight bugs, security vulnerabilities, edge cases, and time/space complexity optimizations.
  • Automated YouTube Video Recommendations: Whenever relevant coding topics or algorithms are discussed, relevant educational lecture videos are dynamically fetched and embedded directly inside the chat feed.

2. ⚡ AI Logo "New Chat" & Chat History Management

  • Instant Session Reset: Click the glowing AI Logo button directly above the decorator toolbar to instantly initialize a clean chat session with pre-configured suggestion chips (Explain Code, Find Bugs, Optimize, Security).
  • Overlay Chat History: Click Old Chats to open a full slide-in drawer showing previous conversation threads with timestamps and message counts.
  • Granular Chat Deletion (🗑️): Remove individual sessions with a single click, keeping both guest and authenticated storage clutter-free.

3. 💻 Authentic VS Code Interactive Terminal

  • Zero Clutter: Replaced cumbersome static STDIN input forms with an integrated, authentic VS Code terminal experience (>_ TERMINAL).
  • Smart Input Detection & Inline Prompt: Automatically parses incoming code for input operations (cin >>, scanf, input(), Scanner) and prompts with an inline cursor (PS C:\workspace> █).
  • Live Echo Execution: Enter input values directly into the console prompt, hitting Enter to freeze the input and immediately stream remote compiler execution outputs.

4. ⚙️ Polyglot Remote Execution Engine

  • Cloud Sandboxing: Executes C++, Python, Java, and JavaScript via the Judge0 API.
  • Base64 & Unicode Normalization: Employs an internal string normalizer to convert mathematical Unicode symbols (e.g., ≤, ≥, ≠, non-standard quotes) into strict ASCII prior to Base64 transmission, eliminating HTTP 400 submission errors.

5. 💾 Workspace File Manager & Hot-Reload

  • File Persistence: Save, tag, and organize custom source code snippets across multiple languages.
  • Two-Way Sync: Load any saved code directly into the editor with automatic language switching and syntax re-highlighting.
  • Persistent User State: Stores files safely with support for signed-in user profiles and local guest workspaces.

6. 🔐 Stateless HMAC Authentication

  • Zero Cold-Start Lag: Engineered with cryptographically signed tokens (django.core.signing) to operate statelessly across serverless lambdas.
  • No Database Locking: Eliminates database latency and connection pool exhaustion during sudden spikes on Vercel.

7. 🛡️ Sliding-Window IP Rate Limiter & Abuse Shield

  • Automated Spam Mitigation: Enforces a sliding-window rate limiting policy allowing a maximum of 7 messages per 60 seconds per client IP.
  • Real IP Edge Detection: Extracts genuine user IP addresses behind Vercel edge reverse proxies (HTTP_X_FORWARDED_FOR) with fallback handling.
  • Zero AI Token Waste: Throttled requests are blocked immediately at the Django gateway with HTTP 429 (Too Many Requests), protecting API keys and upstream LLM quotas.
  • Live UI Cooldown Countdown: The chat Send button turns into a dynamic countdown (Wait 22s...), temporarily disabling input until the cooldown window slides.

8. 📚 DSA Pattern Playbook & LeetCode Practice Module

  • THE DSA PATTERN PLAYBOOK Integration: Features a curated library of 75+ top interview DSA problems structured from the Playbook PDF across 13 core algorithmic categories:
    1. Arrays & Hashing (Two Sum, Contains Duplicate, Group Anagrams, etc.)
    2. Two Pointers (3Sum, Container With Most Water, Valid Palindrome, etc.)
    3. Sliding Window (Longest Substring Without Repeating, Min Window Substring, etc.)
    4. Stack (Valid Parentheses, Min Stack, Monotonic Stack, Largest Histogram)
    5. Binary Search (Search Rotated Array, 2D Matrix, Koko Bananas)
    6. Linked List (Reverse List, Cycle Detection, Merge K Sorted Lists)
    7. Trees (Invert Tree, Level Order Traversal, Validate BST, Max Path Sum)
    8. Tries (Implement Trie, Word Search II)
    9. Heap / Priority Queue (Kth Largest, Median Stream, Task Scheduler)
    10. Backtracking (Subsets, Combination Sum, N-Queens, Sudoku Solver)
    11. Graphs (Number of Islands, Rotting Oranges, Course Schedule)
    12. Dynamic Programming (Climbing Stairs, House Robber, Coin Change, LIS)
  • Direct LeetCode Practice Links: One-click Practice on LeetCode ↗ links opening the exact problem page on LeetCode (https://leetcode.com/problems/<slug>/).
  • Header Bar & Full-Page Navigation: Accessible via a dark-themed [≡] Problem List < > toolbar bar above the Code Editor with a ← Back to Dashboard button for smooth navigation.
  • Key Patterns & Takeaways: Includes essential interview takeaways, pattern summaries, and clean light-weight typography.

🏗️ Architecture & Data Flow

 ┌─────────────────────────────────────────────────────────────────────────┐
 │                            CLIENT BROWSER                               │
 │                                                                         │
 │   ┌──────────────────────┐  ┌─────────────────┐  ┌──────────────────┐  │
 │   │ Monaco Code Editor   │  │ VS Code Console │  │ AI Assistant UI  │  │
 │   │ (Syntax & Completion)│  │ (Inline Prompts)│  │ (SSE + Cooldown) │  │
 │   └──────────┬───────────┘  └────────┬────────┘  └────────┬─────────┘  │
 └──────────────┼───────────────────────┼────────────────────┼─────────────┘
                │                       │                    │
                ▼                       ▼                    ▼
 ┌─────────────────────────────────────────────────────────────────────────┐
 │                       DJANGO REST API (VERCEL)                          │
 │                                                                         │
 │   ┌──────────────────────┐  ┌─────────────────┐  ┌──────────────────┐  │
 │   │ /api/run-code        │  │ 7-Msg/Min Shield│  │ /api/auth/*      │  │
 │   │ (Code Execution)     │  │ (Rate Limiter)  │  │ (Stateless HMAC) │  │
 │   └──────────┬───────────┘  └────────┬────────┘  └──────────────────┘  │
 │              │                       ▼                                 │
 │              │              ┌─────────────────┐                        │
 │              │              │ /api/chat-stream│                        │
 │              │              │ (SSE Streaming) │                        │
 │              │              └────────┬────────┘                        │
 └──���───────────┼───────────────────────┼──────────────────────────────────┘
                │                       │
         ┌──────┴──────┐         ┌──────┴──────────────────────────┐
         ▼             ▼         ▼                                 ▼
   ┌──────────┐  ┌──────────┐ ┌──────────────────────┐  ┌──────────────────┐
   │ Judge0   │  │ Base64   │ │ Primary Provider     │  │ Fallback NIM     │
   │ Sandbox  │  │ Engine   │ │ xKiro (Qwen 3.8 Omni)│  │ (Llama 3.1 8B)   │
   └──────────┘  └──────────┘ └──────────────────────┘  └──────────────────┘

🛠️ Tech Stack

Layer Technologies
Frontend Framework Vanilla ES6+ JavaScript, Semantic HTML5, Custom CSS3 Design System
Code Editor Monaco Editor (VS Code core engine)
Backend Framework Django 6.0, Django REST Framework, Python 3.10+
Rate Limiting & Security Sliding-Window IP Throttler (7 msgs/60s via Django Memory Cache)
AI LLM Inference xKiro API (Qwen 3.8 Omni Flash:free), NVIDIA NIM (Llama 3.1 8B)
Code Execution Judge0 CE (Dockerized remote compiler engine)
Streaming Protocol Server-Sent Events (SSE) via StreamingHttpResponse
Authentication Cryptographic HMAC Token Signing (django.core.signing)
Static Assets WhiteNoise Static Asset Compression & Caching
Hosting & CI/CD Vercel Serverless Functions + GitHub Actions Auto-Deploy

⌨️ Productivity Keyboard Shortcuts

Shortcut Action Scope
F5 or Ctrl + Shift + Enter Run Code / Compile Global Editor
Ctrl + S Quick Save Workspace Global Editor
Enter (in terminal) Submit Input Value Active Terminal Prompt
Enter (in chat) Send Message to AI Chat Input Box
Escape Close Any Active Popup / Dropdown Global Window

🚀 Getting Started Locally

📋 Prerequisites


📥 Step 1: Clone the Repository

git clone https://github.com/shubhamjrd4559-sudo/CodeSenseAI.git
cd CodeSenseAI

🐍 Step 2: Set Up Virtual Environment

On Windows (PowerShell / CMD):

python -m venv venv
venv\Scripts\activate

On macOS / Linux:

python3 -m venv venv
source venv/bin/activate

📦 Step 3: Install Dependencies

pip install -r requirements.txt

⚙️ Step 4: Configure Environment Variables

Create a .env file in the root directory:

# Django Settings
DEBUG=True
SECRET_KEY=your-secure-django-secret-key-here

# Primary AI Model (xKiro)
XKIRO_API_KEY=your-xkiro-api-key-here
XKIRO_MODEL=qwen/qwen3.8-omni-flash:free

# Secondary Fallback Model (NVIDIA NIM)
NVIDIA_API_KEY=nvapi-your-nvidia-key-here
LLM_MODEL=meta/llama-3.1-8b-instruct

# Execution Engine (Judge0)
RAPIDAPI_KEY=your-rapidapi-key-here  # Optional if using public endpoint

🏃‍♂️ Step 5: Run Database Migrations & Start Server

python manage.py migrate
python manage.py runserver

Open your browser and navigate to:

http://127.0.0.1:8000

📡 API Reference

1. Execute Code

  • Endpoint: POST /api/run-code/
  • Payload:
{
  "code": "#include <iostream>\nint main() { std::cout << \"Hello World\"; return 0; }",
  "language": "cpp",
  "stdin": ""
}
  • Response:
{
  "success": true,
  "output": "Hello World",
  "exit_code": 0,
  "execution_time": "0.045s",
  "memory": "1420 KB"
}

2. Stream AI Assistant Response

  • Endpoint: POST /api/chat-stream/
  • Headers: Accept: text/event-stream
  • Payload:
{
  "message": "Explain the time complexity of this binary search",
  "code": "def binary_search(arr, x): ...",
  "language": "python"
}
  • Response: Tokens streamed via SSE chunk format (data: {"token": "..."}\n\n).
  • Rate Limit Reached (HTTP 429):
{
  "success": false,
  "error": "⏳ Rate limit reached: 1 minute me maximum 7 messages allow hain. Kripya 22s wait karein!",
  "wait_seconds": 22
}

☁️ Deployment on Vercel

This repository is optimized for deployment on Vercel:

  1. Fork or push your changes to your GitHub repository.
  2. Log in to Vercel and click "Add New Project".
  3. Select CodeSenseAI and set Framework Preset to Other (handled automatically by vercel.json).
  4. In Environment Variables, add:
    • XKIRO_API_KEY: Your xKiro API key
    • SECRET_KEY: A random 50-character string
  5. Click Deploy. Vercel will build and deploy the application in under 60 seconds!

🗺️ Future Roadmap

  • Sliding-Window IP Rate Limiter: 7 messages / 60s abuse shield with live UI cooldown countdown.
  • DSA Pattern Playbook & LeetCode Integration: 75+ top interview questions across 13 topics with direct LeetCode links & full-page dashboard navigation.
  • RAG (Retrieval-Augmented Generation) Pipeline: Integrating vector embeddings (Pinecone) with a curated DSA & algorithmic pattern library for zero-hallucination code reviews.
  • Upstash Redis Caching: Low-latency caching for frequent code queries and cross-region rate limiting.
  • Multi-Tab File Editor: Support simultaneous multi-file workspaces and tabs.
  • Real-Time Collaborative Coding: WebRTC / WebSocket powered peer-to-peer live pair programming.

🤝 Contributing

Contributions are what make the open-source community an incredible place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'feat: Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📝 License

Distributed under the MIT License. See LICENSE for more information.


👨‍💻 Author

Shubham Kumar

(back to top ↑)

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages