How shadcn-ui/chatbot-template works
This Next.js chatbot template takes a user prompt through the chat UI to a streaming AI Gateway response, then renders text, reasoning, citations, and tool states. Distinct branches support GitHub repository lookup, provider-native web search, and a human-in-the-loop questionnaire whose answer resumes the conversation. The graph includes the model allowlist and the principal message-part renderers. Evidence is limited to the supplied excerpts, source index, and README; some UI-to-route wiring and unsampled tool internals are documented rather than inspected.
Main entry points: chat-message.tsx Message dispatch · chat.tsx Conversation state · route.ts Streaming chat route · index.ts Tool registry
Components 23
Chat experience
- Chat page
app/page.tsx - Conversation state
components/chat.tsx - Prompt and model form
components/prompt-form.tsx - Pending question UI
components/question-card.tsx
Chat orchestration
- Model allowlist
lib/models.ts - Streaming chat route
app/api/chat/route.ts
Tool capabilities
- Tool registry
tools/index.ts - GitHub lookup tool
tools/github_repo.ts - Web search tool
tools/web_search.ts - Question tool
tools/ask_user.ts
Message rendering
- Message dispatch
components/chat-message.tsx - Markdown text part
components/parts/text-part.tsx - GitHub result part
components/parts/github-repo-part.tsx - Search status part
components/parts/web-search-part.tsx - Question answer part
components/parts/ask-user-part.tsx - Reasoning part
components/parts/reasoning-part.tsx - Citation drawer
components/parts/sources-part.tsx - Message scroller
components/ui/message-scroller.tsx - Questionnaire controls
components/ui/questionnaire.tsx
Other components
- Chat user
- Vercel AI Gateway
- GitHub service
- Provider search
Connections 25
- Chat user → Chat page: opens
README.md - Chat page → Conversation state: renders
app/page.tsx - Conversation state → Prompt and model form: renders
components/chat.tsx - Prompt and model form → Conversation state: submits prompt
components/chat.tsx - Conversation state → Streaming chat route: streams with
README.md - Streaming chat route → Model allowlist: validates model
app/api/chat/route.ts - Streaming chat route → Tool registry: selects tools
app/api/chat/route.ts - Streaming chat route → Vercel AI Gateway: generates response
README.md - Tool registry → GitHub lookup tool: registers
tools/index.ts - Tool registry → Question tool: registers
tools/index.ts - Tool registry → Web search tool: selects
tools/index.ts - GitHub lookup tool → GitHub service: looks up repository
README.md - Web search tool → Provider search: uses native search
README.md - Conversation state → Message dispatch: renders messages
components/chat.tsx - Message dispatch → Markdown text part: delegates text
components/chat-message.tsx - Message dispatch → GitHub result part: delegates tool part
components/chat-message.tsx - Message dispatch → Search status part: delegates tool part
components/chat-message.tsx - Message dispatch → Question answer part: delegates tool part
components/chat-message.tsx - Message dispatch → Reasoning part: delegates reasoning
components/chat-message.tsx - Message dispatch → Citation drawer: renders citations
components/chat-message.tsx - Conversation state → Message scroller: displays conversation
components/chat.tsx - Conversation state → Pending question UI: shows pending question
components/chat.tsx - Pending question UI → Questionnaire controls: renders controls
components/question-card.tsx - Pending question UI → Conversation state: submits tool answer
components/chat.tsx - Markdown text part → Message dispatch: returns rendered text
components/chat-message.tsx