Skip to content

rcosta358/cf_ai_code_reviewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Code Reviewer

Lightweight AI code review application powered by Cloudflare Workers AI

Cloudflare Workers LLM License

Demo


This project was implemented for the Software Engineering Internship assignment, built with Codex using GPT-5.5 (Medium). The prompts used can be found in PROMPTS.md.

Features

  • Structured AI code review with actionable feedback
  • Covers multiple aspects of code quality (correctness, security, maintainability, performance, style, documentation, and other)
  • Each issue is annotated with an explanation, suggestion, severity, confidence level, and source code position
  • Overall rating and summary of the review
  • Persistent review storage
  • Follow-up chat for follow-up questions and iterative review

Workflow

  1. User submits code
  2. Backend sends code and system prompt to the LLM
  3. LLM returns structured review in a JSON schema
  4. Review is stored and displayed
  5. User can use the chat to ask follow-up questions or provide additional context

Example of the structured review feedback returned by the LLM:

{
  "summary": "...",
  "rating": 7.5,
  "issues": [
    {
      "type": "correctness",
      "severity": "high",
      "message": "...",
      "suggestion": "...",
      "confidence": "high",
      "location": { "line": 12, "column": 5 }
    }
  ]
}

Architecture

  • Frontend (React, Vite, Worker Static Assets): user interface to paste code, view review results, manage sessions, and chat about a review
  • Backend (Cloudflare Worker): handles API requests, validates payloads, calls the LLM, and stores/retrieves sessions
  • LLM (Workers AI, Llama 3.3): performs code analysis and generates structured feedback
  • Database (Cloudflare KV): stores reviews
  • Client Storage (Local Storage): stores session id (for indexing in KV) and user preferences
flowchart LR
  Start(( )) --> Frontend
  Frontend --> CW["Cloudflare Worker"]
  CW --> WAI["Workers AI"]
  WAI --> Llama["Llama 3.3"]
  CW --> KV["Cloudflare KV"]
  Frontend --> LS["Local Storage"]
Loading

Getting Started

Deployed App

This app is deployed on Cloudflare Workers and can be accessed at:

https://ai-code-reviewer.r1c4rdco5t4-f9d.workers.dev

Local Setup

Requirements:

  • Node.js
  • npm
  • A Cloudflare account

Clone and install dependencies:

git clone https://github.com/rcosta358/cf_ai_code_reviewer
cd cf_ai_code_reviewer/app
npm install

You can set the VITE_USE_MOCK_REVIEW variable in .env.development to true to use a mock review response without calling Workers AI, which is useful for development without consuming AI credits.

Then, login to your Cloudflare account and create a new Cloudflare KV namespace:

npx wrangler login
npx wrangler kv namespace create SESSIONS_KV

Then, update wrangler.jsonc with the generated KV namespace id.

Finally, run the development server and open the app in your browser at http://localhost:5173:

npm run dev

To deploy the app to Cloudflare Workers, run:

npm run deploy

References