Skip to content

workforyou786/Code-Reviewer-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Reviewer API (FastAPI)

An extensible API that reviews source code for bugs, smells, style issues, and complexity. It combines static analysis (AST + Radon) with optional LLM feedback.

Works offline for static checks. If you set OPENAI_API_KEY or connect to an Ollama model, you'll also get AI feedback.

Features

  • 🚦 POST /review accepts code & language (Python supported in v1)
  • 🧠 Static findings: syntax errors, complexity, maintainability, common pitfalls
  • 🧩 Optional LLM feedback (OpenAI or local Ollama) via adapters
  • 📊 Rich, structured JSON with severities and line numbers
  • 🐳 Dockerized + uvicorn for production
  • ✅ Tests included (pytest)

Quickstart (macOS/Linux)

# 1) Create a venv and install deps
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

# 2) Run the API
uvicorn app.main:app --reload

# 3) Open docs
# http://127.0.0.1:8000/docs

With Docker

docker build -t code-reviewer-api .
docker run -p 8000:8000 --env-file .env code-reviewer-api

Environment (optional for LLM)

Copy .env.example to .env and fill as needed:

OPENAI_API_KEY=sk-...
OPENAI_MODEL=gpt-4o-mini
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=codellama:7b

Example request

curl -X POST http://127.0.0.1:8000/review \  -H "Content-Type: application/json" \  -d @- <<'JSON'
{
  "language": "python",
  "code": "def foo(x=[]):\n  try:\n    print('hi')\n  except:\n    pass\n  return 1"
}
JSON

Project layout

code-reviewer-api/
├── app/
│   ├── main.py
│   ├── config.py
│   ├── schemas.py
│   ├── services/
│   │   └── aggregator.py
│   └── review_engine/
│       ├── __init__.py
│       ├── static_checks.py
│       ├── llm_checks.py
│       └── helpers.py
├── sample_code/
│   └── bad.py
├── tests/
│   ├── test_health.py
│   └── test_review.py
├── requirements.txt
├── Dockerfile
├── Makefile
├── .env.example
└── README.md

Notes

  • The static analyzer currently supports Python. The design is language-pluggable.
  • You can extend review_engine/static_checks.py and helpers.py for new rules.
  • LLM adapters are optional and never send code unless you configure them.

About

Created a new Api using FastAPI and Integrated with OpenAI API Key

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors