# breeznik/agui_demo architecture

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

## Overview

AG-UI Demo is a Breeze flight-booking assistant: users chat in either a React or vanilla-JS browser, while a FastAPI service streams a LangGraph ReAct agent’s responses and state. The documented booking path is flight search, flight selection, passenger details, approval interrupt, and confirmation into a cart; flights are invented rather than sourced from an airline. The graph also covers BYOK configuration and request-scoped model access. Edges follow the excerpts or README; unsampled implementation details are not inferred.

Main entry points: [`backend/src/graph.py`](https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py) (ReAct agent graph), [`backend/src/app.py`](https://github.com/breeznik/agui_demo/blob/master/backend/src/app.py) (Agent API), [`frontend/src/Chat/ChatInterface.jsx`](https://github.com/breeznik/agui_demo/blob/master/frontend/src/Chat/ChatInterface.jsx) (Chat interface), [`frontend/src/hooks/useAgentChat.js`](https://github.com/breeznik/agui_demo/blob/master/frontend/src/hooks/useAgentChat.js) (Agent chat hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Browser clients"]
  node_react_app["React app<br/>[App.jsx]"]
  node_react_chat["Chat interface<br/>[ChatInterface.jsx]"]
  node_react_chat_hook["Agent chat hook<br/>[useAgentChat.js]"]
  node_react_stream["Stream helpers<br/>[agentStream.js]"]
  node_react_key["Key handling<br/>[apiKey.js]"]
  node_react_config["Provider config<br/>[useAgentConfig.js]"]
  node_booking_panel["Booking panel<br/>[BookingPanel.jsx]"]
  node_vanilla_app["Vanilla client<br/>[main.js]"]
  node_vanilla_stream["Stream helpers<br/>[agentStream.js]"]
end

subgraph group_backend["Agent service"]
  node_agent_api["Agent API<br/>[app.py]"]
end

subgraph group_booking["Booking workflow"]
  node_agent_graph["ReAct agent graph<br/>[graph.py]"]
  node_flight_search["Search flights<br/>[graph.py]"]
  node_flight_select["Select flight<br/>[graph.py]"]
  node_passenger_save["Save passenger<br/>[graph.py]"]
  node_booking_confirm["Confirm booking<br/>[graph.py]"]
  node_booking_review["Review booking<br/>[graph.py]"]
  node_booking_cart[("Booking cart<br/>[graph.py]")]
end

subgraph group_model["Model and context"]
  node_context_limits["Context limits<br/>[middleware.py]"]
  node_llm_provider["LLM provider"]
end

node_traveler(("Traveler"))

node_traveler -->|"chats in"| node_react_chat
node_traveler -->|"chats in"| node_vanilla_app
node_react_app -->|"renders"| node_react_chat
node_react_chat -->|"uses"| node_react_chat_hook
node_react_chat -->|"loads config"| node_react_config
node_react_chat -->|"renders state"| node_booking_panel
node_react_chat_hook -->|"uses"| node_react_stream
node_react_chat_hook -->|"sets headers"| node_react_key
node_react_chat_hook -->|"streams runs"| node_agent_api
node_react_config -->|"fetches config"| node_agent_api
node_vanilla_app -->|"uses"| node_vanilla_stream
node_vanilla_app -->|"streams runs"| node_agent_api
node_agent_api -->|"runs graph"| node_agent_graph
node_agent_graph -->|"dispatches tools"| node_flight_search
node_agent_graph -->|"dispatches tools"| node_flight_select
node_agent_graph -->|"dispatches tools"| node_passenger_save
node_agent_graph -->|"dispatches tools"| node_booking_confirm
node_agent_graph -->|"dispatches tools"| node_booking_review
node_flight_search -->|"offers options"| node_flight_select
node_flight_select -->|"precedes details"| node_passenger_save
node_passenger_save -->|"precedes approval"| node_booking_confirm
node_booking_confirm -->|"adds confirmed"| node_booking_cart
node_booking_review -->|"reads state"| node_booking_cart
node_agent_graph -->|"uses middleware"| node_context_limits
node_agent_graph -->|"calls model"| node_llm_provider
node_agent_api -->|"streams events"| node_react_chat_hook
node_agent_api -->|"streams events"| node_vanilla_app

click node_react_app "https://github.com/breeznik/agui_demo/blob/master/frontend/src/App.jsx"
click node_react_chat "https://github.com/breeznik/agui_demo/blob/master/frontend/src/Chat/ChatInterface.jsx"
click node_react_chat_hook "https://github.com/breeznik/agui_demo/blob/master/frontend/src/hooks/useAgentChat.js"
click node_react_stream "https://github.com/breeznik/agui_demo/blob/master/frontend/src/lib/agentStream.js"
click node_react_key "https://github.com/breeznik/agui_demo/blob/master/frontend/src/lib/apiKey.js"
click node_react_config "https://github.com/breeznik/agui_demo/blob/master/frontend/src/hooks/useAgentConfig.js"
click node_booking_panel "https://github.com/breeznik/agui_demo/blob/master/frontend/src/Chat/BookingPanel.jsx"
click node_vanilla_app "https://github.com/breeznik/agui_demo/blob/master/frontend-vanilla/src/main.js"
click node_vanilla_stream "https://github.com/breeznik/agui_demo/blob/master/frontend-vanilla/src/agentStream.js"
click node_agent_api "https://github.com/breeznik/agui_demo/blob/master/backend/src/app.py"
click node_agent_graph "https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py"
click node_flight_search "https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py"
click node_flight_select "https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py"
click node_passenger_save "https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py"
click node_booking_confirm "https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py"
click node_booking_review "https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py"
click node_context_limits "https://github.com/breeznik/agui_demo/blob/master/backend/src/middleware.py"
click node_booking_cart "https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.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_react_app,node_react_chat,node_react_chat_hook,node_react_stream,node_react_key,node_react_config,node_booking_panel,node_vanilla_app,node_vanilla_stream toneBlue
class node_agent_api toneAmber
class node_agent_graph,node_flight_search,node_flight_select,node_passenger_save,node_booking_confirm,node_booking_review,node_booking_cart toneMint
class node_context_limits,node_llm_provider toneRose
class node_traveler toneIndigo
```

## Components

### Browser clients

- [React app](https://github.com/breeznik/agui_demo/blob/master/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Chat interface](https://github.com/breeznik/agui_demo/blob/master/frontend/src/Chat/ChatInterface.jsx): `frontend/src/Chat/ChatInterface.jsx`
- [Agent chat hook](https://github.com/breeznik/agui_demo/blob/master/frontend/src/hooks/useAgentChat.js): `frontend/src/hooks/useAgentChat.js`
- [Stream helpers](https://github.com/breeznik/agui_demo/blob/master/frontend/src/lib/agentStream.js): `frontend/src/lib/agentStream.js`
- [Key handling](https://github.com/breeznik/agui_demo/blob/master/frontend/src/lib/apiKey.js): `frontend/src/lib/apiKey.js`
- [Provider config](https://github.com/breeznik/agui_demo/blob/master/frontend/src/hooks/useAgentConfig.js): `frontend/src/hooks/useAgentConfig.js`
- [Booking panel](https://github.com/breeznik/agui_demo/blob/master/frontend/src/Chat/BookingPanel.jsx): `frontend/src/Chat/BookingPanel.jsx`
- [Vanilla client](https://github.com/breeznik/agui_demo/blob/master/frontend-vanilla/src/main.js): `frontend-vanilla/src/main.js`
- [Stream helpers](https://github.com/breeznik/agui_demo/blob/master/frontend-vanilla/src/agentStream.js): `frontend-vanilla/src/agentStream.js`

### Agent service

- [Agent API](https://github.com/breeznik/agui_demo/blob/master/backend/src/app.py): `backend/src/app.py`

### Booking workflow

- [ReAct agent graph](https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py): `backend/src/graph.py`
- [Search flights](https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py): `backend/src/graph.py`
- [Select flight](https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py): `backend/src/graph.py`
- [Save passenger](https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py): `backend/src/graph.py`
- [Confirm booking](https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py): `backend/src/graph.py`
- [Review booking](https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py): `backend/src/graph.py`
- [Booking cart](https://github.com/breeznik/agui_demo/blob/master/backend/src/graph.py): `backend/src/graph.py`

### Model and context

- [Context limits](https://github.com/breeznik/agui_demo/blob/master/backend/src/middleware.py): `backend/src/middleware.py`
- **LLM provider**

### Other components

- **Traveler**

## Connections

- Traveler → Chat interface: chats in (evidence: `README.md`)
- Traveler → Vanilla client: chats in (evidence: `README.md`)
- React app → Chat interface: renders (evidence: `frontend/src/App.jsx`)
- Chat interface → Agent chat hook: uses (evidence: `frontend/src/Chat/ChatInterface.jsx`)
- Chat interface → Provider config: loads config (evidence: `frontend/src/Chat/ChatInterface.jsx`)
- Chat interface → Booking panel: renders state (evidence: `frontend/src/Chat/ChatInterface.jsx`)
- Agent chat hook → Stream helpers: uses (evidence: `frontend/src/hooks/useAgentChat.js`)
- Agent chat hook → Key handling: sets headers (evidence: `frontend/src/hooks/useAgentChat.js`)
- Agent chat hook → Agent API: streams runs (evidence: `README.md`)
- Provider config → Agent API: fetches config (evidence: `frontend/src/hooks/useAgentConfig.js`)
- Vanilla client → Stream helpers: uses (evidence: `frontend-vanilla/src/main.js`)
- Vanilla client → Agent API: streams runs (evidence: `README.md`)
- Agent API → ReAct agent graph: runs graph (evidence: `backend/src/app.py`)
- ReAct agent graph → Search flights: dispatches tools (evidence: `README.md`)
- ReAct agent graph → Select flight: dispatches tools (evidence: `README.md`)
- ReAct agent graph → Save passenger: dispatches tools (evidence: `README.md`)
- ReAct agent graph → Confirm booking: dispatches tools (evidence: `README.md`)
- ReAct agent graph → Review booking: dispatches tools (evidence: `backend/src/graph.py`)
- Search flights → Select flight: offers options (evidence: `README.md`)
- Select flight → Save passenger: precedes details (evidence: `README.md`)
- Save passenger → Confirm booking: precedes approval (evidence: `README.md`)
- Confirm booking → Booking cart: adds confirmed (evidence: `README.md`)
- Review booking → Booking cart: reads state (evidence: `backend/src/graph.py`)
- ReAct agent graph → Context limits: uses middleware (evidence: `backend/src/graph.py`)
- ReAct agent graph → LLM provider: calls model (evidence: `backend/src/graph.py`)
- Agent API → Agent chat hook: streams events (evidence: `README.md`)
- Agent API → Vanilla client: streams events (evidence: `README.md`)
