# devswha/herdr-web-ui architecture

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

- Interactive diagram: https://gitdiagram.com/devswha/herdr-web-ui
- Repository: https://github.com/devswha/herdr-web-ui

## Overview

herdr web ui is a browser and phone client for agent sessions managed by herdr. A user selects a machine and workspace, views an agent conversation or its live terminal, and sends replies or answers approval prompts; the server bridges UI requests to herdr and agent-specific session handling. Other documented capabilities include worktrees, file viewing and image uploads, push alerts, settings, updates, and voice input. Connections below follow the README and SOURCE INDEX references; unsampled feature internals are represented by their directory where possible.

Main entry points: [`src/App.tsx`](https://github.com/devswha/herdr-web-ui/blob/main/src/App.tsx) (App shell), [`server/index.ts`](https://github.com/devswha/herdr-web-ui/blob/main/server/index.ts) (HTTP and event routing), [`src/lib/machineContext.tsx`](https://github.com/devswha/herdr-web-ui/blob/main/src/lib/machineContext.tsx) (Machine API context), [`src/lib/api.ts`](https://github.com/devswha/herdr-web-ui/blob/main/src/lib/api.ts) (HTTP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web and phone client"]
  node_app["App shell<br/>[App.tsx]"]
  node_chat["Chat view<br/>[ChatView.tsx]"]
  node_terminal["Live terminal<br/>[PaneTerminal.tsx]"]
  node_newsession["Session creation"]
  node_settings["Settings<br/>[SettingsDialog.tsx]"]
  node_machinecontext["Machine API context<br/>[machineContext.tsx]"]
  node_api["HTTP client<br/>[api.ts]"]
  node_background["Background tasks"]
end

subgraph group_contract["Shared client contract"]
  node_protocol["Wire contract<br/>[protocol.ts]"]
  node_machines["Machine types<br/>[machines.ts]"]
end

subgraph group_server["Bridge server"]
  node_serverentry["HTTP and event routing<br/>[index.ts]"]
  node_auth["Access control<br/>[auth.ts]"]
  node_herdrclient["herdr client<br/>[client.ts]"]
end

subgraph group_sessions["Agent sessions"]
  node_conversation["Conversation service<br/>[conversation.ts]"]
  node_agentadapters["Agent integrations"]
end

subgraph group_capabilities["Product capabilities"]
  node_filetools["Files and attachments<br/>[files.ts]"]
  node_push["Push alerts<br/>[push.ts]"]
  node_updates["Updates<br/>[update-api.ts]"]
  node_voice["Voice input<br/>[voice.ts]"]
end

node_user(("User"))
node_herdr["herdr runtime"]

node_user -->|"uses"| node_app
node_app -->|"selects machine"| node_machinecontext
node_app -->|"shows conversation"| node_chat
node_app -->|"shows pane"| node_terminal
node_user -->|"creates session"| node_newsession
node_newsession -->|"creates workspace"| node_machinecontext
node_user -->|"configures"| node_settings
node_machinecontext -->|"binds requests"| node_api
node_api -->|"uses types"| node_protocol
node_machinecontext -->|"uses types"| node_machines
node_api -.->|"calls API"| node_serverentry
node_serverentry -->|"checks access"| node_auth
node_serverentry -->|"routes session work"| node_conversation
node_serverentry -->|"requests pane data"| node_herdrclient
node_conversation -->|"reads pane state"| node_herdrclient
node_conversation -->|"dispatches sessions"| node_agentadapters
node_herdrclient -.->|"uses runtime API"| node_herdr
node_serverentry -->|"routes file requests"| node_filetools
node_serverentry -->|"routes push requests"| node_push
node_app -->|"enables alerts"| node_push
node_app -->|"checks updates"| node_updates
node_chat -.->|"accepts dictation"| node_voice
node_terminal -.->|"accepts dictation"| node_voice
node_background -->|"fetches activity"| node_machinecontext
node_machinecontext -->|"fetches task activity"| node_api

click node_app "https://github.com/devswha/herdr-web-ui/blob/main/src/App.tsx"
click node_chat "https://github.com/devswha/herdr-web-ui/blob/main/src/components/ChatView.tsx"
click node_terminal "https://github.com/devswha/herdr-web-ui/blob/main/src/components/PaneTerminal.tsx"
click node_newsession "https://github.com/devswha/herdr-web-ui/blob/main/src/components/NewSessionDialog.tsx"
click node_settings "https://github.com/devswha/herdr-web-ui/blob/main/src/components/SettingsDialog.tsx"
click node_machinecontext "https://github.com/devswha/herdr-web-ui/blob/main/src/lib/machineContext.tsx"
click node_api "https://github.com/devswha/herdr-web-ui/blob/main/src/lib/api.ts"
click node_protocol "https://github.com/devswha/herdr-web-ui/blob/main/shared/protocol.ts"
click node_machines "https://github.com/devswha/herdr-web-ui/blob/main/shared/machines.ts"
click node_serverentry "https://github.com/devswha/herdr-web-ui/blob/main/server/index.ts"
click node_auth "https://github.com/devswha/herdr-web-ui/blob/main/server/auth.ts"
click node_herdrclient "https://github.com/devswha/herdr-web-ui/blob/main/server/herdr/client.ts"
click node_conversation "https://github.com/devswha/herdr-web-ui/blob/main/server/conversation.ts"
click node_agentadapters "https://github.com/devswha/herdr-web-ui/tree/main/server"
click node_filetools "https://github.com/devswha/herdr-web-ui/blob/main/server/files.ts"
click node_push "https://github.com/devswha/herdr-web-ui/blob/main/server/push.ts"
click node_updates "https://github.com/devswha/herdr-web-ui/blob/main/server/update-api.ts"
click node_voice "https://github.com/devswha/herdr-web-ui/blob/main/server/voice.ts"
click node_background "https://github.com/devswha/herdr-web-ui/blob/main/src/components/BackgroundTasks.tsx"

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_chat,node_terminal,node_newsession,node_settings,node_machinecontext,node_api,node_background,node_user toneBlue
class node_protocol,node_machines toneAmber
class node_serverentry,node_auth,node_herdrclient toneMint
class node_conversation,node_agentadapters toneRose
class node_filetools,node_push,node_updates,node_voice,node_herdr toneIndigo
```

## Components

### Web and phone client

- [App shell](https://github.com/devswha/herdr-web-ui/blob/main/src/App.tsx): `src/App.tsx`
- [Chat view](https://github.com/devswha/herdr-web-ui/blob/main/src/components/ChatView.tsx): `src/components/ChatView.tsx`
- [Live terminal](https://github.com/devswha/herdr-web-ui/blob/main/src/components/PaneTerminal.tsx): `src/components/PaneTerminal.tsx`
- [Session creation](https://github.com/devswha/herdr-web-ui/blob/main/src/components/NewSessionDialog.tsx): `src/components/NewSessionDialog.tsx`
- [Settings](https://github.com/devswha/herdr-web-ui/blob/main/src/components/SettingsDialog.tsx): `src/components/SettingsDialog.tsx`
- [Machine API context](https://github.com/devswha/herdr-web-ui/blob/main/src/lib/machineContext.tsx): `src/lib/machineContext.tsx`
- [HTTP client](https://github.com/devswha/herdr-web-ui/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [Background tasks](https://github.com/devswha/herdr-web-ui/blob/main/src/components/BackgroundTasks.tsx): `src/components/BackgroundTasks.tsx`

### Shared client contract

- [Wire contract](https://github.com/devswha/herdr-web-ui/blob/main/shared/protocol.ts): `shared/protocol.ts`
- [Machine types](https://github.com/devswha/herdr-web-ui/blob/main/shared/machines.ts): `shared/machines.ts`

### Bridge server

- [HTTP and event routing](https://github.com/devswha/herdr-web-ui/blob/main/server/index.ts): `server/index.ts`
- [Access control](https://github.com/devswha/herdr-web-ui/blob/main/server/auth.ts): `server/auth.ts`
- [herdr client](https://github.com/devswha/herdr-web-ui/blob/main/server/herdr/client.ts): `server/herdr/client.ts`

### Agent sessions

- [Conversation service](https://github.com/devswha/herdr-web-ui/blob/main/server/conversation.ts): `server/conversation.ts`
- [Agent integrations](https://github.com/devswha/herdr-web-ui/tree/main/server): `server`

### Product capabilities

- [Files and attachments](https://github.com/devswha/herdr-web-ui/blob/main/server/files.ts): `server/files.ts`
- [Push alerts](https://github.com/devswha/herdr-web-ui/blob/main/server/push.ts): `server/push.ts`
- [Updates](https://github.com/devswha/herdr-web-ui/blob/main/server/update-api.ts): `server/update-api.ts`
- [Voice input](https://github.com/devswha/herdr-web-ui/blob/main/server/voice.ts): `server/voice.ts`

### Other components

- **User**
- **herdr runtime**

## Connections

- User → App shell: uses
- App shell → Machine API context: selects machine (evidence: `src/App.tsx`)
- App shell → Chat view: shows conversation (evidence: `src/App.tsx`)
- App shell → Live terminal: shows pane (evidence: `src/App.tsx`)
- User → Session creation: creates session
- Session creation → Machine API context: creates workspace (evidence: `src/components/NewSessionDialog.tsx`)
- User → Settings: configures
- Machine API context → HTTP client: binds requests (evidence: `src/lib/machineContext.tsx`)
- HTTP client → Wire contract: uses types (evidence: `src/lib/api.ts`)
- Machine API context → Machine types: uses types (evidence: `src/lib/machineContext.tsx`)
- HTTP client → HTTP and event routing: calls API
- HTTP and event routing → Access control: checks access (evidence: `server/index.ts`)
- HTTP and event routing → Conversation service: routes session work (evidence: `server/index.ts`)
- HTTP and event routing → herdr client: requests pane data (evidence: `server/index.ts`)
- Conversation service → herdr client: reads pane state (evidence: `server/conversation.ts`)
- Conversation service → Agent integrations: dispatches sessions (evidence: `server/conversation.ts`)
- herdr client → herdr runtime: uses runtime API
- HTTP and event routing → Files and attachments: routes file requests (evidence: `server/index.ts`)
- HTTP and event routing → Push alerts: routes push requests (evidence: `server/index.ts`)
- App shell → Push alerts: enables alerts (evidence: `src/App.tsx`)
- App shell → Updates: checks updates (evidence: `src/App.tsx`)
- Chat view → Voice input: accepts dictation
- Live terminal → Voice input: accepts dictation
- Background tasks → Machine API context: fetches activity (evidence: `src/components/BackgroundTasks.tsx`)
- Machine API context → HTTP client: fetches task activity (evidence: `src/lib/machineContext.tsx`)
