# kingo9/ai-powered-code-reviewer architecture

> Architecture diagram of the GitHub repository kingo9/ai-powered-code-reviewer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kingo9/ai-powered-code-reviewer
- Repository: https://github.com/kingo9/ai-powered-code-reviewer

## Overview

1. **Repository shape**
   - The project is split into two independently run applications: `Frontend/` and `BackEnd/`.
   - The root is mostly documentation and lockfiles; the actual runtime is separated by concern and deployment boundary.

2. **Frontend: interactive code review UI**
   - `Frontend/` is a Vite-based React app.
   - Its job is to provide the code editor/input surface, trigger review requests, and render the AI’s response.
   - The README indicates it uses React Markdown and Highlight.js, so the review output is treated as formatted Markdown with syntax highlighting.

3. **Frontend data flow**
   - User enters code in the UI.
   - The frontend sends that code to the backend over HTTP, likely via Axios based on the README.
   - The response is shown in the app as a review report, not just raw text.

4. **Backend: API boundary**
   - `BackEnd/` is a Node.js + Express application.
   - `server.js` is the process entry point, while `src/app.js` appears to assemble the Express app.
   - This backend is the only place that should know about the OpenAI API key and external AI calls.

5. **Route/controller/service layering**
   - The backend is organized into a simple three-tier structure:
     - `routes/` defines the HTTP endpoint(s)
     - `controllers/` handles request/response handling
     - `services/` contains the AI integration and business logic
   - This separation keeps transport concerns away from the OpenAI-specific logic.

6. **AI integration boundary**
   - `src/services/ai.service.js` is the main integration point with OpenAI.
   - The backend likely transforms the submitted code into a prompt, calls the model, and returns the generated review.
   - The API key is configured through environment variables, so the secret stays server-side.

7. **End-to-end request path**
   - Browser UI -> Express route -> controller -> AI service -> OpenAI API -> controller -> frontend display.
   - The backend acts as a secure proxy and formatting layer between the UI and the external AI provider.

8. **Rendering and presentation**
   - The frontend is focused on presentation and interaction, not analysis.
   - Markdown rendering plus code highlighting suggests the AI response is structured for human-readable review comments, code snippets, and possibly bullet-point recommendations.

9. **Runtime and tooling**
   - Frontend: React + Vite development server.
   - Backend: Node.js + Express server.
   - Package management is npm in both parts, with separate `package.json` files indicating independent dependency graphs.

10. **Important architectural boundary**
   - The key separation is between client-side editing/rendering and server-side AI orchestration.
   - All sensitive credentials and model calls stay in `BackEnd/`; the frontend only talks to the backend API.

Main entry points: [`BackEnd/src/services/ai.service.js`](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/src/services/ai.service.js) (AI Service), [`BackEnd/src/controllers/ai.controller.js`](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/src/controllers/ai.controller.js) (AI Controller), [`Frontend/src/App.jsx`](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/Frontend/src/App.jsx) (Review View), [`BackEnd/src/routes/ai.routes.js`](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/src/routes/ai.routes.js) (AI Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_shell["App Shell<br/>React/Vite UI<br/>[main.jsx]"]
  node_code_input["Code Input<br/>editor surface<br/>[App.jsx]"]
  node_review_view["Review View<br/>rendering<br/>[App.jsx]"]
  node_http_client["API Client<br/>HTTP client<br/>[App.jsx]"]
  node_styles["Styling<br/>presentation<br/>[App.css]"]
  node_markdown_rendering["Markdown Rendering<br/>presentation lib"]
  node_syntax_highlight["Code Highlighting<br/>presentation lib"]
end

subgraph group_backend["BackEnd"]
  node_server_entry["Server Entry<br/>Node entrypoint<br/>[server.js]"]
  node_express_app["Express App<br/>API assembly<br/>[app.js]"]
  node_ai_routes["AI Routes<br/>route layer<br/>[ai.routes.js]"]
  node_ai_controller["AI Controller<br/>request handler<br/>[ai.controller.js]"]
  node_ai_service["AI Service<br/>business logic<br/>[ai.service.js]"]
  node_openai_api(("OpenAI API<br/>external AI"))
  node_env_config["Env Config<br/>secret config"]
end

node_frontend_shell -->|"hosts"| node_code_input
node_frontend_shell -->|"renders"| node_review_view
node_code_input -->|"submits code"| node_http_client
node_http_client -->|"HTTP request"| node_ai_routes
node_review_view -->|"uses"| node_markdown_rendering
node_review_view -->|"uses"| node_syntax_highlight
node_server_entry -->|"boots"| node_express_app
node_express_app -->|"mounts"| node_ai_routes
node_ai_routes -->|"delegates"| node_ai_controller
node_ai_controller -->|"calls"| node_ai_service
node_ai_service -->|"reads"| node_env_config
node_ai_service -->|"requests review"| node_openai_api
node_openai_api -->|"returns result"| node_ai_service
node_ai_service -->|"review text"| node_ai_controller
node_ai_controller -->|"response"| node_http_client

click node_frontend_shell "https://github.com/kingo9/ai-powered-code-reviewer/blob/main/Frontend/src/main.jsx"
click node_code_input "https://github.com/kingo9/ai-powered-code-reviewer/blob/main/Frontend/src/App.jsx"
click node_review_view "https://github.com/kingo9/ai-powered-code-reviewer/blob/main/Frontend/src/App.jsx"
click node_http_client "https://github.com/kingo9/ai-powered-code-reviewer/blob/main/Frontend/src/App.jsx"
click node_styles "https://github.com/kingo9/ai-powered-code-reviewer/blob/main/Frontend/src/App.css"
click node_server_entry "https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/server.js"
click node_express_app "https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/src/app.js"
click node_ai_routes "https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/src/routes/ai.routes.js"
click node_ai_controller "https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/src/controllers/ai.controller.js"
click node_ai_service "https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/src/services/ai.service.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend_shell,node_code_input,node_review_view,node_http_client,node_styles,node_markdown_rendering,node_syntax_highlight toneBlue
class node_server_entry,node_express_app,node_ai_routes,node_ai_controller,node_ai_service,node_openai_api,node_env_config toneAmber
```

## Components

### Frontend

React/Vite client for code input and review display

- [App Shell](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/Frontend/src/main.jsx): React/Vite UI · Main frontend application entry and page composition · `Frontend/src/main.jsx`
- [Code Input](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/Frontend/src/App.jsx): editor surface · User-facing code entry and review request trigger · `Frontend/src/App.jsx`
- [Review View](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/Frontend/src/App.jsx): rendering · Displays AI review output as formatted Markdown with code highlighting · `Frontend/src/App.jsx`
- [API Client](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/Frontend/src/App.jsx): HTTP client · Sends submitted code to the backend review endpoint · `Frontend/src/App.jsx`
- [Styling](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/Frontend/src/App.css): presentation · App styling and visual structure for the review UI · `Frontend/src/App.css`
- **Markdown Rendering**: presentation lib · Frontend formatting path for AI-generated review text
- **Code Highlighting**: presentation lib · Frontend syntax highlighting for code snippets in reviews

### BackEnd

Express API that orchestrates AI code review

- [Server Entry](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/server.js): Node entrypoint · Starts the backend process · `BackEnd/server.js`
- [Express App](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/src/app.js): API assembly · Builds the Express application and middleware pipeline · `BackEnd/src/app.js`
- [AI Routes](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/src/routes/ai.routes.js): route layer · Defines the HTTP endpoint for code review requests · `BackEnd/src/routes/ai.routes.js`
- [AI Controller](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/src/controllers/ai.controller.js): request handler · Handles request/response flow for review requests · `BackEnd/src/controllers/ai.controller.js`
- [AI Service](https://github.com/kingo9/ai-powered-code-reviewer/blob/main/BackEnd/src/services/ai.service.js): business logic · Transforms submitted code into prompts and calls the model · `BackEnd/src/services/ai.service.js`
- **OpenAI API**: external AI · External model provider used for code review generation
- **Env Config**: secret config · Server-side API key and runtime configuration boundary

## Connections

- App Shell → Code Input: hosts · The app shell presents the code entry surface
- App Shell → Review View: renders · The app shell displays the generated review output
- Code Input → API Client: submits code · User code is sent to the backend for review
- API Client → AI Routes: HTTP request · Frontend calls the backend review endpoint
- Review View → Markdown Rendering: uses · Review output is rendered as Markdown
- Review View → Code Highlighting: uses · Code snippets are highlighted for readability
- Server Entry → Express App: boots · Process entrypoint starts the Express app
- Express App → AI Routes: mounts · Routes are registered on the Express application
- AI Routes → AI Controller: delegates · Route handlers forward requests to the controller
- AI Controller → AI Service: calls · Controller passes review work to the service layer
- AI Service → Env Config: reads · Service accesses server-side secrets and config
- AI Service → OpenAI API: requests review · Service sends prompts to the external model provider
- OpenAI API → AI Service: returns result · Generated review is returned to the backend
- AI Service → AI Controller: review text · Service returns the generated review payload
- AI Controller → API Client: response · Backend response is received by the frontend client
