Skip to content

Repository files navigation

AI Code Reviewer

Python React FastAPI Groq License: MIT

An intelligent, two-stage code review tool that analyzes GitHub repositories and pull requests. It uses custom Python static analysis for deterministic issue detection and Groq API (Llama 3.3) for deeper contextual reasoning, generating actionable fixes and severity ratings.

Features

  • ** Two-Stage Pipeline**: Combines the precision of AST-based static analysis with the intelligence of LLMs.
  • ** Security Analysis**: Spots hardcoded secrets, SQL injection vulnerabilities, and dangerous function usages (eval(), exec()).
  • ** Performance Review**: Flags nested loops, synchronous I/O in async functions, and inefficient iterations.
  • ** Code Quality Checks**: Enforces clean code constraints (e.g., missing docstrings, deep nesting, high cyclomatic complexity).
  • ** LLM Enhancement**: Groq API provides plain-English explanations, assigns 1-5 severity scale ratings, and generates direct fix snippets.

🏗️ Architecture Stack

  • Frontend: React 18, Vite, Vanilla Glassmorphism UI
  • Backend: Python, FastAPI, PyGithub
  • AI & Algorithms: Python AST matching, Regex, Groq API (Llama 3.3 70B)

How it Works

  1. GitHub Integration: Fetches raw code from the provided repository or PR URL via the PyGithub API.
  2. Static Analysis Engine: A custom Python ruleset runs over the source code (using AST/Regex) to extract structured metrics and flags.
  3. LLM Enhancement: Identified issues are batched and sent to Groq API to deduce contextual context, write fix suggestions, and rate severity.
  4. Report Generation: The frontend renders a comprehensive, filterable report UI dynamically.

Getting Started

Prerequisites

1. Backend Setup

# Clone the repository
git clone <your-repo-url>
cd AI-Code-Reviewer

# Set up Python virtual environment
cd backend
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
# source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

Create a .env file in the backend folder:

cp .env.example .env

Edit the .env file with your credentials:

GITHUB_TOKEN=ghp_your_github_token
GROQ_API_KEY=gsk_your_groq_api_key
GROQ_MODEL=llama-3.3-70b-versatile
PORT=8000

Run the backend server:

python main.py

The API will run on http://localhost:8000

2. Frontend Setup

Open a new terminal and navigate to the frontend folder:

cd frontend

# Install dependencies
npm install

# Start the development server
npm run dev

The frontend app will be available at http://localhost:5173

Usage

  1. Open the Dashboard: Navigate to http://localhost:5173.
  2. Enter a Target: Paste a GitHub repository URL (e.g., https://github.com/pallets/flask) or a specific Pull Request URL.
  3. Analyze: Click "Analyze Code" and let the engine scan the repository.
  4. Review: Check out the generated report containing an intuitive metrics overview, filterable issue list, and AI-suggested code fixes.

API Reference

POST /api/review

Triggers the full review process on a repository or PR.

Request Body:

{
  "url": "https://github.com/owner/repo"
}

Success Response:

{
  "repo_url": "https://github.com/owner/repo",
  "total_issues": 1,
  "findings": [
    {
      "file": "utils.py",
      "line": 42,
      "issue": "Use of eval() detected",
      "category": "Security",
      "code_snippet": "eval(user_input)",
      "explanation": "Using eval() on user input can lead to arbitrary code execution.",
      "suggested_fix": "Use ast.literal_eval() instead...",
      "severity": 5
    }
  ],
  "stats": { ... }
}

GET /api/health

Check API health status.

📂 Project Structure

AI-Code-Reviewer/
├── backend/                  # FastAPI Application
│   ├── analyzer/             # Static Analysis Engine
│   │   ├── models.py
│   │   ├── security_rules.py
│   │   ├── performance_rules.py
│   │   └── code_quality_rules.py
│   ├── github_service.py     # GitHub API Wrapper
│   ├── llm_reviewer.py       # OpenAI GPT-4 Integration
│   ├── report_generator.py   # Report Creation
│   └── main.py               # API Endpoints
└── frontend/                 # React Application
    ├── src/
    │   ├── components/       # Reusable UI Elements (IssueCard, StatsOverview, etc.)
    │   ├── pages/            # Home & Report Views
    │   └── services/         # API Client
    ├── package.json
    └── index.html

🔮 Future Enhancements (Roadmap)

  • Automated GitHub PR comment bot integration
  • Exportable PDF & Markdown reports
  • Overall code health scoring system (0-100)
  • Support for JavaScript, TypeScript, and Java static analysis
  • Custom rule configuration formats
  • User authentication and historical report saving

📜 Resume Line

Built an AI-powered code reviewer that analyzes GitHub repositories and pull requests using static analysis and LLM reasoning to detect security, performance, and code-quality issues.

Implemented a two-stage analysis pipeline with a custom Python static analyzer (AST parsing + regex) and OpenAI GPT-4 enhancement. Architected FastAPI backend with GitHub API integration and premium React frontend. Detects 15+ issue types including SQL injection, hardcoded secrets, nested loops, and missing docstrings.

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request.

📄 License

This project is provided under the MIT License - feel free to use it for your portfolio!


Built with React, FastAPI, AST Analysis, and GPT-4.

Releases

Packages

Contributors

Languages