# diillson/chatcli architecture

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

- Interactive diagram: https://gitdiagram.com/diillson/chatcli
- Repository: https://github.com/diillson/chatcli

## Overview

ChatCLI is a multi-surface assistant and autonomous coding platform. A user submits a chat turn or task through the terminal, an editor, a chat integration, or a server interface; ChatCLI routes it through its chat or agent runtime, which can call models and tools, then returns a response or streamed run. Other documented capabilities include model orchestration, quality patterns, persistent context and memory, task graphs, integrations, dashboards, and Kubernetes operations. The README and selected excerpts support the main runtime links; unsampled subsystem wiring is not inferred.

Main entry points: [`cli/chat_pipeline.go`](https://github.com/diillson/chatcli/blob/main/cli/chat_pipeline.go) (Chat turn pipeline), [`cli/agent/workers/worker_react.go`](https://github.com/diillson/chatcli/blob/main/cli/agent/workers/worker_react.go) (Coder and agents), [`server/pipeline.go`](https://github.com/diillson/chatcli/blob/main/server/pipeline.go) (Pipeline RPC), [`llm/manager/llm_manager.go`](https://github.com/diillson/chatcli/blob/main/llm/manager/llm_manager.go) (Provider manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_surfaces["User surfaces"]
  node_cli["Interactive CLI<br/>[cli.go]"]
  node_webui["Browser UI<br/>[server.go]"]
  node_acp["ACP server<br/>[acp.go]"]
  node_gateway["Chat gateway<br/>[gateway.go]"]
  node_rpcserver["Pipeline RPC<br/>[pipeline.go]"]
end

subgraph group_runtime["Chat and agent runtime"]
  node_chat["Chat turn pipeline<br/>[chat_pipeline.go]"]
  node_agent["Coder and agents<br/>[worker_react.go]"]
  node_policy["Tool safety policy<br/>[policy_manager.go]"]
  node_taskgraph["Task graph engine<br/>[engine.go]"]
end

subgraph group_models["Models and quality"]
  node_llm["Provider manager<br/>[llm_manager.go]"]
  node_quality["Quality harness<br/>[pipeline.go]"]
  node_pricing["Usage pricing<br/>[engine.go]"]
end

subgraph group_state["Context and state"]
  node_context["Context retrieval<br/>[manager.go]"]
  node_memory["Workspace memory<br/>[memory.go]"]
  node_storage[("Session and state storage<br/>[storage.go]")]
end

subgraph group_integrations["Integrations and operations"]
  node_mcp["MCP integration<br/>[manager.go]"]
  node_plugins["Plugin system<br/>[manager.go]"]
  node_dashboard["Live dashboard<br/>[server.go]"]
  node_operator["Kubernetes operator<br/>[main.go]"]
  node_rollback["Rollback controller<br/>[rollback_engine.go]"]
end

node_terminal(("Terminal user"))
node_editors(("Editor clients"))
node_chatapps(("Chat apps"))
node_rpcclient(("RPC clients"))

node_terminal -->|"submits turns"| node_cli
node_editors -->|"send requests"| node_acp
node_chatapps -->|"send messages"| node_gateway
node_rpcclient -->|"invoke pipeline"| node_rpcserver
node_cli -.->|"runs turns"| node_chat
node_chat -->|"requests completions"| node_llm
node_chat -->|"uses harness"| node_quality
node_chat -.->|"retrieves context"| node_context
node_chat -.->|"uses memory"| node_memory
node_chat -.->|"persists sessions"| node_storage
node_agent -->|"checks tool access"| node_policy
node_agent -.->|"requests completions"| node_llm
node_taskgraph -->|"dispatches workers"| node_agent
node_taskgraph -->|"saves run state"| node_storage
node_llm -.->|"reports usage"| node_pricing
node_mcp -.->|"provides tools"| node_agent
node_plugins -.->|"extends tools"| node_agent
node_rpcserver -->|"hosts backend"| node_chat
node_rpcserver -->|"runs tasks"| node_agent
node_webui -.->|"serves assistant"| node_chat
node_gateway -.->|"shares sessions"| node_chat
node_dashboard -.->|"visualizes runtime"| node_operator
node_operator -->|"uses controller"| node_rollback

click node_cli "https://github.com/diillson/chatcli/blob/main/cli/cli.go"
click node_webui "https://github.com/diillson/chatcli/blob/main/cli/webui/server.go"
click node_acp "https://github.com/diillson/chatcli/blob/main/cli/rpcserve/acp.go"
click node_gateway "https://github.com/diillson/chatcli/blob/main/cli/gateway/gateway.go"
click node_rpcserver "https://github.com/diillson/chatcli/blob/main/server/pipeline.go"
click node_chat "https://github.com/diillson/chatcli/blob/main/cli/chat_pipeline.go"
click node_agent "https://github.com/diillson/chatcli/blob/main/cli/agent/workers/worker_react.go"
click node_policy "https://github.com/diillson/chatcli/blob/main/cli/coder/policy_manager.go"
click node_taskgraph "https://github.com/diillson/chatcli/blob/main/cli/taskgraph/engine.go"
click node_llm "https://github.com/diillson/chatcli/blob/main/llm/manager/llm_manager.go"
click node_quality "https://github.com/diillson/chatcli/blob/main/cli/agent/quality/pipeline.go"
click node_pricing "https://github.com/diillson/chatcli/blob/main/llm/pricing/engine.go"
click node_context "https://github.com/diillson/chatcli/blob/main/cli/ctxmgr/manager.go"
click node_memory "https://github.com/diillson/chatcli/blob/main/cli/workspace/memory.go"
click node_storage "https://github.com/diillson/chatcli/blob/main/cli/storage.go"
click node_mcp "https://github.com/diillson/chatcli/blob/main/cli/mcp/manager.go"
click node_plugins "https://github.com/diillson/chatcli/blob/main/cli/plugins/manager.go"
click node_dashboard "https://github.com/diillson/chatcli/blob/main/cli/pulsedash/server.go"
click node_operator "https://github.com/diillson/chatcli/blob/main/operator/main.go"
click node_rollback "https://github.com/diillson/chatcli/blob/main/operator/controllers/rollback_engine.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_cli,node_webui,node_acp,node_gateway,node_rpcserver,node_terminal,node_editors,node_rpcclient toneBlue
class node_chat,node_agent,node_policy,node_taskgraph toneAmber
class node_llm,node_quality,node_pricing toneMint
class node_context,node_memory,node_storage toneRose
class node_mcp,node_plugins,node_dashboard,node_operator,node_rollback,node_chatapps toneIndigo
```

## Components

### User surfaces

- [Interactive CLI](https://github.com/diillson/chatcli/blob/main/cli/cli.go): `cli/cli.go`
- [Browser UI](https://github.com/diillson/chatcli/blob/main/cli/webui/server.go): `cli/webui/server.go`
- [ACP server](https://github.com/diillson/chatcli/blob/main/cli/rpcserve/acp.go): `cli/rpcserve/acp.go`
- [Chat gateway](https://github.com/diillson/chatcli/blob/main/cli/gateway/gateway.go): `cli/gateway/gateway.go`
- [Pipeline RPC](https://github.com/diillson/chatcli/blob/main/server/pipeline.go): `server/pipeline.go`

### Chat and agent runtime

- [Chat turn pipeline](https://github.com/diillson/chatcli/blob/main/cli/chat_pipeline.go): `cli/chat_pipeline.go`
- [Coder and agents](https://github.com/diillson/chatcli/blob/main/cli/agent/workers/worker_react.go): `cli/agent/workers/worker_react.go`
- [Tool safety policy](https://github.com/diillson/chatcli/blob/main/cli/coder/policy_manager.go): `cli/coder/policy_manager.go`
- [Task graph engine](https://github.com/diillson/chatcli/blob/main/cli/taskgraph/engine.go): `cli/taskgraph/engine.go`

### Models and quality

- [Provider manager](https://github.com/diillson/chatcli/blob/main/llm/manager/llm_manager.go): `llm/manager/llm_manager.go`
- [Quality harness](https://github.com/diillson/chatcli/blob/main/cli/agent/quality/pipeline.go): `cli/agent/quality/pipeline.go`
- [Usage pricing](https://github.com/diillson/chatcli/blob/main/llm/pricing/engine.go): `llm/pricing/engine.go`

### Context and state

- [Context retrieval](https://github.com/diillson/chatcli/blob/main/cli/ctxmgr/manager.go): `cli/ctxmgr/manager.go`
- [Workspace memory](https://github.com/diillson/chatcli/blob/main/cli/workspace/memory.go): `cli/workspace/memory.go`
- [Session and state storage](https://github.com/diillson/chatcli/blob/main/cli/storage.go): `cli/storage.go`

### Integrations and operations

- [MCP integration](https://github.com/diillson/chatcli/blob/main/cli/mcp/manager.go): `cli/mcp/manager.go`
- [Plugin system](https://github.com/diillson/chatcli/blob/main/cli/plugins/manager.go): `cli/plugins/manager.go`
- [Live dashboard](https://github.com/diillson/chatcli/blob/main/cli/pulsedash/server.go): `cli/pulsedash/server.go`
- [Kubernetes operator](https://github.com/diillson/chatcli/blob/main/operator/main.go): `operator/main.go`
- [Rollback controller](https://github.com/diillson/chatcli/blob/main/operator/controllers/rollback_engine.go): `operator/controllers/rollback_engine.go`

### Other components

- **Terminal user**
- **Editor clients**
- **Chat apps**
- **RPC clients**

## Connections

- Terminal user → Interactive CLI: submits turns
- Editor clients → ACP server: send requests
- Chat apps → Chat gateway: send messages
- RPC clients → Pipeline RPC: invoke pipeline
- Interactive CLI → Chat turn pipeline: runs turns
- Chat turn pipeline → Provider manager: requests completions (evidence: `cli/chat_pipeline.go`)
- Chat turn pipeline → Quality harness: uses harness (evidence: `cli/chat_pipeline.go`)
- Chat turn pipeline → Context retrieval: retrieves context
- Chat turn pipeline → Workspace memory: uses memory
- Chat turn pipeline → Session and state storage: persists sessions
- Coder and agents → Tool safety policy: checks tool access
- Coder and agents → Provider manager: requests completions
- Task graph engine → Coder and agents: dispatches workers (evidence: `cli/taskgraph/engine.go`)
- Task graph engine → Session and state storage: saves run state (evidence: `cli/taskgraph/engine.go`)
- Provider manager → Usage pricing: reports usage
- MCP integration → Coder and agents: provides tools
- Plugin system → Coder and agents: extends tools
- Pipeline RPC → Chat turn pipeline: hosts backend
- Pipeline RPC → Coder and agents: runs tasks (evidence: `server/pipeline.go`)
- Browser UI → Chat turn pipeline: serves assistant
- Chat gateway → Chat turn pipeline: shares sessions
- Live dashboard → Kubernetes operator: visualizes runtime
- Kubernetes operator → Rollback controller: uses controller (evidence: `operator/main.go`)
