Enterprise-Grade Static Analysis & AI-Powered Refactoring
AI Code Reviewer is a production-grade Streamlit application combining deterministic Python static analysis with advanced AI semantic reviews powered by GitHub Models.
| 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 |
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]
βββ 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
- Python 3.10+ (Tested on 3.10-3.12)
- GitHub Account (For GitHub Models API)
git clone https://github.com/kashifraza01/AI-Code-Reviewer.git
cd AI-Code-Reviewerpython -m venv .venv
source .venv/bin/activate # Windows: .\.venv\Scripts\activatepip install -r requirements.txtThis application uses GitHub Models for AI inference. You need a GitHub Personal Access Token (PAT).
- Go to GitHub Developer Settings and generate a classic token.
- Create a
.envfile in the root directory:GITHUB_TOKEN=ghp_your_token_here
streamlit run app.py- Submit Code: Paste your Python code or upload a
.pyfile up to 2MB. - Review Options: The app automatically detects Python and runs the Static Analysis engine.
- AI Enhancement: Click Review Code. The app will stream code to GitHub Models for a semantic review.
- 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.
- Export: Click Download PDF Report to save a localized copy of your audit.
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:
Dependabotis active and updates are applied automatically. - Static Analysis: The tool itself runs
banditto ensure no malicious code executes during the evaluation phase.
- 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.
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.
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.
This project is licensed under the MIT License - see the LICENSE file for details.
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.

