Skip to content

Repository files navigation

Open Generative UI

An open-source showcase for building rich, interactive AI-generated UI with CopilotKit and LangGraph. Ask the agent to visualize algorithms, create 3D animations, render charts, or generate interactive diagrams — all rendered as live HTML/SVG inside a sandboxed iframe.

OpenGenerativeUI.demo.mp4

What It Does

The agent produces generative UI — not just text responses, but fully interactive visual components:

  • Algorithm visualizations — binary search, BFS vs DFS, sorting algorithms
  • 3D animations — interactive WebGL/CSS3D scenes
  • Charts & diagrams — pie charts, bar charts, network diagrams
  • Interactive widgets — forms, simulations, math plots

All visuals are rendered in sandboxed iframes with automatic light/dark theming, progressive reveal animations, and responsive sizing.

Quick Start

make setup # Install deps + create .env template# Edit apps/agent/.env with your real OpenAI API key
make dev # Start all services

Available Commands

CommandDescription
make setupInstall all dependencies and create .env template
make devStart all services (frontend + agent + mcp)
make dev-appStart Next.js frontend only
make dev-agentStart LangGraph agent only
make dev-mcpStart MCP server only
make buildBuild all apps
make lintLint all apps
make cleanClean build artifacts
make helpShow all available commands

You can also use pnpm directly (pnpm dev, pnpm dev:app, pnpm dev:agent, etc.).

Architecture

Turborepo monorepo with two apps:

apps/
├── app/ Next.js 16 frontend (CopilotKit v2, React 19, Tailwind 4)
└── agent/ LangGraph Python agent (GPT-5.4, CopilotKit middleware)

How It Works

  1. User sends a prompt via the CopilotKit chat UI
  2. Agent decides whether to respond with text, call a tool, or render a visual component
  3. widgetRenderer — a frontend useComponent hook — receives the agent's HTML and renders it in a sandboxed iframe
  4. Skeleton loading shows while the iframe loads, then content fades in smoothly
  5. ResizeObserver inside the iframe reports content height back to the parent for seamless auto-sizing

Key CopilotKit Patterns

PatternHookExample
Generative UIuseComponentPie charts, bar charts, widget renderer
Frontend toolsuseFrontendToolTheme toggle
Human-in-the-loopuseHumanInTheLoopMeeting scheduler
Default tool renderuseDefaultRenderToolTool execution status

Decision Matrix — Picking the Right Visual

User asks about...Output typeTechnology
How X works (physical)Illustrative diagramSVG
How X works (abstract)Interactive explainerHTML + inline SVG
Process / stepsFlowchartSVG
Architecture / containmentStructural diagramSVG
Database schema / ERDRelationship diagramMermaid
Trends over timeLine chartChart.js
Category comparisonBar chartChart.js
Part of wholeDoughnut chartChart.js
KPIs / metricsDashboardHTML metric cards
Design a UIMockupHTML
Choose between optionsComparison cardsHTML grid
Cyclic processStep-throughHTML stepper
Physics / mathSimulationCanvas + JS
Function / equationPlotterSVG + JS
Data explorationSortable tableHTML + JS
Creative / decorativeArt / illustrationSVG
3D visualization3D sceneThree.js
Music / audioSynthesizerTone.js
Network / graphForce layoutD3.js
Quick factual answerPlain textNone
Code solutionCode blockNone
Emotional supportWarm textNone

Tech Stack

Next.js 16, React 19, Tailwind CSS 4, LangGraph, CopilotKit v2, Turborepo, Recharts

License

MIT

About

Open-Source Generative UI Framework

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages