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.
- ** 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.
- Frontend: React 18, Vite, Vanilla Glassmorphism UI
- Backend: Python, FastAPI, PyGithub
- AI & Algorithms: Python AST matching, Regex, Groq API (Llama 3.3 70B)
- GitHub Integration: Fetches raw code from the provided repository or PR URL via the PyGithub API.
- Static Analysis Engine: A custom Python ruleset runs over the source code (using AST/Regex) to extract structured metrics and flags.
- LLM Enhancement: Identified issues are batched and sent to Groq API to deduce contextual context, write fix suggestions, and rate severity.
- Report Generation: The frontend renders a comprehensive, filterable report UI dynamically.
- Python 3.9+
- Node.js 18+
- GitHub Personal Access Token (needs
reposcope) - Groq API Key
# 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.txtCreate a .env file in the backend folder:
cp .env.example .envEdit 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=8000Run the backend server:
python main.pyThe API will run on http://localhost:8000
Open a new terminal and navigate to the frontend folder:
cd frontend
# Install dependencies
npm install
# Start the development server
npm run devThe frontend app will be available at http://localhost:5173
- Open the Dashboard: Navigate to
http://localhost:5173. - Enter a Target: Paste a GitHub repository URL (e.g.,
https://github.com/pallets/flask) or a specific Pull Request URL. - Analyze: Click "Analyze Code" and let the engine scan the repository.
- Review: Check out the generated report containing an intuitive metrics overview, filterable issue list, and AI-suggested code fixes.
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": { ... }
}Check API health status.
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
- 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
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.
Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request.
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.