Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Code Reviewer Demo

πŸš€ AI Code Reviewer & Mentor

Enterprise-Grade Static Analysis & AI-Powered Refactoring

Ruff Code style: black Mypy Streamlit GitHub Models License: MIT

AI Code Reviewer is a production-grade Streamlit application combining deterministic Python static analysis with advanced AI semantic reviews powered by GitHub Models.


✨ Features

Feature Description Technology
Deterministic Static Analysis Instant checks for syntax, complexity (Cyclomatic), style, naming conventions, and code duplication. ast, pylint, radon
Security Scanning Static application security testing (SAST) to identify hardcoded secrets and SQL injections. bandit
AI Semantic Review Deep context-aware code reviews, bug detection, and automated refactoring suggestions. GitHub Models (GPT-4o)
Interactive Mentor Chat Chat with an AI mentor about your code, ask for explanations, or request specific improvements. Prompt Engineering
Beautiful Reports Generate professional, shareable PDF and JSON reports summarizing all findings and code grades. fpdf2
100% Privacy No code is stored. Optional local environment variables ensure no data leaks. Streamlit Session State

πŸ“Έ Screenshots

Main UI Security Report

πŸ—οΈ Architecture

graph TD
    A["User Input (Upload/Paste)"] --> B(Static Analysis Engine)
    B --> C{Analyzer Modules}
    C -->|Security| C1[Bandit]
    C -->|Complexity| C2["Radon/AST"]
    C -->|Style| C3["Pylint/Black"]

    A --> D(AI Review Engine)
    D --> E[GitHub Models API]

    C --> F(Report Aggregator)
    E --> F

    F --> G[Interactive Streamlit UI]
    F --> H[PDF/JSON Export]
Loading

πŸ“ Folder Structure

β”œβ”€β”€ ai/                 # AI backend interfaces (GitHubModelsProvider)
β”œβ”€β”€ analyzer/           # Static analysis engines (complexity, security, style)
β”œβ”€β”€ assets/             # Static assets, CSS, screenshots
β”œβ”€β”€ models/             # Shared dataclasses and types
β”œβ”€β”€ reports/            # PDF and JSON generation logic
β”œβ”€β”€ storage/            # SQLite history repository
β”œβ”€β”€ tests/              # 100% test coverage suite
└── app.py              # Streamlit entry point

πŸš€ Installation & Setup

Prerequisites

  • Python 3.10+ (Tested on 3.10-3.12)
  • GitHub Account (For GitHub Models API)

1. Clone the repository

git clone https://github.com/kashifraza01/AI-Code-Reviewer.git
cd AI-Code-Reviewer

2. Set up virtual environment

python -m venv .venv
source .venv/bin/activate  # Windows: .\.venv\Scripts\activate

3. Install dependencies

pip install -r requirements.txt

4. Configuration (GitHub Models)

This application uses GitHub Models for AI inference. You need a GitHub Personal Access Token (PAT).

  1. Go to GitHub Developer Settings and generate a classic token.
  2. Create a .env file in the root directory:
    GITHUB_TOKEN=ghp_your_token_here

5. Run the Application

streamlit run app.py

πŸ“– Usage Guide

  1. Submit Code: Paste your Python code or upload a .py file up to 2MB.
  2. Review Options: The app automatically detects Python and runs the Static Analysis engine.
  3. AI Enhancement: Click Review Code. The app will stream code to GitHub Models for a semantic review.
  4. Analyze Findings:
    • Check the Overview tab for a final grade out of 100.
    • Read the Bugs & Syntax tab for AI-detected logic errors.
    • Interact with the Mentor Chat tab to ask clarifying questions.
  5. Export: Click Download PDF Report to save a localized copy of your audit.

πŸ›‘οΈ Security

We take code security seriously.

  • No Data Retention: Code is evaluated in-memory and discarded. History is stored locally in SQLite (reviews.db).
  • Dependency Scanning: Dependabot is active and updates are applied automatically.
  • Static Analysis: The tool itself runs bandit to ensure no malicious code executes during the evaluation phase.

⚑ Performance

  • Static Analysis: Near-instant execution (sub-100ms).
  • AI Analysis: P95 latency of ~4 seconds depending on GitHub Models API conditions.
  • Footprint: Extremely lightweight. UI runs smoothly on 512MB RAM cloud instances.

❓ FAQ

Q: Do I need an OpenAI API key? No. This repository has been fully upgraded to leverage GitHub Models, providing enterprise-level inference (GPT-4o) directly through your GitHub Token.

Q: Can I run this offline? The static analysis modules run entirely offline. The AI semantic review requires an internet connection to reach GitHub Models.


🀝 Contributing

We welcome contributions! Please see our CONTRIBUTING.md for details on how to set up the development environment, run the test suite, and submit Pull Requests.


πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘¨β€πŸ’» Credits

Architected and developed by Kashif Raza.

If you found this tool helpful, please give the repository a ⭐ on GitHub!


Built with ❀️ for the open-source community.

About

Enterprise-Grade Static Analysis & AI-Powered Refactoring using GitHub Models.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages