# draht-dev/draht architecture

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

- Interactive diagram: https://gitdiagram.com/draht-dev/draht
- Repository: https://github.com/draht-dev/draht

## Overview

draht is a monorepo of AI-agent and LLM tooling. The principal user workflow is interacting with the coding-agent CLI: it configures a session, runs an agent against an LLM, invokes tools against the working tree, and presents results. Other documented product branches include the unified multi-provider API, agent runtime, Slack bot, terminal and web interfaces, and vLLM deployment tooling. The graph combines README capabilities with the supplied source index and excerpts; unsampled subsystems are represented at supported directory paths, and their internal links are omitted where wiring is not shown.

Main entry points: [`packages/coding-agent/src/cli.ts`](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/cli.ts) (Coding CLI), [`packages/coding-agent/src/core/agent-session.ts`](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/agent-session.ts) (Agent session), [`packages/agent/src/harness/agent-harness.ts`](https://github.com/draht-dev/draht/blob/main/packages/agent/src/harness/agent-harness.ts) (Agent harness), [`packages/mom/src/main.ts`](https://github.com/draht-dev/draht/blob/main/packages/mom/src/main.ts) (Slack bot)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_coding["Coding agent"]
  node_cli["Coding CLI<br/>[cli.ts]"]
  node_session["Agent session<br/>[agent-session.ts]"]
  node_settings[("Settings")]
  node_credentials[("Credentials<br/>[auth-storage.ts]")]
  node_packages["Package manager<br/>[package-manager.ts]"]
  node_extensions["Extensions<br/>[runner.ts]"]
  node_checkpoints[("Checkpoints")]
  node_tools["Coding tools"]
end

subgraph group_runtime["Agent runtime"]
  node_agent["Agent harness<br/>[agent-harness.ts]"]
  node_agent_sessions[("Session storage<br/>[session.ts]")]
end

subgraph group_models["LLM services"]
  node_ai["Provider API"]
  node_providers["Model providers"]
  node_router["Model router<br/>[router.ts]"]
end

subgraph group_interfaces["Agent interfaces"]
  node_mom["Slack bot<br/>[main.ts]"]
  node_gateway["Session gateway<br/>[server.ts]"]
  node_gateway_sessions[("Session manager<br/>[session-manager.ts]")]
  node_terminal["Terminal UI<br/>[tui.ts]"]
  node_web["Web chat UI"]
end

subgraph group_analysis["Code analysis"]
  node_go_cli["draht-tools CLI<br/>[main.go]"]
  node_graph["Graph pipeline<br/>[pipeline.go]"]
  node_serve["Graph server<br/>[server.go]"]
end

node_user(("Engineer"))
node_workspace["Code workspace"]
node_llm{{"LLM services"}}
node_slack{{"Slack"}}
node_vllm{{"GPU deployments"}}

node_user -->|"uses"| node_cli
node_cli -.->|"starts session"| node_session
node_session -.->|"runs agent"| node_agent
node_agent -->|"stores sessions"| node_agent_sessions
node_session -.->|"invokes tools"| node_tools
node_tools -.->|"reads and edits"| node_workspace
node_session -.->|"requests completions"| node_ai
node_ai -.->|"dispatches requests"| node_providers
node_providers -.->|"calls APIs"| node_llm
node_cli -->|"configures"| node_settings
node_cli -.->|"loads credentials"| node_credentials
node_cli -->|"resolves packages"| node_packages
node_cli -.->|"loads extensions"| node_extensions
node_session -.->|"captures state"| node_checkpoints
node_mom -.->|"handles messages"| node_slack
node_mom -->|"delegates work"| node_agent
node_user -.->|"connects"| node_gateway
node_gateway -->|"manages sessions"| node_gateway_sessions
node_user -->|"uses"| node_terminal
node_user -->|"uses"| node_web
node_user -.->|"runs analysis"| node_go_cli
node_go_cli -->|"builds graph"| node_graph
node_graph -.->|"serves graph"| node_serve
node_user -->|"manages deployments"| node_vllm
node_router -.->|"routes requests"| node_llm

click node_cli "https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/cli.ts"
click node_session "https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/agent-session.ts"
click node_settings "https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/settings-manager.ts"
click node_credentials "https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/auth-storage.ts"
click node_packages "https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/package-manager.ts"
click node_extensions "https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/extensions/runner.ts"
click node_checkpoints "https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/checkpoints/checkpoint-manager.ts"
click node_tools "https://github.com/draht-dev/draht/tree/main/packages/coding-agent/src/core/tools"
click node_agent "https://github.com/draht-dev/draht/blob/main/packages/agent/src/harness/agent-harness.ts"
click node_agent_sessions "https://github.com/draht-dev/draht/blob/main/packages/agent/src/harness/session/session.ts"
click node_ai "https://github.com/draht-dev/draht/tree/main/packages/ai/src"
click node_providers "https://github.com/draht-dev/draht/tree/main/packages/ai/src/providers"
click node_router "https://github.com/draht-dev/draht/blob/main/packages/router/src/router.ts"
click node_mom "https://github.com/draht-dev/draht/blob/main/packages/mom/src/main.ts"
click node_gateway "https://github.com/draht-dev/draht/blob/main/packages/gateway/src/gateway/server.ts"
click node_gateway_sessions "https://github.com/draht-dev/draht/blob/main/packages/gateway/src/session/session-manager.ts"
click node_terminal "https://github.com/draht-dev/draht/blob/main/packages/tui/src/tui.ts"
click node_web "https://github.com/draht-dev/draht/tree/main/packages/web-ui/src"
click node_go_cli "https://github.com/draht-dev/draht/blob/main/go/cmd/draht-tools/main.go"
click node_graph "https://github.com/draht-dev/draht/blob/main/go/internal/graph/pipeline.go"
click node_serve "https://github.com/draht-dev/draht/blob/main/go/internal/serve/server.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_session,node_settings,node_credentials,node_packages,node_extensions,node_checkpoints,node_tools toneBlue
class node_agent,node_agent_sessions toneAmber
class node_ai,node_providers,node_router toneMint
class node_mom,node_gateway,node_gateway_sessions,node_terminal,node_web toneRose
class node_go_cli,node_graph,node_serve,node_user,node_workspace,node_llm,node_slack,node_vllm toneIndigo
```

## Components

### Coding agent

- [Coding CLI](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/cli.ts): `packages/coding-agent/src/cli.ts`
- [Agent session](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/agent-session.ts): `packages/coding-agent/src/core/agent-session.ts`
- [Settings](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/settings-manager.ts): `packages/coding-agent/src/core/settings-manager.ts`
- [Credentials](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/auth-storage.ts): `packages/coding-agent/src/core/auth-storage.ts`
- [Package manager](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/package-manager.ts): `packages/coding-agent/src/core/package-manager.ts`
- [Extensions](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/extensions/runner.ts): `packages/coding-agent/src/core/extensions/runner.ts`
- [Checkpoints](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/src/core/checkpoints/checkpoint-manager.ts): `packages/coding-agent/src/core/checkpoints/checkpoint-manager.ts`
- [Coding tools](https://github.com/draht-dev/draht/tree/main/packages/coding-agent/src/core/tools): `packages/coding-agent/src/core/tools`

### Agent runtime

- [Agent harness](https://github.com/draht-dev/draht/blob/main/packages/agent/src/harness/agent-harness.ts): `packages/agent/src/harness/agent-harness.ts`
- [Session storage](https://github.com/draht-dev/draht/blob/main/packages/agent/src/harness/session/session.ts): `packages/agent/src/harness/session/session.ts`

### LLM services

- [Provider API](https://github.com/draht-dev/draht/tree/main/packages/ai/src): `packages/ai/src`
- [Model providers](https://github.com/draht-dev/draht/tree/main/packages/ai/src/providers): `packages/ai/src/providers`
- [Model router](https://github.com/draht-dev/draht/blob/main/packages/router/src/router.ts): `packages/router/src/router.ts`

### Agent interfaces

- [Slack bot](https://github.com/draht-dev/draht/blob/main/packages/mom/src/main.ts): `packages/mom/src/main.ts`
- [Session gateway](https://github.com/draht-dev/draht/blob/main/packages/gateway/src/gateway/server.ts): `packages/gateway/src/gateway/server.ts`
- [Session manager](https://github.com/draht-dev/draht/blob/main/packages/gateway/src/session/session-manager.ts): `packages/gateway/src/session/session-manager.ts`
- [Terminal UI](https://github.com/draht-dev/draht/blob/main/packages/tui/src/tui.ts): `packages/tui/src/tui.ts`
- [Web chat UI](https://github.com/draht-dev/draht/tree/main/packages/web-ui/src): `packages/web-ui/src`

### Code analysis

- [draht-tools CLI](https://github.com/draht-dev/draht/blob/main/go/cmd/draht-tools/main.go): `go/cmd/draht-tools/main.go`
- [Graph pipeline](https://github.com/draht-dev/draht/blob/main/go/internal/graph/pipeline.go): `go/internal/graph/pipeline.go`
- [Graph server](https://github.com/draht-dev/draht/blob/main/go/internal/serve/server.go): `go/internal/serve/server.go`

### Other components

- **Engineer**
- **Code workspace**
- **LLM services**
- **Slack**
- **GPU deployments**

## Connections

- Engineer → Coding CLI: uses (evidence: `README.md`)
- Coding CLI → Agent session: starts session
- Agent session → Agent harness: runs agent
- Agent harness → Session storage: stores sessions (evidence: `packages/agent/src/harness/types.ts`)
- Agent session → Coding tools: invokes tools
- Coding tools → Code workspace: reads and edits
- Agent session → Provider API: requests completions
- Provider API → Model providers: dispatches requests
- Model providers → LLM services: calls APIs
- Coding CLI → Settings: configures
- Coding CLI → Credentials: loads credentials
- Coding CLI → Package manager: resolves packages
- Coding CLI → Extensions: loads extensions
- Agent session → Checkpoints: captures state
- Slack bot → Slack: handles messages
- Slack bot → Agent harness: delegates work (evidence: `packages/mom/src/main.ts`)
- Engineer → Session gateway: connects
- Session gateway → Session manager: manages sessions (evidence: `packages/gateway/src/gateway/server.ts`)
- Engineer → Terminal UI: uses (evidence: `README.md`)
- Engineer → Web chat UI: uses (evidence: `README.md`)
- Engineer → draht-tools CLI: runs analysis
- draht-tools CLI → Graph pipeline: builds graph (evidence: `go/cmd/draht-tools/main.go`)
- Graph pipeline → Graph server: serves graph
- Engineer → GPU deployments: manages deployments (evidence: `README.md`)
- Model router → LLM services: routes requests
