# rahrajlat/gentui architecture

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

- Interactive diagram: https://gitdiagram.com/rahrajlat/gentui
- Repository: https://github.com/rahrajlat/gentui

## Overview

Gentui is a terminal client for AG-UI agents. The main workflow starts with a user message in the TUI, sends it through either the HTTP AG-UI client or the optional AgentCore transport, then renders streamed events as chat and tool widgets; interrupt widgets let the user approve or reject and resume the run. Separate branches provide demo and recorded-session replay. The README documents features such as themes, event inspection, and plugins; some implementations are unsampled, so only documented or indexed relationships are shown.

Main entry points: [`src/gentui/tui/app.py`](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/app.py) (Chat application), [`src/gentui/cli.py`](https://github.com/rahrajlat/gentui/blob/main/src/gentui/cli.py) (CLI entry), [`src/gentui/plugins.py`](https://github.com/rahrajlat/gentui/blob/main/src/gentui/plugins.py) (Plugin system), [`src/gentui/tui/replay.py`](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/replay.py) (Session replay)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and configuration"]
  node_cli["CLI entry<br/>[cli.py]"]
  node_config["Config loading<br/>[config.py]"]
end

subgraph group_runtime["Agent connections"]
  node_agui["AG-UI HTTP client<br/>[agui_client.py]"]
  node_agentcore["AgentCore client"]
end

subgraph group_interface["Terminal interface"]
  node_app["Chat application<br/>[app.py]"]
  node_transcript["Chat transcript<br/>[transcript.py]"]
  node_commands["Slash commands<br/>[commands.py]"]
  node_branding["Themes and branding<br/>[branding.py]"]
  node_widgets["Tool widget lifecycle<br/>[base.py]"]
  node_registry["Widget registry<br/>[registry.py]"]
  node_generic["Fallback widgets<br/>[generic.py]"]
  node_interrupt["Approval prompts<br/>[interrupt.py]"]
  node_commandwidget["Command cards<br/>[command.py]"]
  node_planwidget["Plan checklist<br/>[plan.py]"]
  node_datawidgets["Tables and charts"]
end

subgraph group_extensions["Customization and replay"]
  node_plugins["Plugin system<br/>[plugins.py]"]
  node_session["Session recording<br/>[session.py]"]
  node_replay["Session replay<br/>[replay.py]"]
  node_demo["Demo mode<br/>[demo.py]"]
end

node_user(("Terminal user"))
node_backend{{"AG-UI backend"}}
node_agentcore_service{{"AgentCore Runtime"}}

node_user -->|"starts"| node_cli
node_cli -->|"loads settings"| node_config
node_cli -->|"launches"| node_app
node_cli -->|"selects HTTP"| node_agui
node_cli -->|"selects AgentCore"| node_agentcore
node_cli -->|"starts replay"| node_replay
node_cli -->|"starts demo"| node_demo
node_user -->|"chats"| node_app
node_app -->|"runs agent"| node_agui
node_agui -->|"streams events"| node_backend
node_agentcore -->|"invokes runtime"| node_agentcore_service
node_agentcore -->|"shares event handling"| node_agui
node_app -->|"updates transcript"| node_transcript
node_app -->|"dispatches commands"| node_commands
node_app -->|"uses themes"| node_branding
node_app -->|"drives lifecycle"| node_widgets
node_app -->|"prompts decisions"| node_interrupt
node_app -->|"updates plan"| node_planwidget
node_app -->|"selects widgets"| node_registry
node_registry -->|"falls back to"| node_generic
node_plugins -->|"registers widgets"| node_registry
node_plugins -->|"extends lifecycle"| node_widgets
node_app -->|"loads plugins"| node_plugins
node_commands -->|"uses registrations"| node_plugins
node_app -->|"records session"| node_session
node_replay -->|"loads session"| node_session
node_replay -->|"replays interface"| node_app
node_demo -->|"runs demo UI"| node_app
node_user -->|"plays recording"| node_replay
node_user -->|"starts tour"| node_demo
node_app -.->|"renders command calls"| node_commandwidget
node_app -.->|"renders data calls"| node_datawidgets

click node_cli "https://github.com/rahrajlat/gentui/blob/main/src/gentui/cli.py"
click node_config "https://github.com/rahrajlat/gentui/blob/main/src/gentui/config.py"
click node_app "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/app.py"
click node_transcript "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/transcript.py"
click node_commands "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/commands.py"
click node_branding "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/branding.py"
click node_agui "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/agui_client.py"
click node_agentcore "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/agentcore_client.py"
click node_widgets "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/widgets/base.py"
click node_registry "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/widgets/registry.py"
click node_generic "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/widgets/generic.py"
click node_interrupt "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/widgets/interrupt.py"
click node_commandwidget "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/widgets/command.py"
click node_planwidget "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/widgets/plan.py"
click node_datawidgets "https://github.com/rahrajlat/gentui/tree/main/src/gentui/tui/widgets"
click node_plugins "https://github.com/rahrajlat/gentui/blob/main/src/gentui/plugins.py"
click node_session "https://github.com/rahrajlat/gentui/blob/main/src/gentui/session.py"
click node_replay "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/replay.py"
click node_demo "https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/demo.py"

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_config,node_user,node_backend toneBlue
class node_agui,node_agentcore toneAmber
class node_app,node_transcript,node_commands,node_branding,node_widgets,node_registry,node_generic,node_interrupt,node_commandwidget,node_planwidget,node_datawidgets toneMint
class node_plugins,node_session,node_replay,node_demo toneRose
class node_agentcore_service toneIndigo
```

## Components

### Entry and configuration

- [CLI entry](https://github.com/rahrajlat/gentui/blob/main/src/gentui/cli.py): `src/gentui/cli.py`
- [Config loading](https://github.com/rahrajlat/gentui/blob/main/src/gentui/config.py): `src/gentui/config.py`

### Agent connections

- [AG-UI HTTP client](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/agui_client.py): `src/gentui/tui/agui_client.py`
- [AgentCore client](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/agentcore_client.py): `src/gentui/tui/agentcore_client.py`

### Terminal interface

- [Chat application](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/app.py): `src/gentui/tui/app.py`
- [Chat transcript](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/transcript.py): `src/gentui/tui/transcript.py`
- [Slash commands](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/commands.py): `src/gentui/tui/commands.py`
- [Themes and branding](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/branding.py): `src/gentui/tui/branding.py`
- [Tool widget lifecycle](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/widgets/base.py): `src/gentui/tui/widgets/base.py`
- [Widget registry](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/widgets/registry.py): `src/gentui/tui/widgets/registry.py`
- [Fallback widgets](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/widgets/generic.py): `src/gentui/tui/widgets/generic.py`
- [Approval prompts](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/widgets/interrupt.py): `src/gentui/tui/widgets/interrupt.py`
- [Command cards](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/widgets/command.py): `src/gentui/tui/widgets/command.py`
- [Plan checklist](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/widgets/plan.py): `src/gentui/tui/widgets/plan.py`
- [Tables and charts](https://github.com/rahrajlat/gentui/tree/main/src/gentui/tui/widgets): `src/gentui/tui/widgets`

### Customization and replay

- [Plugin system](https://github.com/rahrajlat/gentui/blob/main/src/gentui/plugins.py): `src/gentui/plugins.py`
- [Session recording](https://github.com/rahrajlat/gentui/blob/main/src/gentui/session.py): `src/gentui/session.py`
- [Session replay](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/replay.py): `src/gentui/tui/replay.py`
- [Demo mode](https://github.com/rahrajlat/gentui/blob/main/src/gentui/tui/demo.py): `src/gentui/tui/demo.py`

### Other components

- **Terminal user**
- **AG-UI backend**
- **AgentCore Runtime**

## Connections

- Terminal user → CLI entry: starts (evidence: `README.md`)
- CLI entry → Config loading: loads settings (evidence: `src/gentui/cli.py`)
- CLI entry → Chat application: launches (evidence: `src/gentui/cli.py`)
- CLI entry → AG-UI HTTP client: selects HTTP (evidence: `src/gentui/cli.py`)
- CLI entry → AgentCore client: selects AgentCore (evidence: `src/gentui/cli.py`)
- CLI entry → Session replay: starts replay (evidence: `src/gentui/cli.py`)
- CLI entry → Demo mode: starts demo (evidence: `src/gentui/cli.py`)
- Terminal user → Chat application: chats (evidence: `README.md`)
- Chat application → AG-UI HTTP client: runs agent (evidence: `src/gentui/tui/app.py`)
- AG-UI HTTP client → AG-UI backend: streams events (evidence: `README.md`)
- AgentCore client → AgentCore Runtime: invokes runtime (evidence: `README.md`)
- AgentCore client → AG-UI HTTP client: shares event handling (evidence: `src/gentui/tui/agentcore_client.py`)
- Chat application → Chat transcript: updates transcript (evidence: `src/gentui/tui/app.py`)
- Chat application → Slash commands: dispatches commands (evidence: `src/gentui/tui/app.py`)
- Chat application → Themes and branding: uses themes (evidence: `src/gentui/tui/app.py`)
- Chat application → Tool widget lifecycle: drives lifecycle (evidence: `src/gentui/tui/app.py`)
- Chat application → Approval prompts: prompts decisions (evidence: `src/gentui/tui/app.py`)
- Chat application → Plan checklist: updates plan (evidence: `src/gentui/tui/app.py`)
- Chat application → Widget registry: selects widgets (evidence: `src/gentui/tui/app.py`)
- Widget registry → Fallback widgets: falls back to (evidence: `src/gentui/tui/widgets/registry.py`)
- Plugin system → Widget registry: registers widgets (evidence: `src/gentui/plugins.py`)
- Plugin system → Tool widget lifecycle: extends lifecycle (evidence: `src/gentui/plugins.py`)
- Chat application → Plugin system: loads plugins (evidence: `src/gentui/tui/app.py`)
- Slash commands → Plugin system: uses registrations (evidence: `src/gentui/tui/commands.py`)
- Chat application → Session recording: records session (evidence: `src/gentui/tui/app.py`)
- Session replay → Session recording: loads session (evidence: `src/gentui/tui/replay.py`)
- Session replay → Chat application: replays interface (evidence: `src/gentui/tui/replay.py`)
- Demo mode → Chat application: runs demo UI (evidence: `src/gentui/tui/demo.py`)
- Terminal user → Session replay: plays recording (evidence: `README.md`)
- Terminal user → Demo mode: starts tour (evidence: `README.md`)
- Chat application → Command cards: renders command calls
- Chat application → Tables and charts: renders data calls (evidence: `src/gentui/tui/app.py`)
