# tomasz-tomczyk/crit architecture

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

- Interactive diagram: https://gitdiagram.com/tomasz-tomczyk/crit
- Repository: https://github.com/tomasz-tomczyk/crit

## Overview

Crit is a local review tool for agent-authored plans, code diffs, static HTML, and running web apps. The main workflow starts with a CLI invocation, selects or prepares review content, serves an interactive browser review, and stores comments for the agent to act on in an iterative loop. It also supports story-mode diff explanations, forge-based reviews, sharing, and agent integrations. Some relationships below follow README-documented behavior; unsampled implementation links are omitted rather than inferred.

Main entry points: [`cmd/crit/cli_handlers.go`](https://github.com/tomasz-tomczyk/crit/blob/main/cmd/crit/cli_handlers.go) (Command Handlers), [`internal/session`](https://github.com/tomasz-tomczyk/crit/tree/main/internal/session) (Review Sessions), [`internal/server/server.go`](https://github.com/tomasz-tomczyk/crit/blob/main/internal/server/server.go) (Review Server), [`cmd/crit/main.go`](https://github.com/tomasz-tomczyk/crit/blob/main/cmd/crit/main.go) (CLI Entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and Sessions"]
  node_cli["CLI Entry<br/>[main.go]"]
  node_commands["Command Handlers<br/>[cli_handlers.go]"]
  node_sessions["Review Sessions"]
  node_daemon["Review Daemon"]
end

subgraph group_review["Review Experience"]
  node_reviewdata[("Review Files<br/>[review_file.go]")]
  node_server["Review Server<br/>[server.go]"]
  node_webui["Browser Review UI<br/>[app.js]"]
  node_comments["Comment Commands<br/>[comment_cli.go]"]
end

subgraph group_domains["Review Modes"]
  node_vcs["Change Detection<br/>[git.go]"]
  node_diff["Diff Processing<br/>[diff.go]"]
  node_story["Story Mode<br/>[ingest.go]"]
  node_forge["Forge Reviews<br/>[forge.go]"]
  node_live["Live Proxy<br/>[live.go]"]
  node_preview["Static Preview<br/>[preview.go]"]
end

subgraph group_collaboration["Collaboration"]
  node_sharing["Review Sharing<br/>[share.go]"]
  node_auth["Share Authentication<br/>[auth.go]"]
  node_integrations["Agent Integrations"]
end

node_reviewer(("Reviewer"))
node_agent(("AI Agent"))
node_github["GitHub Service"]
node_gitlab["GitLab Service"]

node_reviewer -->|"starts review"| node_cli
node_agent -->|"launches review"| node_cli
node_cli -->|"dispatches commands"| node_commands
node_cli -->|"starts default review"| node_sessions
node_commands -->|"runs session commands"| node_sessions
node_commands -->|"starts live mode"| node_live
node_commands -->|"starts preview"| node_preview
node_commands -->|"runs forge actions"| node_forge
node_sessions -.->|"manages sessions"| node_daemon
node_vcs -->|"uses diff engine"| node_diff
node_reviewer -->|"reviews output"| node_webui
node_server -->|"serves review UI"| node_webui
node_webui -.->|"submits comments"| node_server
node_server -->|"reads session state"| node_sessions
node_server -->|"reads review data"| node_reviewdata
node_reviewdata -->|"persists review JSON"| node_sessions
node_agent -->|"adds programmatic comments"| node_comments
node_comments -->|"updates review file"| node_reviewdata
node_commands -->|"ingests story"| node_story
node_story -->|"stores story data"| node_sessions
node_commands -->|"runs share commands"| node_sharing
node_sharing -->|"uses session state"| node_sessions
node_commands -->|"runs auth commands"| node_auth
node_agent -->|"uses agent commands"| node_integrations
node_forge -->|"supports pull requests"| node_github
node_forge -->|"supports merge requests"| node_gitlab
node_live -.->|"serves proxied review"| node_server
node_preview -.->|"serves static review"| node_server

click node_cli "https://github.com/tomasz-tomczyk/crit/blob/main/cmd/crit/main.go"
click node_commands "https://github.com/tomasz-tomczyk/crit/blob/main/cmd/crit/cli_handlers.go"
click node_sessions "https://github.com/tomasz-tomczyk/crit/tree/main/internal/session"
click node_daemon "https://github.com/tomasz-tomczyk/crit/tree/main/internal/daemon"
click node_reviewdata "https://github.com/tomasz-tomczyk/crit/blob/main/internal/review/review_file.go"
click node_vcs "https://github.com/tomasz-tomczyk/crit/blob/main/internal/vcs/git.go"
click node_diff "https://github.com/tomasz-tomczyk/crit/blob/main/internal/diff/diff.go"
click node_story "https://github.com/tomasz-tomczyk/crit/blob/main/internal/story/ingest.go"
click node_forge "https://github.com/tomasz-tomczyk/crit/blob/main/internal/forge/forge.go"
click node_live "https://github.com/tomasz-tomczyk/crit/blob/main/internal/live/live.go"
click node_preview "https://github.com/tomasz-tomczyk/crit/blob/main/internal/preview/preview.go"
click node_server "https://github.com/tomasz-tomczyk/crit/blob/main/internal/server/server.go"
click node_webui "https://github.com/tomasz-tomczyk/crit/blob/main/web/app.js"
click node_comments "https://github.com/tomasz-tomczyk/crit/blob/main/internal/comment/comment_cli.go"
click node_sharing "https://github.com/tomasz-tomczyk/crit/blob/main/internal/share/share.go"
click node_auth "https://github.com/tomasz-tomczyk/crit/blob/main/internal/auth/auth.go"
click node_integrations "https://github.com/tomasz-tomczyk/crit/tree/main/integrations"

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_cli,node_commands,node_sessions,node_daemon,node_reviewer toneBlue
class node_reviewdata,node_server,node_webui,node_comments toneAmber
class node_vcs,node_diff,node_story,node_forge,node_live,node_preview toneMint
class node_sharing,node_auth,node_integrations toneRose
class node_agent,node_github,node_gitlab toneIndigo
```

## Components

### CLI and Sessions

- [CLI Entry](https://github.com/tomasz-tomczyk/crit/blob/main/cmd/crit/main.go): `cmd/crit/main.go`
- [Command Handlers](https://github.com/tomasz-tomczyk/crit/blob/main/cmd/crit/cli_handlers.go): `cmd/crit/cli_handlers.go`
- [Review Sessions](https://github.com/tomasz-tomczyk/crit/tree/main/internal/session): `internal/session`
- [Review Daemon](https://github.com/tomasz-tomczyk/crit/tree/main/internal/daemon): `internal/daemon`

### Review Experience

- [Review Files](https://github.com/tomasz-tomczyk/crit/blob/main/internal/review/review_file.go): `internal/review/review_file.go`
- [Review Server](https://github.com/tomasz-tomczyk/crit/blob/main/internal/server/server.go): `internal/server/server.go`
- [Browser Review UI](https://github.com/tomasz-tomczyk/crit/blob/main/web/app.js): `web/app.js`
- [Comment Commands](https://github.com/tomasz-tomczyk/crit/blob/main/internal/comment/comment_cli.go): `internal/comment/comment_cli.go`

### Review Modes

- [Change Detection](https://github.com/tomasz-tomczyk/crit/blob/main/internal/vcs/git.go): `internal/vcs/git.go`
- [Diff Processing](https://github.com/tomasz-tomczyk/crit/blob/main/internal/diff/diff.go): `internal/diff/diff.go`
- [Story Mode](https://github.com/tomasz-tomczyk/crit/blob/main/internal/story/ingest.go): `internal/story/ingest.go`
- [Forge Reviews](https://github.com/tomasz-tomczyk/crit/blob/main/internal/forge/forge.go): `internal/forge/forge.go`
- [Live Proxy](https://github.com/tomasz-tomczyk/crit/blob/main/internal/live/live.go): `internal/live/live.go`
- [Static Preview](https://github.com/tomasz-tomczyk/crit/blob/main/internal/preview/preview.go): `internal/preview/preview.go`

### Collaboration

- [Review Sharing](https://github.com/tomasz-tomczyk/crit/blob/main/internal/share/share.go): `internal/share/share.go`
- [Share Authentication](https://github.com/tomasz-tomczyk/crit/blob/main/internal/auth/auth.go): `internal/auth/auth.go`
- [Agent Integrations](https://github.com/tomasz-tomczyk/crit/tree/main/integrations): `integrations`

### Other components

- **Reviewer**
- **AI Agent**
- **GitHub Service**
- **GitLab Service**

## Connections

- Reviewer → CLI Entry: starts review (evidence: `README.md`)
- AI Agent → CLI Entry: launches review (evidence: `README.md`)
- CLI Entry → Command Handlers: dispatches commands (evidence: `cmd/crit/main.go`)
- CLI Entry → Review Sessions: starts default review (evidence: `cmd/crit/main.go`)
- Command Handlers → Review Sessions: runs session commands (evidence: `cmd/crit/cli_handlers.go`)
- Command Handlers → Live Proxy: starts live mode (evidence: `cmd/crit/cli_handlers.go`)
- Command Handlers → Static Preview: starts preview (evidence: `cmd/crit/cli_handlers.go`)
- Command Handlers → Forge Reviews: runs forge actions (evidence: `cmd/crit/cli_handlers.go`)
- Review Sessions → Review Daemon: manages sessions (evidence: `internal/session/stale_reviews.go`)
- Change Detection → Diff Processing: uses diff engine (evidence: `internal/vcs/git.go`)
- Reviewer → Browser Review UI: reviews output (evidence: `README.md`)
- Review Server → Browser Review UI: serves review UI (evidence: `internal/server/server.go`)
- Browser Review UI → Review Server: submits comments
- Review Server → Review Sessions: reads session state (evidence: `internal/server/server.go`)
- Review Server → Review Files: reads review data (evidence: `internal/server/server.go`)
- Review Files → Review Sessions: persists review JSON (evidence: `internal/review/review_file.go`)
- AI Agent → Comment Commands: adds programmatic comments (evidence: `README.md`)
- Comment Commands → Review Files: updates review file (evidence: `internal/comment/comment_cli.go`)
- Command Handlers → Story Mode: ingests story
- Story Mode → Review Sessions: stores story data (evidence: `internal/story/ingest.go`)
- Command Handlers → Review Sharing: runs share commands (evidence: `cmd/crit/cli_handlers.go`)
- Review Sharing → Review Sessions: uses session state (evidence: `internal/share/share.go`)
- Command Handlers → Share Authentication: runs auth commands (evidence: `cmd/crit/cli_handlers.go`)
- AI Agent → Agent Integrations: uses agent commands (evidence: `README.md`)
- Forge Reviews → GitHub Service: supports pull requests (evidence: `README.md`)
- Forge Reviews → GitLab Service: supports merge requests (evidence: `README.md`)
- Live Proxy → Review Server: serves proxied review
- Static Preview → Review Server: serves static review
