An open API service indexing awesome lists of open source software.

https://github.com/monarch1108/ai_code_reviewer

GenAI - AI Code Reviewer analyzes Python code using Gemini AI, detects bugs, suggests fixes, and provides improved code snippets via Streamlit.
https://github.com/monarch1108/ai_code_reviewer

gemini-api generative-ai streamlit

Last synced: about 2 months ago
JSON representation

GenAI - AI Code Reviewer analyzes Python code using Gemini AI, detects bugs, suggests fixes, and provides improved code snippets via Streamlit.

Awesome Lists containing this project

README

          

# ๐Ÿง  AI Code Reviewer

A web-based AI-powered tool that reviews Python code, detects bugs, suggests improvements, and generates human-friendly documentation using language models.

---
### Documentation : https://medium.com/@abhayemani8/ai-code-reviewer-documentation-0a17280adcfd
![image](https://github.com/user-attachments/assets/16ccb5e8-3fb7-43e8-8c26-77b91fc0cb5e)

## ๐Ÿ“Œ Overview

This project demonstrates the evolution of a code reviewer app through two versions:

- **Version 1**: Built with guidance from ChatGPT and tutorials. It uses Google's Gemini API and Streamlit for quick prototyping.
- **Version 2**: Fully self-written using Flask and a local Ollama LLM (`llama3.2`) for offline, more customizable AI processing.

---

## ๐Ÿงพ Table of Contents

- [Project Structure](#file-structure)
- [Version Highlights](#version-highlights)
- [Tech Stack](#tech-stack)
- [Setup & Installation](#setup--installation)
- [How to Run](#how-to-run)
- [Learnings & Evolution](#learnings--evolution)
- [Screenshots](#screenshots) *(optional)*
- [License](#license)

---

## ๐Ÿ“ File Structure

```bash
.
โ”œโ”€โ”€ version_1/ # Streamlit + Gemini API version
โ”‚ โ”œโ”€โ”€ app.py
โ”‚ โ””โ”€โ”€ .env (Google API key)
โ”‚
โ”œโ”€โ”€ version_2/ # Flask + Ollama + Llama3.2 version
โ”‚ โ”œโ”€โ”€ app.py
โ”‚ โ”œโ”€โ”€ templates/
โ”‚ โ”‚ โ””โ”€โ”€ index.html
โ”‚ โ””โ”€โ”€ utils/
โ”‚ โ””โ”€โ”€ functions.py
โ”‚
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ requirements.txt # Optional, depending on environment
```

## โœจ Version Highlights

### ๐Ÿ”น Version 1 (Assisted Build)

- Built using **Streamlit** for fast UI.

- Uses **Google Gemini API** via `google.generativeai`.

- Offers simple input/output layout for quick feedback.

### ๐Ÿ”ธ Version 2 (Self-Built)

- Built using **Flask** from scratch.

- Implements **Ollama** with a **locally running `llama3.2` model**.

- Enhanced prompt engineering for better review quality.

- Beautiful **custom HTML/CSS UI** for better user experience.

- Contains robust instructions for context filtering (code-only reviews).

|Area|Tools Used|
|---|---|
|Frontend|Streamlit (v1), HTML/CSS (v2)|
|Backend|Python, Flask|
|LLM|Google Gemini API (v1), Ollama LLM (`llama3.2`) (v2)|
|Environment|dotenv (`.env`), virtualenv|

## โš™๏ธ Setup & Installation

### ๐Ÿงช Version 1
```bash
cd version_1
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install streamlit google.generativeai
```

# Set your Google API Key in .env
```bash
echo GOOGLE_API_KEY=your_key_here > .env

streamlit run app.py
```

### ๐Ÿ› ๏ธ Version 2
```bash
cd version_2
python -m venv venv
source venv/bin/activate
pip install flask ollama

# Make sure Ollama is installed and running
ollama run llama3.2

python app.py
```

## ๐Ÿง  Learnings & Evolution
### Version 1
- taught me the basics of API calls, prompt structuring, and how to quickly prototype with Streamlit.

### Version 2
- was my full-stack build using Flask, local LLMs, and custom UI โ€” improving my understanding of backend routing, HTML templating, and deploying AI models locally.

- Implemented stricter prompt rules and better error handling in v2.