# alibaba/open-code-review architecture

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

- Interactive diagram: https://gitdiagram.com/alibaba/open-code-review
- Repository: https://github.com/alibaba/open-code-review
- Video tour (about a minute): https://gitdiagram.com/alibaba/open-code-review/video

## Overview

OpenCodeReview is an AI code-review product exposed as a CLI and editor integrations, with an ACP adapter and a session viewer. The principal flow selects changed files (or scans whole files), reviews them with an LLM agent and code tools, then presents structured comments. The README documents the review stages and capabilities; sampled source confirms selected IDE coordination and webview behavior. Several core modules and integration paths were not sampled, so their internal call relationships are left undocumented here.

Main entry points: [`cmd/opencodereview/main.go`](https://github.com/alibaba/open-code-review/blob/main/cmd/opencodereview/main.go) (OCR CLI), [`internal/agent/agent.go`](https://github.com/alibaba/open-code-review/blob/main/internal/agent/agent.go) (Review agent), [`extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/review/ReviewProjectService.kt`](https://github.com/alibaba/open-code-review/blob/main/extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/review/ReviewProjectService.kt) (IDEA integration), [`internal/diff`](https://github.com/alibaba/open-code-review/tree/main/internal/diff) (Git diff)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_review["Review engine"]
  node_diff["Git diff"]
  node_scan["Whole-file scan"]
  node_selection["File selection<br/>[selection.go]"]
  node_bundling["File bundling<br/>[grouping.go]"]
  node_agent["Review agent<br/>[agent.go]"]
  node_tasks["Review tasks<br/>[task.go]"]
  node_tools["Code tools<br/>[definitions.go]"]
  node_llm["LLM client<br/>[client.go]"]
  node_comments["Review comments<br/>[review.go]"]
end

subgraph group_interfaces["User interfaces"]
  node_cli["OCR CLI<br/>[main.go]"]
  node_viewer["Session viewer<br/>[server.go]"]
  node_ide["IDEA integration"]
  node_idegit["IDE Git service<br/>[GitService.kt]"]
  node_idecomments["IDE comments<br/>[CommentService.kt]"]
  node_idecli["IDE CLI service<br/>[CliService.kt]"]
  node_webview["Review webview<br/>[App.tsx]"]
  node_vscode["VS Code integration<br/>[CliService.ts]"]
end

subgraph group_state["Review state"]
  node_config["Review configuration"]
  node_sessions[("Review sessions<br/>[persist.go]")]
end

subgraph group_acp["ACP adapter"]
  node_acp["ACP process<br/>[main.go]"]
  node_acpagent["ACP review agent<br/>[agent.go]"]
end

node_developer(("Developer"))
node_model(("Model endpoint"))

node_developer -.->|"invokes"| node_cli
node_cli -->|"reviews changes"| node_diff
node_cli -->|"scans files"| node_scan
node_diff -->|"selects files"| node_selection
node_selection -->|"groups files"| node_bundling
node_bundling -->|"runs subagents"| node_agent
node_agent -.->|"delegates reviews"| node_tasks
node_agent -->|"retrieves context"| node_tools
node_agent -->|"requests review"| node_llm
node_llm -->|"sends prompts"| node_model
node_agent -->|"produces findings"| node_comments
node_cli -.->|"uses settings"| node_config
node_cli -.->|"stores results"| node_sessions
node_viewer -->|"reads sessions"| node_sessions
node_ide -->|"coordinates Git"| node_idegit
node_ide -->|"mounts comments"| node_idecomments
node_ide -->|"runs CLI"| node_idecli
node_webview -.->|"exchanges messages"| node_ide
node_vscode -.->|"runs executable"| node_cli
node_developer -.->|"connects ACP"| node_acp
node_acp -->|"creates agent"| node_acpagent

click node_cli "https://github.com/alibaba/open-code-review/blob/main/cmd/opencodereview/main.go"
click node_diff "https://github.com/alibaba/open-code-review/tree/main/internal/diff"
click node_scan "https://github.com/alibaba/open-code-review/tree/main/internal/scan"
click node_selection "https://github.com/alibaba/open-code-review/blob/main/internal/agent/selection.go"
click node_bundling "https://github.com/alibaba/open-code-review/blob/main/internal/agent/grouping.go"
click node_agent "https://github.com/alibaba/open-code-review/blob/main/internal/agent/agent.go"
click node_tasks "https://github.com/alibaba/open-code-review/blob/main/internal/reviewtask/task.go"
click node_tools "https://github.com/alibaba/open-code-review/blob/main/internal/tool/definitions.go"
click node_llm "https://github.com/alibaba/open-code-review/blob/main/internal/llm/client.go"
click node_comments "https://github.com/alibaba/open-code-review/blob/main/internal/model/review.go"
click node_config "https://github.com/alibaba/open-code-review/tree/main/internal/config"
click node_sessions "https://github.com/alibaba/open-code-review/blob/main/internal/session/persist.go"
click node_viewer "https://github.com/alibaba/open-code-review/blob/main/internal/viewer/server.go"
click node_ide "https://github.com/alibaba/open-code-review/blob/main/extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/review/ReviewProjectService.kt"
click node_idegit "https://github.com/alibaba/open-code-review/blob/main/extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/services/GitService.kt"
click node_idecomments "https://github.com/alibaba/open-code-review/blob/main/extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/providers/CommentService.kt"
click node_idecli "https://github.com/alibaba/open-code-review/blob/main/extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/services/CliService.kt"
click node_webview "https://github.com/alibaba/open-code-review/blob/main/extensions/frontend/src/webview/App.tsx"
click node_vscode "https://github.com/alibaba/open-code-review/blob/main/extensions/vscode/src/extension/services/CliService.ts"
click node_acp "https://github.com/alibaba/open-code-review/blob/main/acp/cmd/ocr-acp/main.go"
click node_acpagent "https://github.com/alibaba/open-code-review/blob/main/acp/internal/adapter/agent.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_diff,node_scan,node_selection,node_bundling,node_agent,node_tasks,node_tools,node_llm,node_comments toneBlue
class node_cli,node_viewer,node_ide,node_idegit,node_idecomments,node_idecli,node_webview,node_vscode toneAmber
class node_config,node_sessions toneMint
class node_acp,node_acpagent toneRose
class node_developer,node_model toneIndigo
```

## Components

### Review engine

- [Git diff](https://github.com/alibaba/open-code-review/tree/main/internal/diff): `internal/diff`
- [Whole-file scan](https://github.com/alibaba/open-code-review/tree/main/internal/scan): `internal/scan`
- [File selection](https://github.com/alibaba/open-code-review/blob/main/internal/agent/selection.go): `internal/agent/selection.go`
- [File bundling](https://github.com/alibaba/open-code-review/blob/main/internal/agent/grouping.go): `internal/agent/grouping.go`
- [Review agent](https://github.com/alibaba/open-code-review/blob/main/internal/agent/agent.go): `internal/agent/agent.go`
- [Review tasks](https://github.com/alibaba/open-code-review/blob/main/internal/reviewtask/task.go): `internal/reviewtask/task.go`
- [Code tools](https://github.com/alibaba/open-code-review/blob/main/internal/tool/definitions.go): `internal/tool/definitions.go`
- [LLM client](https://github.com/alibaba/open-code-review/blob/main/internal/llm/client.go): `internal/llm/client.go`
- [Review comments](https://github.com/alibaba/open-code-review/blob/main/internal/model/review.go): `internal/model/review.go`

### User interfaces

- [OCR CLI](https://github.com/alibaba/open-code-review/blob/main/cmd/opencodereview/main.go): `cmd/opencodereview/main.go`
- [Session viewer](https://github.com/alibaba/open-code-review/blob/main/internal/viewer/server.go): `internal/viewer/server.go`
- [IDEA integration](https://github.com/alibaba/open-code-review/blob/main/extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/review/ReviewProjectService.kt): `extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/review/ReviewProjectService.kt`
- [IDE Git service](https://github.com/alibaba/open-code-review/blob/main/extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/services/GitService.kt): `extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/services/GitService.kt`
- [IDE comments](https://github.com/alibaba/open-code-review/blob/main/extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/providers/CommentService.kt): `extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/providers/CommentService.kt`
- [IDE CLI service](https://github.com/alibaba/open-code-review/blob/main/extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/services/CliService.kt): `extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/services/CliService.kt`
- [Review webview](https://github.com/alibaba/open-code-review/blob/main/extensions/frontend/src/webview/App.tsx): `extensions/frontend/src/webview/App.tsx`
- [VS Code integration](https://github.com/alibaba/open-code-review/blob/main/extensions/vscode/src/extension/services/CliService.ts): `extensions/vscode/src/extension/services/CliService.ts`

### Review state

- [Review configuration](https://github.com/alibaba/open-code-review/tree/main/internal/config): `internal/config`
- [Review sessions](https://github.com/alibaba/open-code-review/blob/main/internal/session/persist.go): `internal/session/persist.go`

### ACP adapter

- [ACP process](https://github.com/alibaba/open-code-review/blob/main/acp/cmd/ocr-acp/main.go): `acp/cmd/ocr-acp/main.go`
- [ACP review agent](https://github.com/alibaba/open-code-review/blob/main/acp/internal/adapter/agent.go): `acp/internal/adapter/agent.go`

### Other components

- **Developer**
- **Model endpoint**

## Connections

- Developer → OCR CLI: invokes
- OCR CLI → Git diff: reviews changes
- OCR CLI → Whole-file scan: scans files
- Git diff → File selection: selects files
- File selection → File bundling: groups files
- File bundling → Review agent: runs subagents
- Review agent → Review tasks: delegates reviews
- Review agent → Code tools: retrieves context
- Review agent → LLM client: requests review
- LLM client → Model endpoint: sends prompts
- Review agent → Review comments: produces findings
- OCR CLI → Review configuration: uses settings
- OCR CLI → Review sessions: stores results
- Session viewer → Review sessions: reads sessions
- IDEA integration → IDE Git service: coordinates Git (evidence: `extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/review/ReviewProjectService.kt`)
- IDEA integration → IDE comments: mounts comments (evidence: `extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/review/ReviewProjectService.kt`)
- IDEA integration → IDE CLI service: runs CLI (evidence: `extensions/idea/src/main/kotlin/com/alibaba/opencodereview/idea/review/ReviewProjectService.kt`)
- Review webview → IDEA integration: exchanges messages
- VS Code integration → OCR CLI: runs executable
- Developer → ACP process: connects ACP
- ACP process → ACP review agent: creates agent (evidence: `acp/cmd/ocr-acp/main.go`)
