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

https://github.com/soumyadeep6845/code-review-assistant-backend

The AI-Based Code Review Assistant allows users to submit code, which is then analyzed by an AI model (like OpenAI’s GPT) for suggestions, optimizations, and best practices. Users can retrieve past reviews and insights from the system.
https://github.com/soumyadeep6845/code-review-assistant-backend

ai contribute contributions-welcome docker good-first-issue gpt-4 gradle java jwt mysql openai opensource spring spring-boot

Last synced: 2 months ago
JSON representation

The AI-Based Code Review Assistant allows users to submit code, which is then analyzed by an AI model (like OpenAI’s GPT) for suggestions, optimizations, and best practices. Users can retrieve past reviews and insights from the system.

Awesome Lists containing this project

README

          

AI Code Review Assistant



Logo

## πŸš€ Overview
This is the **backend** of the Code Review Assistant, a powerful AI-driven system designed to analyze code snippets and provide intelligent feedback. The backend handles API requests, communicates with OpenAI's GPT models, caches responses using Redis, and stores submission data securely.

## πŸ›  Tech Stack
- **Language:** Java (v17)
- **Framework:** Spring Boot
- **Database:** MySQL
- **API Communication:** REST (Spring MVC)
- **API Documentation:** Swagger (v3)
- **Build Tool:** Gradle
- **Security:** Spring Security
- **Authentication:** JWT (custom, with encryption)
- **Logging:** SLF4j
- **Cache Layer:** Redis
- **Unit Test:** JUnit, Mockito
- **Containerization:** Docker

## πŸ“Έ Application Screenshots

### πŸ”Ή Authentication Page
![Auth](./assets/auth.png)

### πŸ”Ή Home Page
![Home](./assets/homescreen.png)

### πŸ”Ή About Page
![About](./assets/about.png)

### πŸ”Ή Code Review in Action
![Review](./assets/codereview.png)
![Feedback](./assets/codefeedback.png)

### πŸ”Ή API Documentation (Swagger)
![Swagger](./assets/swaggerscreen.png)

### πŸ”Ή Contact Page
![Contact](./assets/contactscreen.png)

### πŸ”Ή MySQL Database (SQLYog)
![Database](./assets/database.png)

### πŸ”Ή Local Cache (Redis)
![Redis](./assets/redislocalcache.png)

### πŸ”Ή Containerization (Docker) - Backend
![Docker](./assets/dockerbackend.png)

---

## πŸ“¦ Installation & Setup

### Prerequisites
- Java 17
- MySQL
- Redis
- Gradle
- Docker
- Docker Compose

### 1️⃣ Clone the Repository
```sh
git clone https://github.com/your-username/code-review-assistant-backend.git
cd code-review-assistant-backend
```

### 2️⃣ Set Up Environment Secrets

Create a `secrets.properties` file in the **root directory** of your backend project:

```properties
openai.api.key=
jwt.secret=
```

#### πŸ”‘ Generate OpenAI API Key

Generate your OpenAI API key from the [OpenAI website](https://platform.openai.com/).
Copy the output and use it as the **openai.api.key** value in your `secrets.properties` file.

#### πŸ” Generate JWT Secret

To generate a secure JWT secret, open **Windows PowerShell as Administrator** and run the following command:

```powershell
[Convert]::ToBase64String((1..32 | ForEach-Object {Get-Random -Maximum 256}))
```
Copy the output and use it as the **jwt.secret** value in your `secrets.properties` file.

### 3️⃣ Start the Backend (using Docker Compose)

```sh
docker-compose up --build
```
> Note: Starting Redis server and MySQL database separately, is not required. It has already been integrated.
> If still required, run:
> ```
> docker run --name mysql-container -e MYSQL_ROOT_PASSWORD=yourpassword -e MYSQL_DATABASE=code_review -p 3306:3306 -d mysql:latest
> docker run --name redis-container -p 6379:6379 -d redis
> ```
The backend will now be running on **http://localhost:8080**.

---

## πŸ“Œ Features

βœ… AI-based code analysis using GPT-4o
βœ… Caching of responses using Redis
βœ… RESTful API for frontend communication
βœ… Secure authentication & authorization with JWT
βœ… MySQL database integration
βœ… Containerized using Docker

---

## πŸ“‚ Folder Structure

```
code-review-assistant-backend/
β”‚-- personal/
β”‚ β”‚-- src/
β”‚ β”‚ β”œβ”€β”€ main/
β”‚ β”‚ β”‚ β”œβ”€β”€ java/com/example/personal/
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ config/ # Configurations
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ controllers/ # API Controllers
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ models/ # Data Models
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ repositories/ # Database Repositories
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ security/ # Security Configuration
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ services/ # Business Logic Services
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ util/ # Helpers & Utilities
β”‚ β”‚ β”‚ β”œβ”€β”€ resources/
β”‚ β”‚ β”‚ β”œβ”€β”€ application.properties # Application Configuration
β”‚ β”‚ β”œβ”€β”€ test/ # Unit & Integration Tests
β”‚ β”‚-- build.gradle # Gradle Build Configuration
β”‚ β”‚-- Dockerfile # Docker Configuration
β”‚ β”‚-- docker-compose.yml # Docker Compose Configuration
β”‚ β”‚-- secrets.properties # Key Secrets (to be created separately)
β”‚-- README.md
```

---

## πŸ“œ API Endpoints

### πŸ” Authentication Endpoints (`/auth`)
| Method | Endpoint | Description |
|--------|------------------|---------------------------------------------|
| POST | `/auth/register` | Registers a new user |
| POST | `/auth/login` | Authenticates a user and returns JWT token |
| GET | `/auth/verify` | Verifies the provided JWT token |

### πŸ€– Code Review Endpoints (`/api/code-review`)
| Method | Endpoint | Description |
|--------|---------------------------|--------------------------------------|
| POST | `/api/code-review/submit` | Submits code for AI-based review |

---

## πŸ“Œ Deployment

### Build Docker Image

```sh
docker build -t code-review-backend .
docker run -p 8080:8080 code-review-backend
```
> *ℹ️ For local development with Redis and MySQL, it’s recommended to use docker-compose for convenience.*

---

## 🎯 Contribution

If you'd like to contribute, feel free to **fork** the repository, create a **new branch**, and raise a **pull request** with changes you deem necessary!

## πŸ’š Found this project interesting?

If you found this project useful, then please consider leaving a ⭐ on [GitHub](https://github.com/soumyadeep6845/code-review-assistant-backend). Thank you! πŸ˜„

## πŸ‘¨ Project Maintained By

[Soumyadeep Das](https://www.linkedin.com/in/soumya0021/)