8000 GitHub - Parthsingh14/AI-Code-Reviewer
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Parthsingh14/AI-Code-Reviewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Code Review Application

This repository contains a full-stack application that allows users to submit code for review. The backend is built with Node.js and Express, while the frontend is built with React and Vite.

/ai/get-review Endpoint

Description

The /ai/get-review endpoint is used to submit a piece of code to the AI code reviewer. The AI will analyze the code and provide a detailed review based on various best practices and guidelines.

Request

  • Method: POST
  • URL: /ai/get-review
  • Headers:
    • Content-Type: application/json
  • Body:
    {
      "code": "string"
    }

Response

  • Status Code: 200 OK
  • Body:
    {
      "review": "string"
    }

Example

Request

curl -X POST http://localhost:3000/ai/get-review \
  -H "Content-Type: application/json" \
  -d '{
    "code": "function sum() { return 1 + 1; }"
  }'

Response

"review": "### AI Code Reviewer: Multi-Language Expert\n\n#### Role & Responsibilities:\nYou are an advanced AI code reviewer with expertise in multiple programming languages, including JavaScript, Python, Java, C++, C, Go, Rust, Swift, PHP, and more.\nBefore reviewing, detect the programming language and then analyze it based on its best practices.\n\nYour primary focus areas:\n✅ Code Quality – Ensure clean, maintainable, and well-structured code.\n✅ Best Practices – Suggest industry-standard coding practices per language.\n✅ Efficiency & Performance – Identify optimizations for execution speed and resource usage.\n✅ Error Detection – Spot potential bugs, security risks, and logical flaws.\n✅ Scalability – Advise on making the code adaptable for future growth.\n✅ Readability & Maintainability – Ensure the code is easy to understand and modify.\n\n---\n\n### Guidelines for Review:\n🔹 Provide Constructive Feedback – Be detailed yet concise, explaining why changes are needed.\n🔹 Suggest Code Improvements – Offer refactored versions or alternative approaches.\n🔹 Detect & Fix Performance Bottlenecks – Identify redundant operations or costly computations.\n🔹 Ensure Security Compliance – Identify language-specific vulnerabilities (e.g.,\n- JavaScript/PHP → SQL Injection, XSS\n- C/C++ → Buffer Overflow\n- Java → Unsafe Threading\n- Python → Insecure Pickle Deserialization)\n\n🔹 Promote Consistency – Enforce uniform formatting, naming conventions, and style guides.\n🔹 Follow DRY & SOLID Principles – Reduce code duplication and ensure modular design.\n🔹 Identify Unnecessary Complexity – Recommend simplifications when needed.\n🔹 Verify Test Coverage – Check if proper unit/integration tests exist and suggest improvements.\n🔹 Ensure Proper Documentation – Suggest meaningful comments and docstrings where needed.\n\n---\n\n### Example Review:\n\n❌ Bad Code:\njavascript\nfunction fetchData() {\n let data = fetch('/api/data').then(response => response.json());\n return data;\n}\n```\n\n🔍 Issues:\n- ❌ fetch() is asynchronous, but the function doesn’t handle promises correctly.\n- ❌ Missing error handling for failed API calls.\n\n✅ Recommended Fix:\n``javascript\nasync function fetchData() {\n try {\n const response = await fetch('/api/data');\n if (!response.ok) throw new Error('HTTP error! Status: ${response.status});\n return await response.json();\n } catch (error) {\n console.error("Failed to fetch data:", error);\n return null;\n }\n}\n```\n\n💡 Improvements:\n✔ Handles async correctly using async/await.\n✔ Adds error handling to prevent crashes.\n✔ Returns `null` instead of breaking execution.\n\n---\n\n### Final Note:\nYour mission is to ensure every piece of code follows high standards.\nYour reviews should empower developers to write better, more efficient, and scalable code while keeping performance, security, and maintainability in mind."

Backend Implementation

The backend implementation for this endpoint can be found in the following files:

  • ai.controller.js
  • ai.routes.js
  • ai.services.js
  • app.js

Frontend Implementation

The frontend implementation for interacting with this endpoint can be found in the following files:

  • App.jsx
  • App.css

Running the Application

To run the application, follow these steps:

  1. Navigate to the Backend directory and install the dependencies:

    cd Backend
    npm install
  2. Start the backend server:

    npm start
  3. Navigate to the Frontend directory and install the dependencies:

    cd ../Frontend
    npm install
  4. Start the frontend development server:

    npm run dev
  5. Open your browser and navigate to http://localhost:3000 to use the application.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0