# rezformbay/ag-ui architecture

> Architecture diagram of the GitHub repository rezformbay/ag-ui, 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/rezformbay/ag-ui
- Repository: https://github.com/rezformbay/ag-ui

## Overview

This starter pairs a CopilotKit chat-and-canvas frontend with a Claude Agent SDK backend. The user’s main path runs from the chat UI through the CopilotKit HTTP route to the agent, which can query sample data or generate UI; frontend tools and renderers then provide charts, meeting selection, and shared todos. The README also documents A2UI flight and dashboard experiences, Intelligence threads, and optional Slack/Teams channels. Some backend and UI links are documented rather than visible in sampled implementation excerpts.

Main entry points: [`src/app/page.tsx`](https://github.com/rezformbay/ag-ui/blob/main/src/app/page.tsx) (Chat and canvas), [`agent/src/agent.ts`](https://github.com/rezformbay/ag-ui/blob/main/agent/src/agent.ts) (Tool orchestration), [`src/hooks/use-generative-ui-examples.tsx`](https://github.com/rezformbay/ag-ui/blob/main/src/hooks/use-generative-ui-examples.tsx) (Tool and UI setup), [`channel-host.mts`](https://github.com/rezformbay/ag-ui/blob/main/channel-host.mts) (Channel host)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_home["Chat and canvas<br/>[page.tsx]"]
  node_layout["Chat/app layout<br/>[index.tsx]"]
  node_canvas["Todo canvas<br/>[todo-list.tsx]"]
  node_suggestions["Prompt suggestions"]
end

subgraph group_ui["Interactive UI features"]
  node_ui_hooks["Tool and UI setup"]
  node_charts["Charts<br/>[bar-chart.tsx]"]
  node_meeting["Meeting picker"]
  node_a2ui_renderers["A2UI renderers<br/>[renderers.tsx]"]
  node_a2ui_definitions["A2UI catalog<br/>[definitions.ts]"]
  node_theme["Theme state<br/>[use-theme.tsx]"]
end

subgraph group_backend["Agent runtime"]
  node_runtime_route["CopilotKit route<br/>[route.ts]"]
  node_http_agent["HTTP agent client<br/>[agent.ts]"]
  node_server["AG-UI server<br/>[server.ts]"]
  node_agent["Tool orchestration<br/>[agent.ts]"]
  node_model["Model selection<br/>[model.ts]"]
  node_query["Financial data query<br/>[query.ts]"]
  node_fixed_a2ui["Flight search UI"]
  node_dynamic_a2ui["Dashboard generation"]
  node_a2ui_ops["A2UI operations<br/>[a2ui.ts]"]
end

subgraph group_channels["Messaging channels"]
  node_channel_host["Channel host<br/>[channel-host.mts]"]
  node_channel_declaration["Channel handlers<br/>[channels.mts]"]
end

node_user(("User"))
node_claude{{"Claude Agent SDK"}}
node_intelligence[("CopilotKit Intelligence")]
node_channel_service{{"Slack / Teams"}}

node_user -->|"uses"| node_home
node_home -->|"renders"| node_layout
node_home -->|"renders"| node_canvas
node_home -->|"configures"| node_suggestions
node_home -->|"registers UI tools"| node_ui_hooks
node_layout -->|"displays"| node_canvas
node_ui_hooks -->|"registers renderers"| node_charts
node_ui_hooks -->|"renders interaction"| node_meeting
node_ui_hooks -->|"reads and updates"| node_theme
node_a2ui_renderers -->|"uses catalog"| node_a2ui_definitions
node_home -->|"sends chat requests"| node_runtime_route
node_runtime_route -->|"configures agent"| node_http_agent
node_http_agent -->|"connects over HTTP"| node_server
node_server -->|"serves"| node_agent
node_agent -->|"resolves model"| node_model
node_agent -->|"registers tool"| node_query
node_agent -->|"registers tool"| node_fixed_a2ui
node_agent -->|"registers tool"| node_dynamic_a2ui
node_dynamic_a2ui -->|"uses operations"| node_a2ui_ops
node_fixed_a2ui -->|"uses operations"| node_a2ui_ops
node_agent -->|"delegates agent run"| node_claude
node_home -.->|"loads thread history"| node_intelligence
node_channel_host -->|"loads channel setup"| node_channel_declaration
node_channel_declaration -->|"shares agent"| node_agent
node_channel_host -.->|"connects via Intelligence"| node_channel_service

click node_home "https://github.com/rezformbay/ag-ui/blob/main/src/app/page.tsx"
click node_layout "https://github.com/rezformbay/ag-ui/blob/main/src/components/example-layout/index.tsx"
click node_canvas "https://github.com/rezformbay/ag-ui/blob/main/src/components/example-canvas/todo-list.tsx"
click node_suggestions "https://github.com/rezformbay/ag-ui/blob/main/src/hooks/use-example-suggestions.tsx"
click node_ui_hooks "https://github.com/rezformbay/ag-ui/blob/main/src/hooks/use-generative-ui-examples.tsx"
click node_charts "https://github.com/rezformbay/ag-ui/blob/main/src/components/generative-ui/charts/bar-chart.tsx"
click node_meeting "https://github.com/rezformbay/ag-ui/blob/main/src/components/generative-ui/meeting-time-picker.tsx"
click node_a2ui_renderers "https://github.com/rezformbay/ag-ui/blob/main/src/app/declarative-generative-ui/renderers.tsx"
click node_a2ui_definitions "https://github.com/rezformbay/ag-ui/blob/main/src/app/declarative-generative-ui/definitions.ts"
click node_theme "https://github.com/rezformbay/ag-ui/blob/main/src/hooks/use-theme.tsx"
click node_runtime_route "https://github.com/rezformbay/ag-ui/blob/main/src/app/api/copilotkit/%5B%5B...slug%5D%5D/route.ts"
click node_http_agent "https://github.com/rezformbay/ag-ui/blob/main/src/agent.ts"
click node_server "https://github.com/rezformbay/ag-ui/blob/main/agent/src/server.ts"
click node_agent "https://github.com/rezformbay/ag-ui/blob/main/agent/src/agent.ts"
click node_model "https://github.com/rezformbay/ag-ui/blob/main/agent/src/model.ts"
click node_query "https://github.com/rezformbay/ag-ui/blob/main/agent/src/query.ts"
click node_fixed_a2ui "https://github.com/rezformbay/ag-ui/blob/main/agent/src/a2ui_fixed_schema.ts"
click node_dynamic_a2ui "https://github.com/rezformbay/ag-ui/blob/main/agent/src/a2ui_dynamic_schema.ts"
click node_a2ui_ops "https://github.com/rezformbay/ag-ui/blob/main/agent/src/a2ui.ts"
click node_channel_host "https://github.com/rezformbay/ag-ui/blob/main/channel-host.mts"
click node_channel_declaration "https://github.com/rezformbay/ag-ui/blob/main/channels.mts"

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_home,node_layout,node_canvas,node_suggestions,node_user toneBlue
class node_ui_hooks,node_charts,node_meeting,node_a2ui_renderers,node_a2ui_definitions,node_theme,node_intelligence toneAmber
class node_runtime_route,node_http_agent,node_server,node_agent,node_model,node_query,node_fixed_a2ui,node_dynamic_a2ui,node_a2ui_ops toneMint
class node_channel_host,node_channel_declaration toneRose
class node_claude,node_channel_service toneIndigo
```

## Components

### Frontend experience

- [Chat and canvas](https://github.com/rezformbay/ag-ui/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Chat/app layout](https://github.com/rezformbay/ag-ui/blob/main/src/components/example-layout/index.tsx): `src/components/example-layout/index.tsx`
- [Todo canvas](https://github.com/rezformbay/ag-ui/blob/main/src/components/example-canvas/todo-list.tsx): `src/components/example-canvas/todo-list.tsx`
- [Prompt suggestions](https://github.com/rezformbay/ag-ui/blob/main/src/hooks/use-example-suggestions.tsx): `src/hooks/use-example-suggestions.tsx`

### Interactive UI features

- [Tool and UI setup](https://github.com/rezformbay/ag-ui/blob/main/src/hooks/use-generative-ui-examples.tsx): `src/hooks/use-generative-ui-examples.tsx`
- [Charts](https://github.com/rezformbay/ag-ui/blob/main/src/components/generative-ui/charts/bar-chart.tsx): `src/components/generative-ui/charts/bar-chart.tsx`
- [Meeting picker](https://github.com/rezformbay/ag-ui/blob/main/src/components/generative-ui/meeting-time-picker.tsx): `src/components/generative-ui/meeting-time-picker.tsx`
- [A2UI renderers](https://github.com/rezformbay/ag-ui/blob/main/src/app/declarative-generative-ui/renderers.tsx): `src/app/declarative-generative-ui/renderers.tsx`
- [A2UI catalog](https://github.com/rezformbay/ag-ui/blob/main/src/app/declarative-generative-ui/definitions.ts): `src/app/declarative-generative-ui/definitions.ts`
- [Theme state](https://github.com/rezformbay/ag-ui/blob/main/src/hooks/use-theme.tsx): `src/hooks/use-theme.tsx`

### Agent runtime

- [CopilotKit route](https://github.com/rezformbay/ag-ui/blob/main/src/app/api/copilotkit/%5B%5B...slug%5D%5D/route.ts): `src/app/api/copilotkit/[[...slug]]/route.ts`
- [HTTP agent client](https://github.com/rezformbay/ag-ui/blob/main/src/agent.ts): `src/agent.ts`
- [AG-UI server](https://github.com/rezformbay/ag-ui/blob/main/agent/src/server.ts): `agent/src/server.ts`
- [Tool orchestration](https://github.com/rezformbay/ag-ui/blob/main/agent/src/agent.ts): `agent/src/agent.ts`
- [Model selection](https://github.com/rezformbay/ag-ui/blob/main/agent/src/model.ts): `agent/src/model.ts`
- [Financial data query](https://github.com/rezformbay/ag-ui/blob/main/agent/src/query.ts): `agent/src/query.ts`
- [Flight search UI](https://github.com/rezformbay/ag-ui/blob/main/agent/src/a2ui_fixed_schema.ts): `agent/src/a2ui_fixed_schema.ts`
- [Dashboard generation](https://github.com/rezformbay/ag-ui/blob/main/agent/src/a2ui_dynamic_schema.ts): `agent/src/a2ui_dynamic_schema.ts`
- [A2UI operations](https://github.com/rezformbay/ag-ui/blob/main/agent/src/a2ui.ts): `agent/src/a2ui.ts`

### Messaging channels

- [Channel host](https://github.com/rezformbay/ag-ui/blob/main/channel-host.mts): `channel-host.mts`
- [Channel handlers](https://github.com/rezformbay/ag-ui/blob/main/channels.mts): `channels.mts`

### Other components

- **User**
- **Claude Agent SDK**
- **CopilotKit Intelligence**
- **Slack / Teams**

## Connections

- User → Chat and canvas: uses (evidence: `src/app/page.tsx`)
- Chat and canvas → Chat/app layout: renders (evidence: `src/app/page.tsx`)
- Chat and canvas → Todo canvas: renders (evidence: `src/app/page.tsx`)
- Chat and canvas → Prompt suggestions: configures (evidence: `src/app/page.tsx`)
- Chat and canvas → Tool and UI setup: registers UI tools (evidence: `src/app/page.tsx`)
- Chat/app layout → Todo canvas: displays (evidence: `src/components/example-layout/index.tsx`)
- Tool and UI setup → Charts: registers renderers (evidence: `src/hooks/use-generative-ui-examples.tsx`)
- Tool and UI setup → Meeting picker: renders interaction (evidence: `src/hooks/use-generative-ui-examples.tsx`)
- Tool and UI setup → Theme state: reads and updates (evidence: `src/hooks/use-generative-ui-examples.tsx`)
- A2UI renderers → A2UI catalog: uses catalog (evidence: `src/app/declarative-generative-ui/renderers.tsx`)
- Chat and canvas → CopilotKit route: sends chat requests (evidence: `README.md`)
- CopilotKit route → HTTP agent client: configures agent (evidence: `src/app/api/copilotkit/[[...slug]]/route.ts`)
- HTTP agent client → AG-UI server: connects over HTTP (evidence: `README.md`)
- AG-UI server → Tool orchestration: serves (evidence: `agent/src/server.ts`)
- Tool orchestration → Model selection: resolves model (evidence: `agent/src/agent.ts`)
- Tool orchestration → Financial data query: registers tool (evidence: `agent/src/agent.ts`)
- Tool orchestration → Flight search UI: registers tool (evidence: `agent/src/agent.ts`)
- Tool orchestration → Dashboard generation: registers tool (evidence: `agent/src/agent.ts`)
- Dashboard generation → A2UI operations: uses operations (evidence: `agent/src/a2ui_dynamic_schema.ts`)
- Flight search UI → A2UI operations: uses operations (evidence: `agent/src/a2ui_fixed_schema.ts`)
- Tool orchestration → Claude Agent SDK: delegates agent run (evidence: `README.md`)
- Chat and canvas → CopilotKit Intelligence: loads thread history (evidence: `README.md`)
- Channel host → Channel handlers: loads channel setup (evidence: `channel-host.mts`)
- Channel handlers → Tool orchestration: shares agent (evidence: `channels.mts`)
- Channel host → Slack / Teams: connects via Intelligence (evidence: `README.md`)
