This is a full-stack web application that leverages the power of Large Language Models (LLMs) to provide instant code analysis, improvement suggestions, and documentation. Users can paste a code snippet, select the programming language, and receive an AI-generated review. All analyses are saved in a history log for future reference.
-
AI-Powered Analysis: Get an in-depth explanation of your code, a list of actionable improvement suggestions, and a summary of potential bugs.
-
Multi-Language Support: Supports popular languages like Python, JavaScript, TypeScript, Java, and C++.
-
Persistent History: Every analysis is automatically saved to a PostgreSQL database.
-
Modern Tech Stack: Built with a professional-grade stack including Next.js, FastAPI, and Docker.
-
Responsive UI: Clean, user-friendly interface built with Tailwind CSS that works on all devices.
-
Frontend: Next.js, React, TypeScript, Tailwind CSS
-
Backend: Python, FastAPI
-
Database: PostgreSQL
-
AI Integration: Google Gemini API
-
Containerization: Docker & Docker Compose
Follow these steps to get the entire application running on your local machine.
Make sure you have the following installed:
git clone [https://github.com/your-github-username/ai-code-reviewer.git](https://www.google.com/search?q=https://github.com/your-github-username/ai-code-reviewer.git)
cd ai-code-reviewerThe PostgreSQL database runs in a Docker container.
-
Make sure Docker Desktop is running on your machine.
-
In the root directory of the project, run the following command to start the database in the background:
docker-compose up -dThis will start a PostgreSQL server on localhost:5432.
- Navigate to the
backenddirectory:
cd backend- Create and activate a Python virtual environment:
python3 -m venv venv
source venv/bin/activatepython -m venv venv
.\\venv\\Scripts\\activate- Install the required Python libraries:
pip install -r requirements.txt- Create a
.envfile for your environment variables by copying the example file:
cp .env.example .env-
Edit the
.envfile: -
Get your API key from Google AI Studio.
-
Open the
.envfile and add your key. It should look like this:# .env GEMINI_API_KEY=YOUR_API_KEY_HERE DATABASE_URL="postgresql://myuser:mypassword@localhost/ai_reviewer"
- In a new terminal window, navigate to the
frontenddirectory:
cd frontend- Install the required Node.js packages:
npm install
You need to have two terminals running simultaneously: one for the backend and one for the frontend.
-
Terminal 1: Start the Backend
-
Make sure you are in the
backenddirectory with the(venv)activated. -
Run the FastAPI server:
uvicorn main:app --reload
-
The backend will be running at
http://127.0.0.1:8000. -
Terminal 2: Start the Frontend
-
Make sure you are in the
frontenddirectory. -
Run the Next.js development server:
npm run dev
-
The frontend will be running at
http://localhost:3000.
You can now open your browser and navigate to http://localhost:3000 to use the application!
ai-code-reviewer/
├── backend/
│ ├── .env \# Environment variables (API key, DB URL)
│ ├── database.py \# Database connection setup
│ ├── main.py \# FastAPI application and API endpoints
│ ├── models.py \# SQLAlchemy database models
│ └── requirements.txt \# Python dependencies
│
├── frontend/
│ ├── src/app/
│ │ ├── page.tsx \# Main React component for the UI
│ │ └── globals.css \# Global styles
│ └── package.json \# Node.js dependencies
│
├── .gitignore
├── docker-compose.yml \# Docker configuration for the database
└── README.md \# This file
-
POST /api/analyze: Receives code and language, returns AI analysis, and saves to history. -
GET /api/history: Returns a list of all past analyses from the database.