# Architecture URL: /docs/architecture How components, runtimes, and cloud services fit together. *** title: "Architecture" description: How components, runtimes, and cloud services fit together. ----------------------------------------------------------------------- import { Sparkles, PanelsTopLeft, Database, Terminal } from "lucide-react"; ## assistant-ui is built on these main pillars:
Shadcn UI chat components with built-in state management State management layer connecting UI to LLMs and backend services Hosted service for thread persistence, history, and user management
### 1. Frontend components Stylized and functional chat components built on top of Shadcn components that have context state management provided by the assistantUI runtime provider. These pre-built React components come with intelligent state management. [View our components](/docs/ui/thread) ### 2. Runtime A React state management context for assistant chat. The runtime handles data conversions between the local state and calls to backends and LLMs. We offer different runtime solutions that work with various frameworks like Vercel AI SDK, LangGraph, LangChain, Helicone, local runtime, and an ExternalStore when you need full control of the frontend message state. [You can view the runtimes we support](/docs/runtimes/pick-a-runtime) ### 3. Assistant Cloud A hosted service that enhances your assistant experience with comprehensive thread management and message history. Assistant Cloud stores complete message history, automatically persists threads, supports human-in-the-loop workflows, and integrates with common auth providers to seamlessly allow users to resume conversations at any point. [Cloud Docs](/docs/cloud/overview) ### There are three common ways to architect your assistant-ui application: #### **1. Direct Integration with External Providers** ```mermaid graph TD A[Frontend Components] --> B[Runtime] B --> D[External Providers or LLM APIs] classDef default color:#f8fafc,text-align:center style A fill:#e879f9,stroke:#2e1065,stroke-width:2px,color:#2e1065,font-weight:bold style B fill:#93c5fd,stroke:#1e3a8a,stroke-width:2px,color:#1e3a8a,font-weight:bold style D fill:#fca5a5,stroke:#7f1d1d,stroke-width:2px,color:#7f1d1d,font-weight:bold class A,B,C,D,E default ``` #### **2. Using your own API endpoint** ```mermaid graph TD A[Frontend Components] --> B[Runtime] B --> E[Your API Backend] E --> D[External Providers or LLM APIs] classDef default color:#f8fafc,text-align:center style A fill:#e879f9,stroke:#2e1065,stroke-width:2px,color:#2e1065,font-weight:bold style B fill:#93c5fd,stroke:#1e3a8a,stroke-width:2px,color:#1e3a8a,font-weight:bold style D fill:#fca5a5,stroke:#7f1d1d,stroke-width:2px,color:#7f1d1d,font-weight:bold style E fill:#fca5a5,stroke:#7f1d1d,stroke-width:2px,color:#7f1d1d,font-weight:bold class A,B,C,D,E default ``` #### **3. With Assistant Cloud** ```mermaid graph TD A[Frontend Components] --> B[Runtime] B --> C[Cloud] E --> C C --> D[External Providers or LLM APIs] B --> E[Your API Backend] classDef default color:#f8fafc,text-align:center style A fill:#e879f9,stroke:#2e1065,stroke-width:2px,color:#2e1065,font-weight:bold style B fill:#93c5fd,stroke:#1e3a8a,stroke-width:2px,color:#1e3a8a,font-weight:bold style C fill:#86efac,stroke:#064e3b,stroke-width:2px,color:#064e3b,font-weight:bold style D fill:#fca5a5,stroke:#7f1d1d,stroke-width:2px,color:#7f1d1d,font-weight:bold style E fill:#fca5a5,stroke:#7f1d1d,stroke-width:2px,color:#7f1d1d,font-weight:bold class A,B,C,D,E default ``` # CLI URL: /docs/cli Scaffold projects, add components, and manage updates from the command line. *** title: CLI description: Scaffold projects, add components, and manage updates from the command line. ----------------------------------------------------------------------------------------- Use the `assistant-ui` CLI to quickly set up new projects and add components to existing ones. ## init Use the `init` command to initialize configuration and dependencies for a new project. The `init` command installs dependencies, adds components, and configures your project for assistant-ui. ```bash npx assistant-ui@latest init ``` This will: * Detect if you have an existing project with a `package.json` * Use `shadcn add` to install the assistant-ui quick-start component * Add the default assistant-ui components (thread, composer, etc.) to your project * Configure TypeScript paths and imports **When to use:** * Adding assistant-ui to an **existing** Next.js project * First-time setup in a project with `package.json` **Options** ```bash Usage: assistant-ui init [options] initialize assistant-ui in a new or existing project Options: -c, --cwd the working directory. defaults to the current directory. -h, --help display help for command ``` ## create Use the `create` command to scaffold a new Next.js project with assistant-ui pre-configured. ```bash npx assistant-ui@latest create [project-directory] ``` This command uses `create-next-app` with assistant-ui starter templates. **Available Templates** | Template | Description | Command | | ----------- | ------------------------------------ | -------------------------------------- | | `default` | Basic setup with Vercel AI SDK | `npx assistant-ui create` | | `cloud` | With Assistant Cloud for persistence | `npx assistant-ui create -t cloud` | | `langgraph` | LangGraph integration | `npx assistant-ui create -t langgraph` | | `mcp` | Model Context Protocol support | `npx assistant-ui create -t mcp` | **Available Examples** Use `--example` to create a project from one of the monorepo examples with full feature demonstrations: | Example | Description | Command | | -------------------------- | -------------------------------------- | ------------------------------------------------------------ | | `with-ai-sdk-v6` | Vercel AI SDK v6 integration | `npx assistant-ui create my-app -e with-ai-sdk-v6` | | `with-langgraph` | LangGraph agent with custom tools | `npx assistant-ui create my-app -e with-langgraph` | | `with-cloud` | Assistant Cloud persistence | `npx assistant-ui create my-app -e with-cloud` | | `with-ag-ui` | AG-UI protocol integration | `npx assistant-ui create my-app -e with-ag-ui` | | `with-assistant-transport` | Custom backend via Assistant Transport | `npx assistant-ui create my-app -e with-assistant-transport` | | `with-external-store` | External message store | `npx assistant-ui create my-app -e with-external-store` | | `with-custom-thread-list` | Custom thread list UI | `npx assistant-ui create my-app -e with-custom-thread-list` | | `with-react-hook-form` | React Hook Form integration | `npx assistant-ui create my-app -e with-react-hook-form` | | `with-ffmpeg` | FFmpeg video processing tool | `npx assistant-ui create my-app -e with-ffmpeg` | | `with-elevenlabs-scribe` | ElevenLabs voice transcription | `npx assistant-ui create my-app -e with-elevenlabs-scribe` | | `with-parent-id-grouping` | Message part grouping | `npx assistant-ui create my-app -e with-parent-id-grouping` | | `with-react-router` | React Router v7 integration | `npx assistant-ui create my-app -e with-react-router` | | `with-tanstack` | TanStack Start integration | `npx assistant-ui create my-app -e with-tanstack` | **Examples** ```bash # Create with default template npx assistant-ui@latest create my-app # Create with cloud template npx assistant-ui@latest create my-app -t cloud # Create from an example npx assistant-ui@latest create my-app --example with-langgraph # Create with specific package manager npx assistant-ui@latest create my-app --use-pnpm # Skip package installation npx assistant-ui@latest create my-app --skip-install ``` **Options** ```bash Usage: assistant-ui create [project-directory] [options] create a new project Arguments: project-directory name of the project directory Options: -t, --template