# rahulpaswan461/pr-reviwer-agent architecture

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

- Interactive diagram: https://gitdiagram.com/rahulpaswan461/pr-reviwer-agent
- Repository: https://github.com/rahulpaswan461/pr-reviwer-agent

## Overview

This is a pull-request diff reviewer that can run from standard input or in a GitHub Actions environment. Its main flow reads and redacts a diff, asks Groq for a schema-constrained review, validates the response (falling back to a fail-closed result), then prints JSON or posts a GitHub comment. The tree and README provide no further product documentation; the graph follows the sampled runtime source and omits unrelated example files.

Main entry points: [`index.js`](https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/index.js) (Review entrypoint), [`reviwer.js`](https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/reviwer.js) (AI reviewer), [`postPRComment.js`](https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/postPRComment.js) (PR commenter), [`redact-secrets.js`](https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/redact-secrets.js) (Secret redaction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Diff intake"]
  node_entry["Review entrypoint<br/>[index.js]"]
  node_redaction["Secret redaction<br/>[redact-secrets.js]"]
end

subgraph group_review["AI review"]
  node_reviewer["AI reviewer<br/>[reviwer.js]"]
  node_json_schema["Output schema"]
  node_validation["Review validation<br/>[validateSchema.js]"]
  node_fallback["Fail-closed result"]
end

subgraph group_delivery["Result delivery"]
  node_commenter["PR commenter<br/>[postPRComment.js]"]
  node_markdown["Markdown formatter<br/>[to-markdown.js]"]
end

node_initiator(("CLI or GitHub run"))
node_groq["Groq API"]
node_github["GitHub API"]
node_stdout["JSON output"]

node_initiator -->|"provides diff"| node_entry
node_entry -->|"redacts diff"| node_redaction
node_entry -->|"requests review"| node_reviewer
node_entry -->|"supplies schema"| node_json_schema
node_reviewer -->|"sends review request"| node_groq
node_groq -->|"returns review"| node_reviewer
node_reviewer -->|"returns result"| node_entry
node_entry -->|"validates result"| node_validation
node_entry -->|"builds on error"| node_fallback
node_entry -->|"posts in Actions"| node_commenter
node_entry -->|"prints outside Actions"| node_stdout
node_commenter -->|"formats result"| node_markdown
node_commenter -->|"creates comment"| node_github

click node_entry "https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/index.js"
click node_redaction "https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/redact-secrets.js"
click node_reviewer "https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/reviwer.js"
click node_json_schema "https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/ReviewJsonschema.js"
click node_validation "https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/validateSchema.js"
click node_fallback "https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/failed-closed-result.js"
click node_commenter "https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/postPRComment.js"
click node_markdown "https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/to-markdown.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_entry,node_redaction toneBlue
class node_reviewer,node_json_schema,node_validation,node_fallback toneAmber
class node_commenter,node_markdown,node_groq,node_github toneMint
class node_initiator,node_stdout toneIndigo
```

## Components

### Diff intake

- [Review entrypoint](https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/index.js): `index.js`
- [Secret redaction](https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/redact-secrets.js): `redact-secrets.js`

### AI review

- [AI reviewer](https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/reviwer.js): `reviwer.js`
- [Output schema](https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/ReviewJsonschema.js): `ReviewJsonschema.js`
- [Review validation](https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/validateSchema.js): `validateSchema.js`
- [Fail-closed result](https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/failed-closed-result.js): `failed-closed-result.js`

### Result delivery

- [PR commenter](https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/postPRComment.js): `postPRComment.js`
- [Markdown formatter](https://github.com/rahulpaswan461/pr-reviwer-agent/blob/main/to-markdown.js): `to-markdown.js`

### Other components

- **CLI or GitHub run**
- **Groq API**
- **GitHub API**
- **JSON output**

## Connections

- CLI or GitHub run → Review entrypoint: provides diff
- Review entrypoint → Secret redaction: redacts diff
- Review entrypoint → AI reviewer: requests review
- Review entrypoint → Output schema: supplies schema
- AI reviewer → Groq API: sends review request
- Groq API → AI reviewer: returns review
- AI reviewer → Review entrypoint: returns result
- Review entrypoint → Review validation: validates result
- Review entrypoint → Fail-closed result: builds on error
- Review entrypoint → PR commenter: posts in Actions
- Review entrypoint → JSON output: prints outside Actions
- PR commenter → Markdown formatter: formats result
- PR commenter → GitHub API: creates comment
