How tambo-ai/tambo works
Project Type and Purpose
• This is a monorepo developer toolkit (“tambo-ai”) centered around a React SDK for generative UI components, plus supporting packages and a demo.
• Top‐level modules:
– cli: a CLI tool to scaffold, add, update, and manage tambo-based apps
– create-tambo-app: a thin wrapper around the CLI for “npm create tambo-app”
– packages/*: shared ESLint and TypeScript config packages
– react-sdk: the core React library providing TamboProvider, hooks, registry, and MCP clients
– showcase: a Next.js demonstration app consuming react-sdk
File Structure Analysis
– Monorepo orchestrated by turbo.json and workspaces (package.json)
– cli/src/commands: command modules (create-app, add, upgrade, etc.)
– cli/src/registry: built‐in component registry templates & JSON configs
– react-sdk/src:
• providers: TamboProvider, MCP provider, registry provider
• hooks: useTamboThreadInput, useTamboComponentState, etc.
• mcp: MCP‐client implementations
• util/model: component metadata, schemas, thread data
– showcase/src: Next.js app organized by route, UI primitives, and imports from react-sdk
Key README Insights
– tambo-ai exposes a client‐side registry of React components to an LLM via “MCP” servers
– You register your components with name, description, Zod schema; wrap app in TamboProvider; use hooks to submit messages and render AI‐generated components
– Supports pluggable “tools” and custom MCP servers, relying on streaming API
Main Components
A. Monorepo Orchestrator
• Turbo (turbo.json), GitHub workflows (CI, release)
B. CLI Layer (cli & create-tambo-app)
• Commands: create-app, add, init, list, upgrade
• Templates & registry JSON → scaffolding
C. Config Packages
• ESLint and TypeScript configs used by CLI, SDK, and showcase
D. Core Library (react-sdk)
• TamboProvider & TamboMcpProvider (React Context)
• Registry Provider (component registry)
• Hooks (input, streaming, component state)
• MCP clients (HTTP transport)
• Models & Zod schemas
E. Demo Application (showcase)
• Next.js front-end consuming react-sdk
• Components folders organized by feature (message-primitives, generative, canvas, etc.)
F. External Services
• MCP Servers (user‐configured endpoints)
• LLM API backends (OpenAI, Azure, etc.)
Relationships & Data Flows
• Developer → [CLI] → scaffolds new app code (using templates from cli/src/registry)
• Generated App → installs react-sdk and config packages → developer code
• Runtime: User input in UI → useTamboThreadInput.submit() → TamboMcpProvider → MCP Server → LLM → stream responses back → react-sdk updates component state → UI renders new components
• Tools: optional functions registered in TamboProvider that LLM can invoke via MCP
Architectural Patterns & Design Principles
• Monorepo (turbo) for unified builds, testing, and release
• CLI scaffolding pattern with pluggable commands and JSON‐based templates
• React Context + hooks pattern for state management and streaming data
• Registry pattern: decouple component metadata & rendering logic
• Pluggable transport/providers for MCP servers and tools
• Zod schemas for prop/tool validation and type safety
Essential Elements to Capture
– Monorepo root and CI/CD orchestration
– CLI and create-tambo-app packages with template registry
– Shared config packages (eslint-config, typescript-config)
– react-sdk internals: providers, hooks, mcp clients, registry, models
– Demo application structure and its import of react-sdk
– External MCP servers and LLM API endpoints
– Flow of user input → hook → network call → component state → rendered component