A production-grade framework for building multi-agent systems with dynamic, real-time UI generation using LangGraph, FastAPI, React, and the AG-UI protocol.
Frontend (React + TypeScript + CopilotKit)
↕ (SSE / AG-UI Events)
CopilotKit Runtime
↕ (HTTP)
Backend (FastAPI + LangGraph)
├── Supervisor Agent
├── Specialist Agents
└── Tool Registry (MCP)
GenUI/
├── backend/
│ ├── app.py # FastAPI entry point
│ ├── models/
│ │ ├── ag_ui_events.py # AG-UI protocol event schemas
│ │ └── a2ui_schema.py # (Phase 2) Declarative UI schema
│ ├── agents/
│ │ ├── supervisor.py # (Phase 1) Supervisor agent
│ │ └── specialists.py # (Phase 5) Specialist agents
│ ├── tools/
│ │ └── registry.py # (Phase 1) Tool definitions
│ ├── requirements.txt
│ └── .env
├── frontend/
│ ├── src/
│ │ ├── App.tsx # Main app component
│ │ ├── hooks/
│ │ │ └── useStream.ts # SSE consumer hook
│ │ ├── stores/
│ │ │ └── stateStore.ts # Zustand state management
│ │ └── components/ # (Phase 2) Component registry
│ ├── index.html
│ ├── package.json
│ ├── vite.config.ts
│ ├── tsconfig.json
│ └── tailwind.config.js
└── docs/ # (Phase 6) Documentation
cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run server
python app.py
# Backend runs on http://localhost:8000cd frontend
# Install dependencies
npm install
# Run dev server
npm run dev
# Frontend runs on http://localhost:5173- Open http://localhost:5173 in your browser
- Type a query in the text area
- Click "Send Query"
- Watch SSE events stream in real-time from the backend
Expected flow:
- Query sent
- RUN_STARTED event
- STATE_SNAPSHOT event
- TEXT_MESSAGE_CONTENT events (agent thinking)
- RUN_FINISHED event
All phases have been fully implemented, tested, and documented.
- Project scaffolding & directory structure setup.
- FastAPI skeleton & SSE streaming endpoint (
/api/agent/stream). - React + TypeScript setup with Tailwind CSS.
- Full AG-UI event catalogue modeled as Pydantic models.
- SSE event consumer hook (
useStream). - Zustand state store (
stateStore) for React state synchronization.
- LangGraph supervisor node for dynamic request routing.
- 3 specialist node stubs (DataRetrieval, Analysis, Summarise).
- Extensible tool registry with mock tools (
search_knowledge_base,fetch_data,calculate_metric). - Real-time SSE streaming of thinking blocks (
TEXT_MESSAGE_CONTENT) and tool states. - Confidence score routing output.
- Artificial 5-second long-running tool execution to test SSE buffer flushing.
- Custom components library (
DataCard,ChartPanel,SummaryTable,StatusBadge). - Registered custom component renderers as agent-callable actions.
- Strict props validation and error banners for component inputs.
- Theme compatibility (dark mode Outfits styling).
- Recursive layout tree compiler (
UIRenderer.tsx) parsing the A2UI spec. - Security whitelist mapping allowed component tags (
Card,Table,Form,Chart,List,Badge,Button). - Safe RFC 6901 JSON pointer resolver for dynamic runtime data bindings.
- Gating filter rejecting unwhitelisted elements at rendering boundaries.
- Bidirectional state sync (user edits propagate to agent state, agent updates reflect in UI).
- Live optimistic UI state updates for latency-free typing.
- Predictive intermediate progress states ("Fetching sales records... X% complete") streamed during tool runs.
- Custom state synchronization hook (
useCoAgent).
- Risk-tiered authorization gating checkpoints using LangGraph interrupts.
- Context-aware
PolicyEngineevaluating confidence scores and budget overrun flags. - Interactive operator approval overlays (
ApprovalCard) to edit or submit decisions. - Persistent JSON audit logs (
audit_log.json) storing decisions, metrics, and timestamps.
- Sandboxed iframe embedding (
simulated-mcp-appendpoint). - Bidirectional message passing handshake protocol (
postMessage) for vector drawing sync. - Collaborative whiteboard canvas with tools for shapes, colors, text annotations, and wipe actions.
- Synced collaborative task checklist with agent auto-generation capabilities.
- Full multi-agent pool with 4 specialists (Search, Analysis, Recommendation, Report).
- Concurrent fork-and-join parallel agent nodes branching.
- Safe, recursive
merge_resultsstate reducer to prevent race conditions during parallel joins. - Graceful degradation and error boundaries handling specialist failures.
- Comprehensive backend automated testing suite (9 pytest test cases covering policy engine, tool registry, and supervisor graph routing).
- Flawless frontend TypeScript compilation and production packaging builds.
- Automated GitHub Actions workflow (
.github/workflows/ci.yml) protecting the codebase on push/PRs. - Premium guides:
DEVELOPER_GUIDE.md(developer extension manual) andMARKET_RESEARCH_BOT_FLOW.md(end-to-end execution flow walkthrough).
| Component | Technology | Version |
|---|---|---|
| Backend Runtime | FastAPI | 0.104.1 |
| Agent Framework | LangGraph | 0.0.51 |
| Agent Orchestration | LangChain | >=0.1.46,<0.2.0 |
| Data Validation | Pydantic | 2.4.2 |
| Frontend Framework | React | 18.2.0 |
| Frontend Build | Vite | 5.4.21 |
| Language | TypeScript | 5.2.2 |
| Styling | Tailwind CSS | 3.3.6 |
| State Management | Zustand | 4.4.1 |
Event-based bidirectional communication between agent and UI. Key events:
RUN_STARTED/RUN_FINISHED— Lifecycle trackingTEXT_MESSAGE_*— Streaming agent thoughtsTOOL_CALL_*— Tool execution with progressSTATE_SNAPSHOT/STATE_DELTA— Shared state updatesINTERRUPT/USER_APPROVAL— Human-in-the-loop checkpoints
Agents describe UIs as JSON structures, not code:
{
"type": "Card",
"props": { "title": "...", "description": "..." },
"children": [
{ "type": "Badge", "props": { "label": "...", "status_type": "success" } }
]
}This is safe (no XSS), portable (same JSON on web/mobile), and scalable.
Supervisor agent routes user requests → Specialist agents handle domains → Results aggregate back to UI.
- Research Document:
Generative UI Agent Research Plan.pdf - AG-UI Spec: https://docs.ag-ui.com
- LangGraph Docs: https://langchain-ai.github.io/langgraph/
- CopilotKit Docs: https://docs.copilotkit.ai/
- A2UI Spec: https://developers.googleblog.com/a2ui-v0-9-generative-ui/
Status: 100% Completed (Phases 0 to 8 fully verified)