# ali-marandi/ai-code-reviewer architecture

> Architecture diagram of the GitHub repository ali-marandi/ai-code-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/ali-marandi/ai-code-reviewer
- Repository: https://github.com/ali-marandi/ai-code-reviewer

## Overview

AI-Code-Reviewer Enterprise is a local-first desktop and CLI tool for reviewing GitHub pull requests. The main workflow retrieves PR files, analyzes supported code with local rules and optional AI, then displays or posts findings and can save SARIF locally. The product also includes local findings trends, packaged localization, licensing and telemetry, plus versioned enterprise-analysis modules. Excerpts establish the main entry-point calls and storage behavior; some feature modules are not shown as wired into the primary workflow, so no such links are asserted.

Main entry points: [`app.py`](https://github.com/ali-marandi/ai-code-reviewer/blob/main/app.py) (CLI and GUI entry), [`core/ai_engine.py`](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine.py) (AI and local SAST), [`core/github_client.py`](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/github_client.py) (GitHub PR client), [`ui/main_window.py`](https://github.com/ali-marandi/ai-code-reviewer/blob/main/ui/main_window.py) (Desktop review UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User Entry"]
  node_app["CLI and GUI entry<br/>[app.py]"]
  node_desktop["Desktop review UI<br/>[main_window.py]"]
end

subgraph group_review["Review Analysis"]
  node_github["GitHub PR client<br/>[github_client.py]"]
  node_analysis["AI and local SAST<br/>[ai_engine.py]"]
  node_rules["Default rule pack"]
end

subgraph group_outputs["Findings and History"]
  node_review_cache[("Review cache and trend store<br/>[ai_engine.py]")]
  node_sarif["SARIF export<br/>[ai_engine.py]"]
  node_pr_comment["PR findings comment<br/>[github_client.py]"]
end

subgraph group_support["Application Support"]
  node_i18n["Packaged localization<br/>[i18n.py]"]
  node_translations["Translation catalogs"]
  node_license["License status<br/>[license_manager.py]"]
  node_telemetry["Local telemetry<br/>[telemetry.py]"]
end

subgraph group_extensions["Enterprise Extensions"]
  node_refactor_exemptions["Refactoring and exemptions"]
  node_analytics["Debt and repository analytics"]
  node_exploitability["Exploitability analysis"]
  node_compliance["Compliance mapping"]
  node_predictive["Predictive patching"]
  node_v160["Version 1.6 features"]
end

node_user(("Reviewer / CI"))
node_github_service["GitHub API"]
node_openai["OpenAI API"]
node_rule_config["Selected local rule pack"]

node_user -->|"starts review"| node_app
node_app -->|"opens UI"| node_desktop
node_app -->|"creates client"| node_github
node_app -->|"creates engine"| node_analysis
node_app -->|"installs locale"| node_i18n
node_app -->|"creates manager"| node_license
node_app -->|"creates logger"| node_telemetry
node_desktop -->|"loads PR data"| node_github
node_desktop -->|"analyzes files"| node_analysis
node_app -->|"fetches PR files"| node_github
node_app -->|"analyzes code"| node_analysis
node_app -->|"exports findings"| node_sarif
node_analysis -->|"requests AI review"| node_openai
node_analysis -->|"loads default rules"| node_rules
node_analysis -->|"loads selected rules"| node_rule_config
node_analysis -->|"stores scan metadata"| node_review_cache
node_desktop -->|"reads trend data"| node_review_cache
node_github -->|"calls API"| node_github_service
node_github -->|"posts review comment"| node_pr_comment
node_app -->|"posts findings"| node_github
node_i18n -->|"loads catalog"| node_translations
node_desktop -->|"saves local export"| node_sarif

click node_app "https://github.com/ali-marandi/ai-code-reviewer/blob/main/app.py"
click node_desktop "https://github.com/ali-marandi/ai-code-reviewer/blob/main/ui/main_window.py"
click node_github "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/github_client.py"
click node_analysis "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine.py"
click node_rules "https://github.com/ali-marandi/ai-code-reviewer/blob/main/rules/enterprise_default_rules.json"
click node_review_cache "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine.py"
click node_sarif "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine.py"
click node_pr_comment "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/github_client.py"
click node_i18n "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/i18n.py"
click node_translations "https://github.com/ali-marandi/ai-code-reviewer/tree/main/translations"
click node_license "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/license_manager.py"
click node_telemetry "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/telemetry.py"
click node_refactor_exemptions "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine_v120_features.py"
click node_analytics "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine_v130_features.py"
click node_exploitability "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine_v140_features.py"
click node_compliance "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine_v150_features.py"
click node_predictive "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine_v150_features.py"
click node_v160 "https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine_v160_features.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_app,node_desktop,node_user toneBlue
class node_github,node_analysis,node_rules toneAmber
class node_review_cache,node_sarif,node_pr_comment,node_github_service,node_openai toneMint
class node_i18n,node_translations,node_license,node_telemetry toneRose
class node_refactor_exemptions,node_analytics,node_exploitability,node_compliance,node_predictive,node_v160,node_rule_config toneIndigo
```

## Components

### User Entry

- [CLI and GUI entry](https://github.com/ali-marandi/ai-code-reviewer/blob/main/app.py): `app.py`
- [Desktop review UI](https://github.com/ali-marandi/ai-code-reviewer/blob/main/ui/main_window.py): `ui/main_window.py`

### Review Analysis

- [GitHub PR client](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/github_client.py): `core/github_client.py`
- [AI and local SAST](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine.py): `core/ai_engine.py`
- [Default rule pack](https://github.com/ali-marandi/ai-code-reviewer/blob/main/rules/enterprise_default_rules.json): `rules/enterprise_default_rules.json`

### Findings and History

- [Review cache and trend store](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine.py): `core/ai_engine.py`
- [SARIF export](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine.py): `core/ai_engine.py`
- [PR findings comment](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/github_client.py): `core/github_client.py`

### Application Support

- [Packaged localization](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/i18n.py): `core/i18n.py`
- [Translation catalogs](https://github.com/ali-marandi/ai-code-reviewer/tree/main/translations): `translations`
- [License status](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/license_manager.py): `core/license_manager.py`
- [Local telemetry](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/telemetry.py): `core/telemetry.py`

### Enterprise Extensions

- [Refactoring and exemptions](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine_v120_features.py): `core/ai_engine_v120_features.py`
- [Debt and repository analytics](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine_v130_features.py): `core/ai_engine_v130_features.py`
- [Exploitability analysis](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine_v140_features.py): `core/ai_engine_v140_features.py`
- [Compliance mapping](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine_v150_features.py): `core/ai_engine_v150_features.py`
- [Predictive patching](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine_v150_features.py): `core/ai_engine_v150_features.py`
- [Version 1.6 features](https://github.com/ali-marandi/ai-code-reviewer/blob/main/core/ai_engine_v160_features.py): `core/ai_engine_v160_features.py`

### Other components

- **Reviewer / CI**
- **GitHub API**
- **OpenAI API**
- **Selected local rule pack**

## Connections

- Reviewer / CI → CLI and GUI entry: starts review (evidence: `README.md`)
- CLI and GUI entry → Desktop review UI: opens UI (evidence: `app.py`)
- CLI and GUI entry → GitHub PR client: creates client (evidence: `app.py`)
- CLI and GUI entry → AI and local SAST: creates engine (evidence: `app.py`)
- CLI and GUI entry → Packaged localization: installs locale (evidence: `app.py`)
- CLI and GUI entry → License status: creates manager (evidence: `app.py`)
- CLI and GUI entry → Local telemetry: creates logger (evidence: `app.py`)
- Desktop review UI → GitHub PR client: loads PR data (evidence: `README.md`)
- Desktop review UI → AI and local SAST: analyzes files (evidence: `README.md`)
- CLI and GUI entry → GitHub PR client: fetches PR files (evidence: `app.py`)
- CLI and GUI entry → AI and local SAST: analyzes code (evidence: `app.py`)
- CLI and GUI entry → SARIF export: exports findings (evidence: `app.py`)
- AI and local SAST → OpenAI API: requests AI review (evidence: `core/ai_engine.py`)
- AI and local SAST → Default rule pack: loads default rules (evidence: `core/ai_engine.py`)
- AI and local SAST → Selected local rule pack: loads selected rules (evidence: `README.md`)
- AI and local SAST → Review cache and trend store: stores scan metadata (evidence: `core/ai_engine.py`)
- Desktop review UI → Review cache and trend store: reads trend data (evidence: `ui/main_window.py`)
- GitHub PR client → GitHub API: calls API (evidence: `core/github_client.py`)
- GitHub PR client → PR findings comment: posts review comment (evidence: `core/github_client.py`)
- CLI and GUI entry → GitHub PR client: posts findings (evidence: `app.py`)
- Packaged localization → Translation catalogs: loads catalog (evidence: `core/i18n.py`)
- Desktop review UI → SARIF export: saves local export (evidence: `README.md`)
