# dahc36/loop-review architecture

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

- Interactive diagram: https://gitdiagram.com/dahc36/loop-review
- Repository: https://github.com/dahc36/loop-review

## Overview

loop-review is a Go CLI that posts JSON review drafts as pending GitHub pull-request reviews. Its workflow reads and validates the draft, identifies the GitHub repository from a local clone, fetches pull-request state, checks comment anchors against the base-to-head diff and validates suggestions and links, then submits the review and emits IDs. The graph reflects relationships visible in the sampled source; finer validation behavior is shown as separate components where the caller is explicit.

Main entry points: [`post.go`](https://github.com/dahc36/loop-review/blob/main/post.go) (Post workflow), [`draft.go`](https://github.com/dahc36/loop-review/blob/main/draft.go) (Comment validation), [`github.go`](https://github.com/dahc36/loop-review/blob/main/github.go) (GitHub CLI client), [`main.go`](https://github.com/dahc36/loop-review/blob/main/main.go) (Command entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_entry["Command entry<br/>[main.go]"]
  node_workflow["Post workflow<br/>[post.go]"]
  node_output["Review result<br/>[post.go]"]
end

subgraph group_validation["Draft validation"]
  node_draft["Draft reader<br/>[draft.go]"]
  node_comment_model["Comment model<br/>[comment.go]"]
  node_comment_validation["Comment validation<br/>[draft.go]"]
  node_anchor_validation["Anchor validation<br/>[anchor.go]"]
  node_suggestion_validation["Suggestion validation<br/>[suggestion.go]"]
  node_link_validation["Link validation<br/>[link.go]"]
end

subgraph group_git["Local Git operations"]
  node_repo_identity["Repository identity<br/>[repo.go]"]
  node_diff_reader["Touched-line reader<br/>[diff.go]"]
end

subgraph group_github["GitHub integration"]
  node_github_client["GitHub CLI client<br/>[github.go]"]
end

node_user(("CLI user"))
node_git_cli["Git CLI"]
node_github["GitHub"]

node_user -->|"runs command"| node_entry
node_entry -->|"dispatches post"| node_workflow
node_workflow -->|"reads draft"| node_draft
node_workflow -->|"opens clone"| node_repo_identity
node_workflow -->|"loads pull request"| node_github_client
node_workflow -->|"reads touched lines"| node_diff_reader
node_workflow -->|"validates comments"| node_comment_validation
node_comment_validation -->|"checks anchors"| node_anchor_validation
node_comment_validation -->|"checks suggestions"| node_suggestion_validation
node_comment_validation -->|"checks links"| node_link_validation
node_workflow -->|"creates review"| node_github_client
node_workflow -->|"encodes result"| node_output
node_workflow -->|"reads diff"| node_git_cli
node_repo_identity -->|"reads origin"| node_git_cli
node_link_validation -->|"checks file refs"| node_git_cli
node_diff_reader -->|"fetches and diffs"| node_git_cli
node_github_client -->|"GraphQL via gh"| node_github

click node_entry "https://github.com/dahc36/loop-review/blob/main/main.go"
click node_workflow "https://github.com/dahc36/loop-review/blob/main/post.go"
click node_draft "https://github.com/dahc36/loop-review/blob/main/draft.go"
click node_comment_model "https://github.com/dahc36/loop-review/blob/main/comment.go"
click node_comment_validation "https://github.com/dahc36/loop-review/blob/main/draft.go"
click node_anchor_validation "https://github.com/dahc36/loop-review/blob/main/anchor.go"
click node_suggestion_validation "https://github.com/dahc36/loop-review/blob/main/suggestion.go"
click node_link_validation "https://github.com/dahc36/loop-review/blob/main/link.go"
click node_repo_identity "https://github.com/dahc36/loop-review/blob/main/repo.go"
click node_diff_reader "https://github.com/dahc36/loop-review/blob/main/diff.go"
click node_github_client "https://github.com/dahc36/loop-review/blob/main/github.go"
click node_output "https://github.com/dahc36/loop-review/blob/main/post.go"

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_workflow,node_output,node_user toneBlue
class node_draft,node_comment_model,node_comment_validation,node_anchor_validation,node_suggestion_validation,node_link_validation toneAmber
class node_repo_identity,node_diff_reader toneMint
class node_github_client toneRose
class node_git_cli,node_github toneIndigo
```

## Components

### CLI workflow

- [Command entry](https://github.com/dahc36/loop-review/blob/main/main.go): `main.go`
- [Post workflow](https://github.com/dahc36/loop-review/blob/main/post.go): `post.go`
- [Review result](https://github.com/dahc36/loop-review/blob/main/post.go): `post.go`

### Draft validation

- [Draft reader](https://github.com/dahc36/loop-review/blob/main/draft.go): `draft.go`
- [Comment model](https://github.com/dahc36/loop-review/blob/main/comment.go): `comment.go`
- [Comment validation](https://github.com/dahc36/loop-review/blob/main/draft.go): `draft.go`
- [Anchor validation](https://github.com/dahc36/loop-review/blob/main/anchor.go): `anchor.go`
- [Suggestion validation](https://github.com/dahc36/loop-review/blob/main/suggestion.go): `suggestion.go`
- [Link validation](https://github.com/dahc36/loop-review/blob/main/link.go): `link.go`

### Local Git operations

- [Repository identity](https://github.com/dahc36/loop-review/blob/main/repo.go): `repo.go`
- [Touched-line reader](https://github.com/dahc36/loop-review/blob/main/diff.go): `diff.go`

### GitHub integration

- [GitHub CLI client](https://github.com/dahc36/loop-review/blob/main/github.go): `github.go`

### Other components

- **CLI user**
- **Git CLI**
- **GitHub**

## Connections

- CLI user → Command entry: runs command (evidence: `main.go`)
- Command entry → Post workflow: dispatches post (evidence: `main.go`)
- Post workflow → Draft reader: reads draft (evidence: `post.go`)
- Post workflow → Repository identity: opens clone (evidence: `post.go`)
- Post workflow → GitHub CLI client: loads pull request (evidence: `post.go`)
- Post workflow → Touched-line reader: reads touched lines (evidence: `post.go`)
- Post workflow → Comment validation: validates comments (evidence: `post.go`)
- Comment validation → Anchor validation: checks anchors (evidence: `draft.go`)
- Comment validation → Suggestion validation: checks suggestions (evidence: `draft.go`)
- Comment validation → Link validation: checks links (evidence: `draft.go`)
- Post workflow → GitHub CLI client: creates review (evidence: `post.go`)
- Post workflow → Review result: encodes result (evidence: `post.go`)
- Post workflow → Git CLI: reads diff
- Repository identity → Git CLI: reads origin (evidence: `repo.go`)
- Link validation → Git CLI: checks file refs (evidence: `link.go`)
- Touched-line reader → Git CLI: fetches and diffs (evidence: `diff.go`)
- GitHub CLI client → GitHub: GraphQL via gh (evidence: `github.go`)
