# agogear/chatgpt-pr-review architecture

> Architecture diagram of the GitHub repository agogear/chatgpt-pr-review, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/agogear/chatgpt-pr-review
- Repository: https://github.com/agogear/chatgpt-pr-review

## Overview

This GitHub Action reviews changed pull-request files: it selects eligible files, gathers PR context and file contents, asks OpenAI for per-file feedback, then submits a GitHub review. The implementation is concentrated in main.py; the README documents the GitHub Actions trigger, file-pattern filtering, and OpenAI/GitHub integrations. Internal relationships follow the shown orchestration and calls; details of the action wrapper are not represented because its source was not excerpted.

Main entry points: [`main.py`](https://github.com/agogear/chatgpt-pr-review/blob/main/main.py) (Review entry point)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Review orchestration"]
  node_entry["Review entry point<br/>[main.py]"]
  node_file_selection["Changed-file selection<br/>[main.py]"]
  node_pr_context["PR context<br/>[main.py]"]
  node_file_content["Changed file content<br/>[main.py]"]
end

subgraph group_generation["Review generation"]
  node_prompt["Review prompt<br/>[main.py]"]
  node_review_request["Review request<br/>[main.py]"]
  node_review_result["Review comments<br/>[main.py]"]
end

subgraph group_integrations["External services"]
  node_openai["OpenAI Chat API"]
  node_github_api["GitHub REST API"]
end

node_pull_request(("Pull request"))
node_runner(("GitHub Action runner"))

node_pull_request -->|"triggers workflow"| node_runner
node_runner -.->|"starts action"| node_entry
node_entry -->|"selects files"| node_file_selection
node_entry -->|"fetches context"| node_pr_context
node_entry -->|"reads contents"| node_file_content
node_entry -->|"requests reviews"| node_review_request
node_review_request -->|"builds prompt"| node_prompt
node_review_request -->|"sends request"| node_openai
node_openai -->|"returns feedback"| node_review_result
node_entry -->|"submits review"| node_github_api

click node_entry "https://github.com/agogear/chatgpt-pr-review/blob/main/main.py"
click node_file_selection "https://github.com/agogear/chatgpt-pr-review/blob/main/main.py"
click node_pr_context "https://github.com/agogear/chatgpt-pr-review/blob/main/main.py"
click node_file_content "https://github.com/agogear/chatgpt-pr-review/blob/main/main.py"
click node_prompt "https://github.com/agogear/chatgpt-pr-review/blob/main/main.py"
click node_review_request "https://github.com/agogear/chatgpt-pr-review/blob/main/main.py"
click node_review_result "https://github.com/agogear/chatgpt-pr-review/blob/main/main.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_entry,node_file_selection,node_pr_context,node_file_content toneBlue
class node_prompt,node_review_request,node_review_result toneAmber
class node_openai,node_github_api,node_pull_request toneMint
class node_runner toneIndigo
```

## Components

### Review orchestration

- [Review entry point](https://github.com/agogear/chatgpt-pr-review/blob/main/main.py): `main.py`
- [Changed-file selection](https://github.com/agogear/chatgpt-pr-review/blob/main/main.py): `main.py`
- [PR context](https://github.com/agogear/chatgpt-pr-review/blob/main/main.py): `main.py`
- [Changed file content](https://github.com/agogear/chatgpt-pr-review/blob/main/main.py): `main.py`

### Review generation

- [Review prompt](https://github.com/agogear/chatgpt-pr-review/blob/main/main.py): `main.py`
- [Review request](https://github.com/agogear/chatgpt-pr-review/blob/main/main.py): `main.py`
- [Review comments](https://github.com/agogear/chatgpt-pr-review/blob/main/main.py): `main.py`

### External services

- **OpenAI Chat API**
- **GitHub REST API**

### Other components

- **Pull request**
- **GitHub Action runner**

## Connections

- Pull request → GitHub Action runner: triggers workflow (evidence: `README.md`)
- GitHub Action runner → Review entry point: starts action
- Review entry point → Changed-file selection: selects files (evidence: `main.py`)
- Review entry point → PR context: fetches context (evidence: `main.py`)
- Review entry point → Changed file content: reads contents (evidence: `main.py`)
- Review entry point → Review request: requests reviews (evidence: `main.py`)
- Review request → Review prompt: builds prompt (evidence: `main.py`)
- Review request → OpenAI Chat API: sends request (evidence: `main.py`)
- OpenAI Chat API → Review comments: returns feedback (evidence: `main.py`)
- Review entry point → GitHub REST API: submits review (evidence: `main.py`)
