# garrytan/openclaw architecture

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

- Interactive diagram: https://gitdiagram.com/garrytan/openclaw
- Repository: https://github.com/garrytan/openclaw

## Overview

OpenClaw is a self-hosted personal AI assistant: users message it through supported channels or the CLI, the Gateway coordinates assistant sessions and tools, and replies can be delivered back through connected channels. The repository also includes browser and memory extensions, control-plane and task subsystems, and native mobile/desktop clients with voice, Canvas, and device capabilities. The README documents the product-level workflow and capabilities; source excerpts are selective, so links between unsampled subsystems are omitted rather than inferred.

Main entry points: [`src/gateway`](https://github.com/garrytan/openclaw/tree/main/src/gateway) (Gateway), [`src/agents`](https://github.com/garrytan/openclaw/tree/main/src/agents) (Agent runtime), [`extensions`](https://github.com/garrytan/openclaw/tree/main/extensions) (Messaging channels), [`src/cli/route.ts`](https://github.com/garrytan/openclaw/blob/main/src/cli/route.ts) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry points"]
  node_cli["CLI<br/>[route.ts]"]
  node_controlui[("Control UI storage<br/>[storage.ts]")]
end

subgraph group_assistant["Assistant runtime"]
  node_reply["Reply pipeline"]
  node_agent["Agent runtime"]
  node_modelauth["Model authentication<br/>[model-auth.ts]"]
  node_toolpolicy["Tool policy"]
  node_context["Context engine"]
  node_maintenance["Context maintenance"]
  node_embedding["Embedding services"]
end

subgraph group_integrations["Channels and extensions"]
  node_channels["Messaging channels"]
  node_memory["Memory extension"]
  node_browser["Browser extension<br/>[server-context.ts]"]
end

subgraph group_clients["Native clients"]
  node_mobile["Mobile clients<br/>[MainActivity.kt]"]
  node_iosshare["iOS share"]
  node_swabble["Speech tools"]
end

subgraph group_platform["Control plane"]
  node_gateway["Gateway"]
  node_tasks["Task executor<br/>[task-executor.ts]"]
  node_acp["ACP control plane<br/>[manager.core.ts]"]
  node_delivery[("Delivery queue")]
end

node_user(("User"))

node_user -->|"issues commands"| node_cli
node_user -->|"sends messages"| node_channels
node_cli -->|"starts or addresses"| node_gateway
node_channels -->|"connect to"| node_gateway
node_gateway -->|"coordinates sessions"| node_agent
node_agent -.->|"produces replies"| node_reply
node_reply -->|"delivers replies"| node_channels
node_agent -->|"resolves credentials"| node_modelauth
node_agent -->|"applies tool policy"| node_toolpolicy
node_agent -->|"assembles context"| node_context
node_maintenance -->|"schedules work"| node_tasks
node_gateway -.->|"supports control plane"| node_acp
node_memory -.->|"uses embedding services"| node_embedding
node_user -->|"uses assistant apps"| node_mobile
node_mobile -.->|"connects to"| node_gateway
node_iosshare -->|"sends node events"| node_gateway
node_user -.->|"configures interface"| node_controlui
node_user -->|"speaks or listens"| node_swabble
node_agent -.->|"uses browser tools"| node_browser
node_delivery -.->|"stores outbound delivery"| node_gateway

click node_cli "https://github.com/garrytan/openclaw/blob/main/src/cli/route.ts"
click node_gateway "https://github.com/garrytan/openclaw/tree/main/src/gateway"
click node_channels "https://github.com/garrytan/openclaw/tree/main/extensions"
click node_reply "https://github.com/garrytan/openclaw/blob/main/src/auto-reply/reply/block-reply-pipeline.ts"
click node_agent "https://github.com/garrytan/openclaw/tree/main/src/agents"
click node_modelauth "https://github.com/garrytan/openclaw/blob/main/src/agents/model-auth.ts"
click node_toolpolicy "https://github.com/garrytan/openclaw/blob/main/src/agents/tool-policy-pipeline.ts"
click node_context "https://github.com/garrytan/openclaw/blob/main/src/agents/pi-embedded-runner/run/attempt.context-engine-helpers.ts"
click node_maintenance "https://github.com/garrytan/openclaw/blob/main/src/agents/pi-embedded-runner/context-engine-maintenance.ts"
click node_tasks "https://github.com/garrytan/openclaw/blob/main/src/tasks/task-executor.ts"
click node_acp "https://github.com/garrytan/openclaw/blob/main/src/acp/control-plane/manager.core.ts"
click node_delivery "https://github.com/garrytan/openclaw/blob/main/src/infra/outbound/delivery-queue-storage.ts"
click node_memory "https://github.com/garrytan/openclaw/blob/main/extensions/memory-core/src/memory/manager-embedding-ops.ts"
click node_embedding "https://github.com/garrytan/openclaw/blob/main/src/memory-host-sdk/engine-embeddings.ts"
click node_browser "https://github.com/garrytan/openclaw/blob/main/extensions/browser/src/browser/server-context.ts"
click node_controlui "https://github.com/garrytan/openclaw/blob/main/ui/src/ui/storage.ts"
click node_mobile "https://github.com/garrytan/openclaw/blob/main/apps/android/app/src/main/java/ai/openclaw/app/MainActivity.kt"
click node_iosshare "https://github.com/garrytan/openclaw/blob/main/apps/ios/ShareExtension/ShareViewController.swift"
click node_swabble "https://github.com/garrytan/openclaw/blob/main/Swabble/Sources/SwabbleCore/Speech/SpeechPipeline.swift"

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_controlui,node_user toneBlue
class node_reply,node_agent,node_modelauth,node_toolpolicy,node_context,node_maintenance,node_embedding toneAmber
class node_channels,node_memory,node_browser toneMint
class node_mobile,node_iosshare,node_swabble toneRose
class node_gateway,node_tasks,node_acp,node_delivery toneIndigo
```

## Components

### User entry points

- [CLI](https://github.com/garrytan/openclaw/blob/main/src/cli/route.ts): `src/cli/route.ts`
- [Control UI storage](https://github.com/garrytan/openclaw/blob/main/ui/src/ui/storage.ts): `ui/src/ui/storage.ts`

### Assistant runtime

- [Reply pipeline](https://github.com/garrytan/openclaw/blob/main/src/auto-reply/reply/block-reply-pipeline.ts): `src/auto-reply/reply/block-reply-pipeline.ts`
- [Agent runtime](https://github.com/garrytan/openclaw/tree/main/src/agents): `src/agents`
- [Model authentication](https://github.com/garrytan/openclaw/blob/main/src/agents/model-auth.ts): `src/agents/model-auth.ts`
- [Tool policy](https://github.com/garrytan/openclaw/blob/main/src/agents/tool-policy-pipeline.ts): `src/agents/tool-policy-pipeline.ts`
- [Context engine](https://github.com/garrytan/openclaw/blob/main/src/agents/pi-embedded-runner/run/attempt.context-engine-helpers.ts): `src/agents/pi-embedded-runner/run/attempt.context-engine-helpers.ts`
- [Context maintenance](https://github.com/garrytan/openclaw/blob/main/src/agents/pi-embedded-runner/context-engine-maintenance.ts): `src/agents/pi-embedded-runner/context-engine-maintenance.ts`
- [Embedding services](https://github.com/garrytan/openclaw/blob/main/src/memory-host-sdk/engine-embeddings.ts): `src/memory-host-sdk/engine-embeddings.ts`

### Channels and extensions

- [Messaging channels](https://github.com/garrytan/openclaw/tree/main/extensions): `extensions`
- [Memory extension](https://github.com/garrytan/openclaw/blob/main/extensions/memory-core/src/memory/manager-embedding-ops.ts): `extensions/memory-core/src/memory/manager-embedding-ops.ts`
- [Browser extension](https://github.com/garrytan/openclaw/blob/main/extensions/browser/src/browser/server-context.ts): `extensions/browser/src/browser/server-context.ts`

### Native clients

- [Mobile clients](https://github.com/garrytan/openclaw/blob/main/apps/android/app/src/main/java/ai/openclaw/app/MainActivity.kt): `apps/android/app/src/main/java/ai/openclaw/app/MainActivity.kt`
- [iOS share](https://github.com/garrytan/openclaw/blob/main/apps/ios/ShareExtension/ShareViewController.swift): `apps/ios/ShareExtension/ShareViewController.swift`
- [Speech tools](https://github.com/garrytan/openclaw/blob/main/Swabble/Sources/SwabbleCore/Speech/SpeechPipeline.swift): `Swabble/Sources/SwabbleCore/Speech/SpeechPipeline.swift`

### Control plane

- [Gateway](https://github.com/garrytan/openclaw/tree/main/src/gateway): `src/gateway`
- [Task executor](https://github.com/garrytan/openclaw/blob/main/src/tasks/task-executor.ts): `src/tasks/task-executor.ts`
- [ACP control plane](https://github.com/garrytan/openclaw/blob/main/src/acp/control-plane/manager.core.ts): `src/acp/control-plane/manager.core.ts`
- [Delivery queue](https://github.com/garrytan/openclaw/blob/main/src/infra/outbound/delivery-queue-storage.ts): `src/infra/outbound/delivery-queue-storage.ts`

### Other components

- **User**

## Connections

- User → CLI: issues commands (evidence: `README.md`)
- User → Messaging channels: sends messages (evidence: `README.md`)
- CLI → Gateway: starts or addresses (evidence: `README.md`)
- Messaging channels → Gateway: connect to (evidence: `README.md`)
- Gateway → Agent runtime: coordinates sessions (evidence: `README.md`)
- Agent runtime → Reply pipeline: produces replies
- Reply pipeline → Messaging channels: delivers replies (evidence: `README.md`)
- Agent runtime → Model authentication: resolves credentials (evidence: `src/agents/model-auth.ts`)
- Agent runtime → Tool policy: applies tool policy (evidence: `src/agents/tool-policy-pipeline.ts`)
- Agent runtime → Context engine: assembles context (evidence: `src/agents/pi-embedded-runner/run/attempt.context-engine-helpers.ts`)
- Context maintenance → Task executor: schedules work (evidence: `src/agents/pi-embedded-runner/context-engine-maintenance.ts`)
- Gateway → ACP control plane: supports control plane
- Memory extension → Embedding services: uses embedding services
- User → Mobile clients: uses assistant apps (evidence: `README.md`)
- Mobile clients → Gateway: connects to
- iOS share → Gateway: sends node events (evidence: `apps/ios/ShareExtension/ShareViewController.swift`)
- User → Control UI storage: configures interface
- User → Speech tools: speaks or listens (evidence: `README.md`)
- Agent runtime → Browser extension: uses browser tools
- Delivery queue → Gateway: stores outbound delivery
