# asharibali/flowisechatembed architecture

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

- Interactive diagram: https://gitdiagram.com/asharibali/flowisechatembed
- Repository: https://github.com/asharibali/flowisechatembed

## Overview

##### Main Components

a) Client-Side Components:
- Chat Interface Layer (Components)
- Bubble Feature
- Popup Feature
- Full Page Feature
- Input Components
- Message Bubbles
- Buttons & Controls
- Avatar System

b) Communication Layer:
- Message Query System
- WebSocket/HTTP Communication
- Proxy Server (Security Layer)

c) Integration Layer:
- Flowise API Integration
- Configuration System
- Observer Pattern Implementation

**[Client Website]**

- ▼
**[Flowise Embed Library]──────────────────┐**

- [UI Components]                    │
- [Chat Variants]               │
- Bubble                     │
- Popup                      │
- Full Page                  │

- [Interface Elements]          │
- Message Bubbles           │
- Input System              │
- Buttons                   │
- Avatars                   │

- [Core Services]                   │
- Message Handler              │
- Audio Recording              │
- File Upload                  │
- Chat History                 │

- ▼                                  ▼
**[Proxy Server (Optional)]        [Direct Connection]**

- ►[Flowise API]◄─────┘

##### Key Elements to Highlight

a) Component Architecture:
- Hierarchical structure of UI components
- Three main deployment modes (Bubble, Popup, Full)
- Modular nature of the components

b) Data Flow:
- Message transmission path
- File upload handling
- Audio recording flow
- Configuration propagation

c) Security Layer:
- Proxy server implementation
- Domain validation
- API key handling
- Secure communication channels

##### Implementation Details

- Configuration injection points
- Customization options (theme, styling)
- Where observers are implemented
- Sound effect integration points

##### Technical Stack Indicators

- TypeScript/JavaScript
- DOM Web Components
- CSS/Tailwind
- Audio/File handling capabilities

##### Integration Points

- How the library connects to host websites
- Configuration entry points
- API communication channels
- Observer pattern hookpoints

Remember to include notes about:
- The experimental proxy server feature
- Configuration options
- Security considerations
- Integration methods (PopUp vs FullPage)

This will provide a complete picture of how the system works while maintaining clarity about its architecture and implementation details.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CW[Client Website]
    end

    subgraph FlowiseEmbed[Flowise Embed Library]
        WEB[Web Integration]
        REG[Component Registration]
        TYPES[Type Definitions]
        CONST[Constants]

        subgraph UI[UI Components Layer]
            BOT[Main Bot Component]
            subgraph Features[Chat Variants]
                BUB[Bubble Feature]
                POP[Popup Feature]
                FULL[Full Page Feature]
            end

            subgraph Interface[Interface Elements]
                MB[Message Bubbles]
                INP[Input System]
                BTN[Buttons & Controls]
                AVA[Avatar System]
                ICO[Icons]
                FB[Feedback System]
                TYP[Typing Indicator]
            end
        end

        subgraph Core[Core Services]
            MH[Message Handler]
            AR[Audio Recording]
            CH[Chat History]
            MD[Mobile Detection]
        end

        subgraph Assets[Assets]
            SFX[Sound Effects]
            CSS[Styling]
        end
    end

    subgraph Communication[Communication Layer]
        MQ[Message Query System]
        choice{Proxy Enabled?}
        PS[Proxy Server]
        DC[Direct Connection]
    end

    FAPI[Flowise API]

    %% Relationships
    CW --> WEB
    WEB --> UI
    WEB --> Core
    MH --> MQ
    MQ --> choice
    choice -->|Yes| PS
    choice -->|No| DC
    PS --> FAPI
    DC --> FAPI

    %% Component Mappings
    click WEB "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/web.ts"
    click REG "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/register.tsx"
    click TYPES "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/types.ts"
    click CONST "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/constants.ts"
    click BOT "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/components/Bot.tsx"
    click BUB "https://github.com/AsharibAli/flowisechatEmbed/tree/main/src/features/bubble/"
    click POP "https://github.com/AsharibAli/flowisechatEmbed/tree/main/src/features/popup/"
    click FULL "https://github.com/AsharibAli/flowisechatEmbed/tree/main/src/features/full/"
    click MB "https://github.com/AsharibAli/flowisechatEmbed/tree/main/src/components/bubbles/"
    click INP "https://github.com/AsharibAli/flowisechatEmbed/tree/main/src/components/inputs/"
    click BTN "https://github.com/AsharibAli/flowisechatEmbed/tree/main/src/components/buttons/"
    click AVA "https://github.com/AsharibAli/flowisechatEmbed/tree/main/src/components/avatars/"
    click ICO "https://github.com/AsharibAli/flowisechatEmbed/tree/main/src/components/icons/"
    click FB "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/components/FeedbackContentDialog.tsx"
    click TYP "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/components/TypingBubble.tsx"
    click AR "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/utils/audioRecording.ts"
    click CH "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/utils/chatInputHistory.ts"
    click MD "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/utils/isMobileSignal.ts"
    click MQ "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/queries/sendMessageQuery.ts"
    click SFX "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/assets/receive_message.mp3"
    click CSS "https://github.com/AsharibAli/flowisechatEmbed/blob/main/src/assets/index.css"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef interface fill:#dbeafe,stroke:#333,stroke-width:2px
    classDef core fill:#dcfce7,stroke:#333,stroke-width:2px
    classDef communication fill:#fee2e2,stroke:#333,stroke-width:2px
    classDef external fill:#f3f4f6,stroke:#333,stroke-width:2px
    classDef assets fill:#fef3c7,stroke:#333,stroke-width:2px

    class UI,BOT,Features,Interface,MB,INP,BTN,AVA,ICO,FB,TYP interface
    class Core,MH,AR,CH,MD core
    class Communication,MQ,PS,DC communication
    class FAPI,CW external
    class Assets,SFX,CSS assets
```
