# jakobhoeg/shadcn-chat architecture

> Architecture diagram of the GitHub repository jakobhoeg/shadcn-chat, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jakobhoeg/shadcn-chat
- Repository: https://github.com/jakobhoeg/shadcn-chat

## Overview

##### Main Components

a. Package Architecture:
- CLI Tool Package
- UI Components Package
- Documentation Site
- Example Applications

b. Core Components Layer:
- Chat Components
- Base UI Components
- Utility Functions

**Top Level (User Interface):**
- Documentation Site (Next.js)
- Example Applications
- Vercel AI SDK Example

**Middle Level (Packages):**
- shadcn-chat-cli
- Command Handler
- Registry Generator
- shadcn-chat-ui
- Chat Components
- Base Components

**Bottom Level (Dependencies):**
- shadcn-ui
- Tailwind CSS
- React

##### Component Relationships

- Installation flows (CLI to project)
- Component dependencies
- Data flow in chat components

##### Implementation Details to Highlight

- Relationship between the CLI registry and component distribution
- Hook system (useAutoScroll, etc.)
- Demonstrate theme integration points
- Build/compilation process

**┌─ Development Tools ─────┐  ┌─ Component Library ────┐**
- CLI                   │  │ - Chat Components      │
- Registry Generator    │  │ - UI Components        │
- Build Scripts        │  │ - Hooks                │
- ┘  └──────────────────────────┘

**┌─ Documentation ────────┐  ┌─ Examples ─────────────┐**
- Next.js Docs Site   │  │ - Vercel AI SDK Demo   │
- Component Preview   │  │ - Integration Examples │
- API Reference      │  │ - Usage Patterns       │
- ┘  └──────────────────────────┘

##### Additional Elements

- Version management flow
- Npm package distribution
- Relationship with shadcn-ui
- Demonstrate theming system integration

Remember to:
- Use consistent styling
- Clear labels for all components
- Both synchronous and asynchronous interactions
- Error handling flows

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Development Tools"
        CLI["CLI Tool"]:::cli
        Registry["Registry Generator"]:::cli
        CommandHandler["Command Handler"]:::cli
    end

    subgraph "Component Library"
        ChatComponents["Chat Components"]:::component
        BaseComponents["Base UI Components"]:::component
        Utils["Utility Functions"]:::util

        subgraph "Chat Components Detail"
            ChatBubble["Chat Bubble"]:::chat
            ChatInput["Chat Input"]:::chat
            MessageList["Message List"]:::chat
            ExpandableChat["Expandable Chat"]:::chat
            AutoScroll["Auto-scroll Hook"]:::chat
        end

        subgraph "Base Components Detail"
            Avatar["Avatar"]:::base
            Button["Button"]:::base
            Textarea["Textarea"]:::base
        end
    end

    subgraph "Documentation"
        DocsSite["Documentation Site"]:::docs
        ComponentPreviews["Component Previews"]:::docs
        ComponentDocs["Component Documentation"]:::docs
    end

    subgraph "Examples"
        VercelAIExample["Vercel AI Example"]:::example
        AIIntegration["AI Integration"]:::example
    end

    subgraph "Dependencies"
        ShadcnUI["shadcn-ui"]:::dep
        TailwindCSS["Tailwind CSS"]:::dep
        React["React"]:::dep
    end

    %% Relationships
    CLI --> Registry
    CLI --> CommandHandler
    ChatComponents --> BaseComponents
    BaseComponents --> ShadcnUI
    ShadcnUI --> TailwindCSS
    ShadcnUI --> React
    VercelAIExample --> ChatComponents
    DocsSite --> ChatComponents

    %% Component Relationships
    ChatComponents --> ChatBubble
    ChatComponents --> ChatInput
    ChatComponents --> MessageList
    ChatComponents --> ExpandableChat
    ChatComponents --> AutoScroll

    BaseComponents --> Avatar
    BaseComponents --> Button
    BaseComponents --> Textarea

    %% Click Events
    click CLI "https://github.com/jakobhoeg/shadcn-chat/tree/master/packages/cli"
    click CommandHandler "https://github.com/jakobhoeg/shadcn-chat/blob/master/packages/cli/src/commands/add.ts"
    click Registry "https://github.com/jakobhoeg/shadcn-chat/blob/master/packages/cli/src/utils/generate-registry.ts"
    click ChatComponents "https://github.com/jakobhoeg/shadcn-chat/tree/master/packages/ui/src/components/ui/chat"
    click BaseComponents "https://github.com/jakobhoeg/shadcn-chat/tree/master/packages/ui/src/components/ui"
    click Utils "https://github.com/jakobhoeg/shadcn-chat/blob/master/packages/ui/src/lib/utils.ts"
    click DocsSite "https://github.com/jakobhoeg/shadcn-chat/tree/master/apps/docs"
    click ComponentPreviews "https://github.com/jakobhoeg/shadcn-chat/tree/master/apps/docs/components/preview"
    click ComponentDocs "https://github.com/jakobhoeg/shadcn-chat/tree/master/apps/docs/pages/components"
    click VercelAIExample "https://github.com/jakobhoeg/shadcn-chat/tree/master/examples/shadcn-chat-example-vercel-ai"
    click AIIntegration "https://github.com/jakobhoeg/shadcn-chat/tree/master/examples/shadcn-chat-example-vercel-ai/src/app/api/chat"
    click ChatBubble "https://github.com/jakobhoeg/shadcn-chat/blob/master/packages/ui/src/components/ui/chat/chat-bubble.tsx"
    click ChatInput "https://github.com/jakobhoeg/shadcn-chat/blob/master/packages/ui/src/components/ui/chat/chat-input.tsx"
    click MessageList "https://github.com/jakobhoeg/shadcn-chat/blob/master/packages/ui/src/components/ui/chat/chat-message-list.tsx"
    click ExpandableChat "https://github.com/jakobhoeg/shadcn-chat/blob/master/packages/ui/src/components/ui/chat/expandable-chat.tsx"
    click AutoScroll "https://github.com/jakobhoeg/shadcn-chat/blob/master/packages/ui/src/components/ui/chat/hooks/useAutoScroll.tsx"
    click Avatar "https://github.com/jakobhoeg/shadcn-chat/blob/master/packages/ui/src/components/ui/avatar.tsx"
    click Button "https://github.com/jakobhoeg/shadcn-chat/blob/master/packages/ui/src/components/ui/button.tsx"
    click Textarea "https://github.com/jakobhoeg/shadcn-chat/blob/master/packages/ui/src/components/ui/textarea.tsx"

    %% Styling
    classDef cli fill:#FFA500,stroke:#333,stroke-width:2px
    classDef component fill:#3498DB,stroke:#333,stroke-width:2px
    classDef chat fill:#2ECC71,stroke:#333,stroke-width:2px
    classDef base fill:#3498DB,stroke:#333,stroke-width:2px
    classDef docs fill:#9B59B6,stroke:#333,stroke-width:2px
    classDef example fill:#E74C3C,stroke:#333,stroke-width:2px
    classDef dep fill:#95A5A6,stroke:#333,stroke-width:2px
    classDef util fill:#F1C40F,stroke:#333,stroke-width:2px
```
