# caique-neves-ferreira/pr-review-agent architecture

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

- Interactive diagram: https://gitdiagram.com/caique-neves-ferreira/pr-review-agent
- Repository: https://github.com/caique-neves-ferreira/pr-review-agent

## Overview

This repository is a .NET pull-request review agent invoked by GitHub Actions. Its main workflow reads the event and team standards, fetches the PR diff, asks OpenAI for a structured review, posts a PR comment, and exits unsuccessfully for high-severity findings. The core implementation is concentrated in Program.cs; README.md documents the Actions trigger and merge-gate use. The workflow file and standards file are present in the tree, but their contents were not sampled, so those relationships are based on README documentation.

Main entry points: [`tools/PrReview.Agent/Program.cs`](https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/tools/PrReview.Agent/Program.cs) (Review agent), [`.github/workflows/pr-review.yml`](https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/.github/workflows/pr-review.yml) (GitHub Actions), [`docs/pr-standards.md`](https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/docs/pr-standards.md) (Team standards)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Workflow"]
  node_actions["GitHub Actions<br/>[pr-review.yml]"]
end

subgraph group_review["Review agent"]
  node_agent["Review agent<br/>[Program.cs]"]
  node_event["PR event payload"]
  node_standards["Team standards<br/>[pr-standards.md]"]
  node_diff["PR diff"]
  node_prompt["Review prompt<br/>[Program.cs]"]
  node_review_result["Structured review<br/>[Program.cs]"]
end

subgraph group_governance["Merge governance"]
  node_severity_gate["Severity gate<br/>[Program.cs]"]
  node_branch_protection["Branch protection"]
end

node_pull_request(("Pull request"))
node_openai["OpenAI API"]
node_comment["PR comment"]

node_pull_request -->|"triggers"| node_actions
node_actions -->|"runs"| node_agent
node_agent -->|"reads"| node_event
node_agent -->|"reads"| node_standards
node_agent -->|"fetches"| node_diff
node_agent -->|"builds"| node_prompt
node_prompt -->|"submits"| node_openai
node_openai -->|"returns JSON"| node_review_result
node_agent -->|"posts"| node_comment
node_agent -->|"checks severity"| node_severity_gate
node_severity_gate -->|"fails run"| node_actions
node_actions -.->|"supplies status"| node_branch_protection
node_branch_protection -.->|"blocks merge"| node_pull_request

click node_actions "https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/.github/workflows/pr-review.yml"
click node_agent "https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/tools/PrReview.Agent/Program.cs"
click node_standards "https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/docs/pr-standards.md"
click node_prompt "https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/tools/PrReview.Agent/Program.cs"
click node_review_result "https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/tools/PrReview.Agent/Program.cs"
click node_severity_gate "https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/tools/PrReview.Agent/Program.cs"

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_actions toneBlue
class node_agent,node_event,node_standards,node_diff,node_prompt,node_review_result toneAmber
class node_severity_gate,node_branch_protection,node_pull_request,node_openai toneMint
class node_comment toneIndigo
```

## Components

### Workflow

- [GitHub Actions](https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/.github/workflows/pr-review.yml): `.github/workflows/pr-review.yml`

### Review agent

- [Review agent](https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/tools/PrReview.Agent/Program.cs): `tools/PrReview.Agent/Program.cs`
- **PR event payload**
- [Team standards](https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/docs/pr-standards.md): `docs/pr-standards.md`
- **PR diff**
- [Review prompt](https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/tools/PrReview.Agent/Program.cs): `tools/PrReview.Agent/Program.cs`
- [Structured review](https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/tools/PrReview.Agent/Program.cs): `tools/PrReview.Agent/Program.cs`

### Merge governance

- [Severity gate](https://github.com/caique-neves-ferreira/pr-review-agent/blob/main/tools/PrReview.Agent/Program.cs): `tools/PrReview.Agent/Program.cs`
- **Branch protection**

### Other components

- **Pull request**
- **OpenAI API**
- **PR comment**

## Connections

- Pull request → GitHub Actions: triggers (evidence: `README.md`)
- GitHub Actions → Review agent: runs (evidence: `README.md`)
- Review agent → PR event payload: reads (evidence: `tools/PrReview.Agent/Program.cs`)
- Review agent → Team standards: reads (evidence: `tools/PrReview.Agent/Program.cs`)
- Review agent → PR diff: fetches (evidence: `tools/PrReview.Agent/Program.cs`)
- Review agent → Review prompt: builds (evidence: `tools/PrReview.Agent/Program.cs`)
- Review prompt → OpenAI API: submits (evidence: `tools/PrReview.Agent/Program.cs`)
- OpenAI API → Structured review: returns JSON (evidence: `tools/PrReview.Agent/Program.cs`)
- Review agent → PR comment: posts (evidence: `tools/PrReview.Agent/Program.cs`)
- Review agent → Severity gate: checks severity (evidence: `tools/PrReview.Agent/Program.cs`)
- Severity gate → GitHub Actions: fails run (evidence: `tools/PrReview.Agent/Program.cs`)
- GitHub Actions → Branch protection: supplies status (evidence: `README.md`)
- Branch protection → Pull request: blocks merge (evidence: `README.md`)
