# abhisheksrikanth/saturchat-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/abhisheksrikanth/saturchat-frontend
- Repository: https://github.com/abhisheksrikanth/saturchat-frontend

## Overview

##### Project Type and Purpose
- Type: React/Vite frontend for a real‐time chat platform.
- Purpose: Provide users with a responsive UI for messaging, group management, user profiles, and AI bot integration.

##### File Structure
- Top‐level:
– index.html + public/: Static entry point and assets.
– src/: All React logic (components/, layouts/, pages/, services/, context/, hooks/).
– vite.config.js: Build/dev config.
– Dockerfile, GitHub Actions: Deployment pipelines.
- Key subdirectories:
– components/: UI building blocks (chat bubbles, modals, sidebars).
– services/: HTTP client (axios.js), auth.js, chat.js.
– hooks/: WebSocket hooks (useChatSocket, useUserSocket).
– context/: JWT‐based AuthProvider & hooks.
– layouts/ + pages/: Route‐based pages (Login, Register, Chat, Profile, Error).

##### Extract Insights from README
- Tech stack: React 19, Vite, TailwindCSS.
- Real‐time messaging via WebSockets (VITE_WS_BASE_URL).
- HTTP API calls to a JWT‐secured backend (VITE_API_BASE_URL).
- Integration with AI bots for automated responses.
- Deployment: serve index.html via NGINX; CORS/proxy for API + WS.

##### Main Components & Their Relationships
a. Browser & Static Hosting
– Vite Dev Server (dev mode) or NGINX (prod) serves index.html + JS/CSS.
b. React Application
– UI Layer: pages → layouts → components
– State Management: AuthContext (JWT storage), custom hooks
– Service Layer: axios HTTP client for REST; WebSocket wrappers
c. Backend Services (external to this repo)
– REST API (Auth, Users, Conversations, AI)
– WebSocket Server (real-time chat streams)
– AI Bot Service (internal or third-party)
– Database (users, messages, conversation metadata)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Static Hosting
    subgraph "Static Host (Dev: Vite / Prod: NGINX)" 
        SH1["index.html"]:::frontend
        SH2["vite.config.js"]:::frontend
        SH3["Dockerfile"]:::ci
    end

    %% Browser & React Application
    subgraph "Browser & React App" 
        Browser["Browser"]:::frontend

        subgraph "Entry Points" 
            EP1["main.jsx"]:::frontend
            EP2["App.jsx"]:::frontend
            EP3["App.css"]:::frontend
            EP4["index.css"]:::frontend
        end

        subgraph "UI Components (src/components/)" 
            UI["Components"]:::frontend
        end

        subgraph "Pages (src/pages/)" 
            Pages["Pages"]:::frontend
        end

        subgraph "Layouts (src/layouts/)" 
            Layouts["Layouts"]:::frontend
        end

        subgraph "Context & Hooks" 
            Context["Context"]:::frontend
            Hooks["Hooks"]:::frontend
        end

        subgraph "Service Layer (src/services/)" 
            Services["Services"]:::frontend
        end

        subgraph "Static Assets" 
            Public["public/"]:::frontend
            Assets["src/assets/"]:::frontend
        end
    end

    %% Backend Ecosystem
    subgraph "Backend Services" 
        REST["REST API Server"]:::backend
        WS["WebSocket Server"]:::backend
        AI["AI Service"]:::external
        DB["Database"]:::backend
    end

    %% CI/CD Pipeline
    subgraph "CI/CD & Deployment" 
        GH["GitHub Actions"]:::ci
        Docker["Docker Build & Deploy"]:::ci
    end

    %% Data Flows
    Browser -->|"GET index.html, JS, CSS"| SH1
    SH1 -->|serves| Browser
    Browser -->|loads| EP1
    EP1 --> EP2 --> EP3
    EP1 --> EP4

    Browser -->|renders| UI
    Browser -->|navigates| Pages
    Pages --> Layouts --> UI

    Browser -->|uses AuthContext| Context
    Browser -->|uses Hooks| Hooks
    Browser -->|calls| Services

    Services -->|"HTTP(S) requests"| REST
    Hooks -->|"WebSocket handshake"| WS

    REST -- "CRUD users/messages" --> DB
    REST -->|"forward context"| AI
    WS -->|"persist & broadcast"| DB
    WS -->|broadcast| Browser

    GH -->|runs build| Docker
    Docker -->|deploy to NGINX| SH3

    %% Click Events
    click SH1 "https://github.com/abhisheksrikanth/saturchat-frontend/blob/main/index.html"
    click SH2 "https://github.com/abhisheksrikanth/saturchat-frontend/blob/main/vite.config.js"
    click SH3 "https://github.com/abhisheksrikanth/saturchat-frontend/tree/main/Dockerfile"
    click EP1 "https://github.com/abhisheksrikanth/saturchat-frontend/blob/main/src/main.jsx"
    click EP2 "https://github.com/abhisheksrikanth/saturchat-frontend/blob/main/src/App.jsx"
    click EP3 "https://github.com/abhisheksrikanth/saturchat-frontend/blob/main/src/App.css"
    click EP4 "https://github.com/abhisheksrikanth/saturchat-frontend/blob/main/src/index.css"
    click UI "https://github.com/abhisheksrikanth/saturchat-frontend/tree/main/src/components/"
    click Pages "https://github.com/abhisheksrikanth/saturchat-frontend/tree/main/src/pages/"
    click Layouts "https://github.com/abhisheksrikanth/saturchat-frontend/tree/main/src/layouts/"
    click Context "https://github.com/abhisheksrikanth/saturchat-frontend/tree/main/src/context/"
    click Hooks "https://github.com/abhisheksrikanth/saturchat-frontend/tree/main/src/hooks/"
    click Services "https://github.com/abhisheksrikanth/saturchat-frontend/tree/main/src/services/"
    click Public "https://github.com/abhisheksrikanth/saturchat-frontend/tree/main/public/"
    click Assets "https://github.com/abhisheksrikanth/saturchat-frontend/tree/main/src/assets/"
    click GH "https://github.com/abhisheksrikanth/saturchat-frontend/blob/main/.github/workflows/build.yml"
    click Docker "https://github.com/abhisheksrikanth/saturchat-frontend/tree/main/Dockerfile"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:1px
    classDef backend fill:#D3F9D8,stroke:#28a745,stroke-width:1px
    classDef external fill:#FFE5B4,stroke:#d2691e,stroke-width:1px
    classDef ci fill:#F0E68C,stroke:#b8860b,stroke-width:1px
```
