# gitlawb/openclaude architecture

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

- Interactive diagram: https://gitdiagram.com/gitlawb/openclaude
- Repository: https://github.com/gitlawb/openclaude

## Overview

OpenClaude is a terminal-first coding-agent CLI spanning local and hosted model providers. The principal workflow takes a user prompt, builds system context, runs model/tool interactions, streams results, and persists conversation history. Supporting capabilities include provider setup, agents and tasks, MCP and plugins, and session resume. The QueryEngine excerpts establish its context, input-processing, and transcript-storage calls; other subsystem links reflect README-described capabilities, not inspected call sites.

Main entry points: [`src/QueryEngine.ts`](https://github.com/gitlawb/openclaude/blob/main/src/QueryEngine.ts) (Query engine), [`src/commands.ts`](https://github.com/gitlawb/openclaude/blob/main/src/commands.ts) (Slash commands), [`src/components/App.tsx`](https://github.com/gitlawb/openclaude/blob/main/src/components/App.tsx) (Terminal app), [`src/components/PromptInput/PromptInput.tsx`](https://github.com/gitlawb/openclaude/blob/main/src/components/PromptInput/PromptInput.tsx) (Prompt input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Terminal interaction"]
  node_app["Terminal app<br/>[App.tsx]"]
  node_input["Prompt input<br/>[PromptInput.tsx]"]
  node_commands["Slash commands<br/>[commands.ts]"]
end

subgraph group_runtime["Agent runtime"]
  node_query["Query engine<br/>[QueryEngine.ts]"]
  node_context["System context<br/>[queryContext.ts]"]
  node_tools["Tool execution<br/>[Tool.ts]"]
  node_tasks["Task workflows<br/>[Task.ts]"]
  node_agents["Worker agents<br/>[workerAgent.ts]"]
end

subgraph group_extensions["Extensibility"]
  node_mcp["MCP setup"]
  node_plugins["Plugin management"]
end

subgraph group_providers["Model providers"]
  node_providerui["Provider manager"]
  node_model["Model backend"]
end

subgraph group_state["Session and settings"]
  node_transcript[("Transcript storage<br/>[sessionStorage.ts]")]
  node_portable["Portable session tools"]
  node_settings[("Provider settings")]
end

node_user(("CLI user"))
node_llm{{"Cloud or local model"}}

node_user -->|"starts CLI"| node_app
node_user -->|"enters prompt"| node_input
node_app -->|"presents"| node_input
node_app -->|"dispatches"| node_commands
node_input -->|"submits prompt"| node_query
node_query -->|"fetches context"| node_context
node_query -->|"runs interactions"| node_tools
node_query -->|"records history"| node_transcript
node_query -->|"selects model"| node_model
node_model -->|"sends requests"| node_llm
node_query -->|"provides agent definitions"| node_agents
node_query -.->|"supports task workflows"| node_tasks
node_commands -.->|"opens setup"| node_providerui
node_providerui -->|"updates profiles"| node_settings
node_commands -.->|"configures MCP"| node_mcp
node_commands -.->|"manages plugins"| node_plugins
node_portable -.->|"supports session reads"| node_transcript
node_transcript -.->|"restores history"| node_app

click node_app "https://github.com/gitlawb/openclaude/blob/main/src/components/App.tsx"
click node_input "https://github.com/gitlawb/openclaude/blob/main/src/components/PromptInput/PromptInput.tsx"
click node_commands "https://github.com/gitlawb/openclaude/blob/main/src/commands.ts"
click node_query "https://github.com/gitlawb/openclaude/blob/main/src/QueryEngine.ts"
click node_context "https://github.com/gitlawb/openclaude/blob/main/src/utils/queryContext.ts"
click node_tools "https://github.com/gitlawb/openclaude/blob/main/src/Tool.ts"
click node_tasks "https://github.com/gitlawb/openclaude/blob/main/src/Task.ts"
click node_agents "https://github.com/gitlawb/openclaude/blob/main/src/coordinator/workerAgent.ts"
click node_providerui "https://github.com/gitlawb/openclaude/blob/main/src/components/ProviderManager.tsx"
click node_mcp "https://github.com/gitlawb/openclaude/tree/main/src/commands/mcp"
click node_plugins "https://github.com/gitlawb/openclaude/tree/main/src/commands/plugin"
click node_transcript "https://github.com/gitlawb/openclaude/blob/main/src/utils/sessionStorage.ts"
click node_portable "https://github.com/gitlawb/openclaude/blob/main/src/utils/sessionStoragePortable.ts"

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_app,node_input,node_commands,node_user toneBlue
class node_query,node_context,node_tools,node_tasks,node_agents toneAmber
class node_mcp,node_plugins toneMint
class node_providerui,node_model toneRose
class node_transcript,node_portable,node_settings,node_llm toneIndigo
```

## Components

### Terminal interaction

- [Terminal app](https://github.com/gitlawb/openclaude/blob/main/src/components/App.tsx): `src/components/App.tsx`
- [Prompt input](https://github.com/gitlawb/openclaude/blob/main/src/components/PromptInput/PromptInput.tsx): `src/components/PromptInput/PromptInput.tsx`
- [Slash commands](https://github.com/gitlawb/openclaude/blob/main/src/commands.ts): `src/commands.ts`

### Agent runtime

- [Query engine](https://github.com/gitlawb/openclaude/blob/main/src/QueryEngine.ts): `src/QueryEngine.ts`
- [System context](https://github.com/gitlawb/openclaude/blob/main/src/utils/queryContext.ts): `src/utils/queryContext.ts`
- [Tool execution](https://github.com/gitlawb/openclaude/blob/main/src/Tool.ts): `src/Tool.ts`
- [Task workflows](https://github.com/gitlawb/openclaude/blob/main/src/Task.ts): `src/Task.ts`
- [Worker agents](https://github.com/gitlawb/openclaude/blob/main/src/coordinator/workerAgent.ts): `src/coordinator/workerAgent.ts`

### Extensibility

- [MCP setup](https://github.com/gitlawb/openclaude/tree/main/src/commands/mcp): `src/commands/mcp`
- [Plugin management](https://github.com/gitlawb/openclaude/tree/main/src/commands/plugin): `src/commands/plugin`

### Model providers

- [Provider manager](https://github.com/gitlawb/openclaude/blob/main/src/components/ProviderManager.tsx): `src/components/ProviderManager.tsx`
- **Model backend**

### Session and settings

- [Transcript storage](https://github.com/gitlawb/openclaude/blob/main/src/utils/sessionStorage.ts): `src/utils/sessionStorage.ts`
- [Portable session tools](https://github.com/gitlawb/openclaude/blob/main/src/utils/sessionStoragePortable.ts): `src/utils/sessionStoragePortable.ts`
- **Provider settings**

### Other components

- **CLI user**
- **Cloud or local model**

## Connections

- CLI user → Terminal app: starts CLI
- CLI user → Prompt input: enters prompt
- Terminal app → Prompt input: presents
- Terminal app → Slash commands: dispatches
- Prompt input → Query engine: submits prompt
- Query engine → System context: fetches context
- Query engine → Tool execution: runs interactions
- Query engine → Transcript storage: records history
- Query engine → Model backend: selects model
- Model backend → Cloud or local model: sends requests
- Query engine → Worker agents: provides agent definitions
- Query engine → Task workflows: supports task workflows
- Slash commands → Provider manager: opens setup
- Provider manager → Provider settings: updates profiles
- Slash commands → MCP setup: configures MCP
- Slash commands → Plugin management: manages plugins
- Portable session tools → Transcript storage: supports session reads
- Transcript storage → Terminal app: restores history
