# eduhubsolutions/chatboard architecture

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

- Interactive diagram: https://gitdiagram.com/eduhubsolutions/chatboard
- Repository: https://github.com/eduhubsolutions/chatboard

## Overview

##### Project type and purpose
- This is a WordPress plugin (“index.php” + “assets/style.css”) that injects a live-chat/chatbot widget into any WordPress site.
- Its core responsibility is embedding chat UI & loading/supporting the ChatBoard PWA admin console.
- It communicates with ChatBoard’s cloud platform for real-time chat, notifications, analytics, integrations (Dialogflow, WooCommerce, social channels).

##### File structure
- index.php: the main WP plugin file—registers hooks, shortcodes, enqueues assets, embeds ChatBoard scripts.
- assets/style.css: front-end styling for chat widget.
- README.md/readme.txt: documentation—no other code modules or microservices here.

##### Extract key architecture points from README
- Front-end chat widget (live chat + chatbot) embedded via shortcode or PHP.
- Back-end PWA admin console (runs within WP admin as a PWA).
- Web API / JS API / PHP API offered by ChatBoard cloud.
- Third-party integrations: Dialogflow, email/SMS/push services, WooCommerce, Facebook/Telegram, etc.

a. WordPress Host
- WP Core
- Chat Board Plugin (index.php + assets)
- Shortcode/Hook processor
- Asset enqueuer (CSS, JS loader for widget & PWA)
- WP Admin Area (with PWA service worker for admin console)
b. Visitor Browser
- Loads WP page → receives ChatBoard widget JS/CSS → displays chat UI
- Initiates WebSocket/REST calls to ChatBoard cloud
- Receives notifications (desktop push, title updates)
c. ChatBoard Cloud Platform
- Chat Server (WebSocket / Socket.io) for real-time messaging
- REST API for configuration, history, analytics
- Authoring & routing (live agents vs. bot)
- Bot Engine (Dialogflow CX/ES integration)
- Notification Engine (email, SMS gateway, push services)
- Data Storage (conversations, user profiles, analytics)
d. Third-Party Services
- Dialogflow (bot responses, NLP)
- WooCommerce (customer data sync)
- Social Channels (Facebook, Telegram)
- Email/SMS providers (SendGrid/Twilio)
- Push Notification Service (Web Push, FCM, APNs)

##### Relationships & interactions
- User ↔ Browser widget ↔ ChatBoard cloud (messages flow via WebSocket)
- Plugin ↔ Browser (injects widget code, installs PWA in admin)
- WP Admin console ↔ ChatBoard cloud REST API (admin config, view reports)
- ChatBoard cloud ↔ Dialogflow & other third parties (via REST/webhooks)
- ChatBoard cloud ↔ Notification services (via API calls)

##### Architectural patterns & principles
- Plugin acts as an “edge” or “proxy” that injects front-end code; business logic resides in cloud.
- SPA/PWA pattern for admin console.
- Real-time event bus (WebSocket) for messaging.
- Micro-integrations via REST/webhooks to external services.
- Shortcodes for seamless WP integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% WordPress Host
    subgraph "WordPress Host"
        WP_Core["WP Core"]:::onsite
        Plugin["ChatBoard Plugin"]:::onsite
        ShortcodeProcessor["Shortcode/Hook Processor"]:::onsite
        AssetEnqueuer["Asset Enqueuer"]:::onsite
        DocMd["README.md"]:::onsite
        DocTxt["readme.txt"]:::onsite
        WP_Admin["WP Admin Area\nPWA Service Worker"]:::client
    end

    %% Visitor Browser
    subgraph "Visitor Browser"
        Browser["Browser"]:::client
        ChatWidget["Chat Widget UI"]:::client
    end

    %% ChatBoard Cloud Platform
    subgraph "ChatBoard Cloud Platform"
        ChatServer["Chat Server\n(WebSocket/Socket.io)"]:::cloud
        RestAPI["REST API\n(Configuration, History)"]:::cloud
        AuthoringRouting["Authoring & Routing"]:::cloud
        BotEngine["Bot Engine\n(Dialogflow CX/ES Integration)"]:::cloud
        NotificationEngine["Notification Engine\n(Email, SMS, Push)"]:::cloud
        DataStorage["Data Storage\n(Conversations, Profiles, Analytics)"]:::cloud
    end

    %% Third-Party Services
    subgraph "Third-Party Services"
        Dialogflow["Dialogflow"]:::external
        WooCommerce["WooCommerce"]:::external
        SocialChannels["Social Channels\n(Facebook, Telegram)"]:::external
        EmailSMS["Email/SMS Providers"]:::external
        PushService["Push Notification Service\n(Web Push, FCM, APNs)"]:::external
    end

    %% Relationships
    Plugin -->|"Injects widget code"| Browser
    Plugin --> ShortcodeProcessor
    Plugin --> AssetEnqueuer
    Plugin --> DocMd
    Plugin --> DocTxt
    AssetEnqueuer -->|"Enqueues CSS/JS"| Browser
    AssetEnqueuer -->|"Loads style.css"| ChatWidget
    click Plugin "https://github.com/eduhubsolutions/chatboard/blob/main/index.php"
    click AssetEnqueuer "https://github.com/eduhubsolutions/chatboard/blob/main/assets/style.css"
    click DocMd "https://github.com/eduhubsolutions/chatboard/blob/main/README.md"
    click DocTxt "https://github.com/eduhubsolutions/chatboard/blob/main/readme.txt"

    WP_Admin -->|"PWA Service Worker"| Browser
    WP_Admin -->|"REST API"| RestAPI

    Browser -->|WebSocket| ChatServer
    ChatServer -->|WebSocket| Browser
    Browser -->|REST API| RestAPI

    RestAPI -->|Fetch/Save Data| DataStorage
    ChatServer -->|Store/Retrieve| DataStorage

    RestAPI --> AuthoringRouting
    AuthoringRouting -->|"Route to Live Agent or Bot"| ChatServer

    AuthoringRouting -->|"Invoke Bot Engine"| BotEngine
    BotEngine -->|Webhook/REST| Dialogflow

    NotificationEngine -->|Email/SMS| EmailSMS
    NotificationEngine -->|Push| PushService
    NotificationEngine -->|Social Messages| SocialChannels

    RestAPI --> NotificationEngine
    RestAPI --> DataStorage

    %% Cloud to Third-Party Data Sync
    RestAPI ---|Optional Sync| WooCommerce

    %% Styles
    classDef onsite fill:#AED6F1,stroke:#1B4F72,color:#1B2631
    classDef client fill:#A9DFBF,stroke:#145A32,color:#0E2F1A
    classDef cloud fill:#F9E79F,stroke:#7D6608,color:#4E342E
    classDef external fill:#F5B7B1,stroke:#922B21,color:#581511
    classDef dashed stroke-dasharray: 5 5

    class RestAPI,ChatServer,AuthoringRouting,BotEngine,NotificationEngine,DataStorage cloud
    class WP_Core,Plugin,ShortcodeProcessor,AssetEnqueuer,DocMd,DocTxt onsite
    class Browser,ChatWidget,WP_Admin client
    class Dialogflow,WooCommerce,SocialChannels,EmailSMS,PushService external
    class RestAPI,WooCommerce dashed
```
