# tanbiralam/claude-code architecture

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

- Interactive diagram: https://gitdiagram.com/tanbiralam/claude-code
- Repository: https://github.com/tanbiralam/claude-code

## Overview

Claude Code is a terminal-based AI software-engineering assistant. Its central workflow is user input in the terminal UI, prompt processing and model querying, then presentation of responses and tool activity; permissions govern whether actions are allowed. The README also documents slash commands, MCP, persistent sessions and memory, agents, skills, and IDE/remote bridges. Sampled QueryEngine code confirms prompt processing, query dispatch, and session-storage flushing; session-storage excerpts confirm filesystem-backed transcripts. Several documented subsystems are represented by their supported directories or files because their implementation was not sampled.

Main entry points: [`src/components/App.tsx`](https://github.com/tanbiralam/claude-code/blob/main/src/components/App.tsx) (Terminal app), [`src/QueryEngine.ts`](https://github.com/tanbiralam/claude-code/blob/main/src/QueryEngine.ts) (Query engine), [`src/components/PromptInput/PromptInput.tsx`](https://github.com/tanbiralam/claude-code/blob/main/src/components/PromptInput/PromptInput.tsx) (Prompt input), [`src/utils/sessionStorage.ts`](https://github.com/tanbiralam/claude-code/blob/main/src/utils/sessionStorage.ts) (Session transcripts)

## Diagram (Mermaid)

```mermaid
flowchart TD

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

subgraph group_agent["Agent workflow"]
  node_query["Query engine<br/>[QueryEngine.ts]"]
  node_tooltypes["Tool definitions<br/>[Tool.ts]"]
  node_permissions["Tool approvals"]
  node_agents["Agent management<br/>[agents.tsx]"]
  node_tasks["Task management<br/>[useTasksV2.ts]"]
end

subgraph group_state["Session and state"]
  node_sessionstorage[("Session transcripts<br/>[sessionStorage.ts]")]
  node_portable["Portable session reads"]
  node_discovery["Session discovery"]
  node_history["Session history<br/>[sessionHistory.ts]"]
  node_memory["Persistent memory<br/>[memory.tsx]"]
end

subgraph group_integrations["Integrations"]
  node_mcp["MCP management<br/>[index.ts]"]
  node_bridge["IDE bridge<br/>[bridgeMain.ts]"]
  node_remote["Remote sessions<br/>[sessionRunner.ts]"]
end

node_user(("Terminal user"))
node_claude{{"Anthropic API"}}

node_user -->|"uses"| node_app
node_app -->|"renders"| node_prompt
node_app -->|"renders"| node_messages
node_user -->|"invokes"| node_commands
node_prompt -->|"submits input"| node_query
node_query -->|"queries model"| node_claude
node_query -->|"flushes session"| node_sessionstorage
node_sessionstorage -->|"reads transcripts"| node_portable
node_user -->|"responds to approval"| node_permissions
node_user -->|"manages agents"| node_agents
node_user -->|"manages tasks"| node_tasks
node_user -->|"manages memory"| node_memory
node_user -->|"configures servers"| node_mcp
node_bridge -->|"runs sessions"| node_remote

click node_app "https://github.com/tanbiralam/claude-code/blob/main/src/components/App.tsx"
click node_prompt "https://github.com/tanbiralam/claude-code/blob/main/src/components/PromptInput/PromptInput.tsx"
click node_messages "https://github.com/tanbiralam/claude-code/blob/main/src/components/Messages.tsx"
click node_commands "https://github.com/tanbiralam/claude-code/blob/main/src/commands.ts"
click node_query "https://github.com/tanbiralam/claude-code/blob/main/src/QueryEngine.ts"
click node_tooltypes "https://github.com/tanbiralam/claude-code/blob/main/src/Tool.ts"
click node_permissions "https://github.com/tanbiralam/claude-code/blob/main/src/components/permissions/FilePermissionDialog/usePermissionHandler.ts"
click node_agents "https://github.com/tanbiralam/claude-code/blob/main/src/commands/agents/agents.tsx"
click node_tasks "https://github.com/tanbiralam/claude-code/blob/main/src/hooks/useTasksV2.ts"
click node_sessionstorage "https://github.com/tanbiralam/claude-code/blob/main/src/utils/sessionStorage.ts"
click node_portable "https://github.com/tanbiralam/claude-code/blob/main/src/utils/sessionStoragePortable.ts"
click node_discovery "https://github.com/tanbiralam/claude-code/blob/main/src/assistant/sessionDiscovery.ts"
click node_history "https://github.com/tanbiralam/claude-code/blob/main/src/assistant/sessionHistory.ts"
click node_memory "https://github.com/tanbiralam/claude-code/blob/main/src/commands/memory/memory.tsx"
click node_mcp "https://github.com/tanbiralam/claude-code/blob/main/src/components/mcp/index.ts"
click node_bridge "https://github.com/tanbiralam/claude-code/blob/main/src/bridge/bridgeMain.ts"
click node_remote "https://github.com/tanbiralam/claude-code/blob/main/src/bridge/sessionRunner.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_prompt,node_messages,node_commands,node_user toneBlue
class node_query,node_tooltypes,node_permissions,node_agents,node_tasks toneAmber
class node_sessionstorage,node_portable,node_discovery,node_history,node_memory,node_claude toneMint
class node_mcp,node_bridge,node_remote toneRose
```

## Components

### Terminal interaction

- [Terminal app](https://github.com/tanbiralam/claude-code/blob/main/src/components/App.tsx): `src/components/App.tsx`
- [Prompt input](https://github.com/tanbiralam/claude-code/blob/main/src/components/PromptInput/PromptInput.tsx): `src/components/PromptInput/PromptInput.tsx`
- [Conversation display](https://github.com/tanbiralam/claude-code/blob/main/src/components/Messages.tsx): `src/components/Messages.tsx`
- [Slash commands](https://github.com/tanbiralam/claude-code/blob/main/src/commands.ts): `src/commands.ts`

### Agent workflow

- [Query engine](https://github.com/tanbiralam/claude-code/blob/main/src/QueryEngine.ts): `src/QueryEngine.ts`
- [Tool definitions](https://github.com/tanbiralam/claude-code/blob/main/src/Tool.ts): `src/Tool.ts`
- [Tool approvals](https://github.com/tanbiralam/claude-code/blob/main/src/components/permissions/FilePermissionDialog/usePermissionHandler.ts): `src/components/permissions/FilePermissionDialog/usePermissionHandler.ts`
- [Agent management](https://github.com/tanbiralam/claude-code/blob/main/src/commands/agents/agents.tsx): `src/commands/agents/agents.tsx`
- [Task management](https://github.com/tanbiralam/claude-code/blob/main/src/hooks/useTasksV2.ts): `src/hooks/useTasksV2.ts`

### Session and state

- [Session transcripts](https://github.com/tanbiralam/claude-code/blob/main/src/utils/sessionStorage.ts): `src/utils/sessionStorage.ts`
- [Portable session reads](https://github.com/tanbiralam/claude-code/blob/main/src/utils/sessionStoragePortable.ts): `src/utils/sessionStoragePortable.ts`
- [Session discovery](https://github.com/tanbiralam/claude-code/blob/main/src/assistant/sessionDiscovery.ts): `src/assistant/sessionDiscovery.ts`
- [Session history](https://github.com/tanbiralam/claude-code/blob/main/src/assistant/sessionHistory.ts): `src/assistant/sessionHistory.ts`
- [Persistent memory](https://github.com/tanbiralam/claude-code/blob/main/src/commands/memory/memory.tsx): `src/commands/memory/memory.tsx`

### Integrations

- [MCP management](https://github.com/tanbiralam/claude-code/blob/main/src/components/mcp/index.ts): `src/components/mcp/index.ts`
- [IDE bridge](https://github.com/tanbiralam/claude-code/blob/main/src/bridge/bridgeMain.ts): `src/bridge/bridgeMain.ts`
- [Remote sessions](https://github.com/tanbiralam/claude-code/blob/main/src/bridge/sessionRunner.ts): `src/bridge/sessionRunner.ts`

### Other components

- **Terminal user**
- **Anthropic API**

## Connections

- Terminal user → Terminal app: uses
- Terminal app → Prompt input: renders
- Terminal app → Conversation display: renders
- Terminal user → Slash commands: invokes
- Prompt input → Query engine: submits input
- Query engine → Anthropic API: queries model
- Query engine → Session transcripts: flushes session
- Session transcripts → Portable session reads: reads transcripts
- Terminal user → Tool approvals: responds to approval
- Terminal user → Agent management: manages agents
- Terminal user → Task management: manages tasks
- Terminal user → Persistent memory: manages memory
- Terminal user → MCP management: configures servers
- IDE bridge → Remote sessions: runs sessions
