Skip to content

Latest commit

 

History

History
300 lines (222 loc) · 10.8 KB

File metadata and controls

300 lines (222 loc) · 10.8 KB

🔍 INSPECTOR

AI Code Review Agent — Multi-Dimensional Audit With Live Scan UI

Python FastAPI React NVIDIA CI License: MIT


INSPECTOR is a production-grade AI Code Review Agent. Paste any code snippet, run one intelligent scan, and get structured extraction for security vulnerabilities, performance bottlenecks, code quality issues, best practice violations, and improvement suggestions — all rendered in a premium "Dark Hacker" dashboard with real-time progress and actionable fixes.


Audit Realtime Hardened Performance


📋 Table of Contents


🧠 Overview

INSPECTOR focuses on a critical engineering workflow: high-fidelity code reviews. The backend leverages NVIDIA NIM (Llama-3.1-405B) to run five simultaneous analysis passes, identifying risks and suggesting modern refactors with surgical precision.

Users can:

  • Paste code into a professional Monaco Editor and watch live scan stages
  • Extract structured findings (security, performance, quality, best_practices, suggestions)
  • Review a dynamic Quality Score Gauge and grading system (A-F)
  • Copy exact code fixes directly for downstream implementation
  • Experience a "Dark Hacker" aesthetic with Matrix rain and scan beam animations

🖼️ Application Preview

Demo Reel (Live Flow)

Demo


1) Editor & Landing Page

Dashboard


2) Live Scan Progress

Scanning


3) Multi-Dimensional Findings

Issues


4) Actionable Fixes

Fixes


✨ Features

Feature Description
🔍 Multi-Dimensional Audit Simultaneous scans for Security, Performance, Quality, and Best Practices
🚀 NVIDIA NIM Powered Leverages Llama-3.1-405B for senior-engineer level reasoning and fixes
🔴 Live Progress Stream WebSocket-driven progress events showing exactly what the AI is analyzing
🛠️ Monaco Editor Integration Full VSCode-grade editing experience with syntax highlighting and line numbers
📊 Dynamic Score Gauge Real-time quality scoring and grading based on cumulative issue severity
💡 Actionable Code Fixes Every issue includes a detailed explanation and a ready-to-copy fixed code snippet
🎨 Premium Hacker UI High-end dark theme with Matrix rain and animated scan beam overlays
⏱️ Parallel Execution All review dimensions are scanned in parallel via asyncio.gather for max speed

🏗️ Architecture

┌───────────────────────────────────────────────────────────────────┐
│                        React Inspector UI                         │
│                                                                   │
│  Monaco Editor ──► Scan Controls ──► Issue Dashboard (Cards)      │
│      │              │                    │                        │
│      └────── POST /review + WS /ws ◄─────┘                        │
│                                                                   │
└──────────────────────────────┬────────────────────────────────────┘
                               │
                               ▼
┌───────────────────────────────────────────────────────────────────┐
│                          FastAPI Backend                          │
│                                                                   │
│  Middleware: CORS + Request-ID Logging + Scoped WS Management     │
│                                                                   │
│  /review ─► review_agent.py  ─► asyncio.gather()                  │
│                                  ├► security_scan                 │
│                                  ├► performance_scan              │
│                                  ├► quality_scan                  │
│                                  └► nvidia_service.py             │
│                                                                   │
│  /ws     ─► client-scoped progress events (UUID routed)           │
└───────────────────────────────────────────────────────────────────┘

🛠️ Tech Stack

Layer Technology
Backend FastAPI, Pydantic, Uvicorn, Python 3.11+
AI Provider NVIDIA NIM (Llama-3.1-405B)
Editor Engine Monaco Editor (@monaco-editor/react)
Frontend React 18, Vite, Framer Motion, Axios
Transport REST + WebSocket
Styling Vanilla CSS (JetBrains Mono)

📁 Project Structure

inspector-agent/
│
├── backend/
│   ├── main.py                    # FastAPI routes + scoped WS + middleware
│   ├── review_agent.py            # Parallelized AI scan orchestration
│   ├── nvidia_service.py          # NVIDIA NIM (OpenAI-compatible) integration
│   ├── code_analyzer.py           # Language detection + metrics logic
│   ├── requirements.txt
│   └── .env.example
│
├── frontend/
│   ├── src/
│   │   ├── components/            # Monaco Editor, Gauge, Cards, Matrix Rain
│   │   ├── pages/
│   │   │   └── ReviewPage.jsx     # Main Split Dashboard Layout
│   │   ├── hooks/
│   │   │   └── useReview.js       # UUID-scoped WS + API state management
│   │   ├── styles/
│   │   │   └── globals.css        # Premium Hacker styling tokens
│   │   └── App.jsx
│   ├── package.json
│   └── vite.config.js
│
├── .github/workflows/deploy.yml   # GitHub Pages deployment automation
├── LICENSE
└── README.md

🚀 Installation

1) Clone

git clone https://github.com/crastatelvin/inspector-agent.git
cd inspector-agent

2) Backend

cd backend
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
copy .env.example .env
# Configure NVIDIA_API_KEY in .env
python main.py

3) Frontend

cd frontend
npm install
npm run dev

💻 Usage

  1. Open the dashboard and paste your target code into the Monaco Editor
  2. Watch the scan progress in real time via the status console
  3. Review extracted findings across tabs:
    • SUMMARY
    • CRITICAL / HIGH / MEDIUM
    • SECURITY / PERF / QUALITY
  4. Expand any issue card to view the PROPOSED FIX
  5. Click the copy icon to apply the fix to your source code

Quick health check:

curl -X GET http://localhost:8000/

📡 API Reference

Method Endpoint Description
GET / Service health and version info
POST /review/{client_id} Initiate parallelized code audit
WS /ws/{client_id} Client-scoped progress event stream

⚙️ Configuration

backend/.env:

NVIDIA_API_KEY=nvapi-...

frontend/src/hooks/useReview.js:

const BASE_URL = 'http://localhost:8000';
const WS_BASE_URL = 'ws://localhost:8000/ws';

🧪 Testing & CI

Backend:

cd backend
# Run functional tests for the parser and AI logic
python -m pytest

Frontend:

cd frontend
# Verify build integrity
npm run build

🔒 Security Notes

  • Scoped WebSockets: Progress updates are isolated per UUID client_id to prevent cross-session log leaking.
  • Environment Isolation: API keys are restricted to the backend and never exposed to the client.
  • Input Validation: Backend enforces code size limits and validates language patterns before AI submission.

🧭 Design Decisions

  • Parallelised Scans: Using asyncio.gather for five simultaneous passes ensures deep-surgical detail without the latency of sequential calls.
  • Monaco Engine: Professional syntax highlighting and line numbers are essential for the "Senior Engineer" UX.
  • UUID Routing: Ensures real-time logs are accurately delivered to the initiating user in a multi-user environment.

License

This project is licensed under the MIT License.

Built by Telvin Crasta · Powered by NVIDIA NIM · Production Ready

⭐ If INSPECTOR helped you ship cleaner code, star the repo.