# snakeeye-sudo/codeflow-ai-reviewer architecture

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

- Interactive diagram: https://gitdiagram.com/snakeeye-sudo/codeflow-ai-reviewer
- Repository: https://github.com/snakeeye-sudo/codeflow-ai-reviewer

## Overview

CodeFlow AI Reviewer is a Flask service that accepts GitHub pull-request webhooks or manual review requests, obtains changed code, sends it to OpenAI for analysis, and returns or posts review feedback. The main runtime is concentrated in app.py: webhook validation, GitHub retrieval, language selection, model interaction, and comment publication are responsibilities within that file. The README describes broader quality checks and CI usage, but the supplied tree and excerpts do not show separate implementation modules or a learning subsystem, so those are not represented as independent components.

Main entry points: [`app.py`](https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py) (Webhook handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request handling"]
  node_webhook["Webhook handler<br/>[app.py]"]
  node_manual_route["Manual review route<br/>[app.py]"]
  node_status_route["Status endpoint<br/>[app.py]"]
  node_signature_check["Signature verification<br/>[app.py]"]
end

subgraph group_review["Review processing"]
  node_file_selection["Changed-file selection<br/>[app.py]"]
  node_language_map["Language selection<br/>[app.py]"]
  node_code_analysis["GPT code analysis<br/>[app.py]"]
  node_comment_publication["PR comment formatting<br/>[app.py]"]
end

subgraph group_integrations["External services"]
  node_github_api["GitHub API access<br/>[app.py]"]
  node_openai["OpenAI API"]
  node_github_pr["GitHub pull request"]
end

node_github_event(("GitHub PR event"))
node_review_user(("Manual review caller"))
node_review_result["Review response"]

node_github_event -->|"sends event"| node_webhook
node_webhook -->|"checks signature"| node_signature_check
node_webhook -->|"fetches PR"| node_github_api
node_github_api -->|"reads changes"| node_github_pr
node_webhook -->|"selects changed files"| node_file_selection
node_webhook -->|"maps extensions"| node_language_map
node_webhook -->|"submits patches"| node_code_analysis
node_manual_route -->|"submits code"| node_code_analysis
node_code_analysis -->|"requests analysis"| node_openai
node_openai -->|"returns feedback"| node_code_analysis
node_webhook -->|"publishes reviews"| node_comment_publication
node_comment_publication -->|"posts comment"| node_github_pr
node_manual_route -->|"returns review"| node_review_result
node_review_user -->|"requests review"| node_manual_route

click node_webhook "https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py"
click node_manual_route "https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py"
click node_status_route "https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py"
click node_signature_check "https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py"
click node_github_api "https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py"
click node_file_selection "https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py"
click node_language_map "https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py"
click node_code_analysis "https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py"
click node_comment_publication "https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py"

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_webhook,node_manual_route,node_status_route,node_signature_check,node_review_user,node_review_result toneBlue
class node_file_selection,node_language_map,node_code_analysis,node_comment_publication toneAmber
class node_github_api,node_openai,node_github_pr toneMint
class node_github_event toneIndigo
```

## Components

### Request handling

- [Webhook handler](https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py): `app.py`
- [Manual review route](https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py): `app.py`
- [Status endpoint](https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py): `app.py`
- [Signature verification](https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py): `app.py`

### Review processing

- [Changed-file selection](https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py): `app.py`
- [Language selection](https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py): `app.py`
- [GPT code analysis](https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py): `app.py`
- [PR comment formatting](https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py): `app.py`

### External services

- [GitHub API access](https://github.com/snakeeye-sudo/codeflow-ai-reviewer/blob/main/app.py): `app.py`
- **OpenAI API**
- **GitHub pull request**

### Other components

- **GitHub PR event**
- **Manual review caller**
- **Review response**

## Connections

- GitHub PR event → Webhook handler: sends event (evidence: `README.md`)
- Webhook handler → Signature verification: checks signature (evidence: `app.py`)
- Webhook handler → GitHub API access: fetches PR (evidence: `app.py`)
- GitHub API access → GitHub pull request: reads changes (evidence: `app.py`)
- Webhook handler → Changed-file selection: selects changed files (evidence: `app.py`)
- Webhook handler → Language selection: maps extensions (evidence: `app.py`)
- Webhook handler → GPT code analysis: submits patches (evidence: `app.py`)
- Manual review route → GPT code analysis: submits code (evidence: `app.py`)
- GPT code analysis → OpenAI API: requests analysis (evidence: `app.py`)
- OpenAI API → GPT code analysis: returns feedback (evidence: `app.py`)
- Webhook handler → PR comment formatting: publishes reviews (evidence: `app.py`)
- PR comment formatting → GitHub pull request: posts comment (evidence: `app.py`)
- Manual review route → Review response: returns review (evidence: `app.py`)
- Manual review caller → Manual review route: requests review (evidence: `README.md`)
