# bhavesh10joshi/livelink architecture

> Architecture diagram of the GitHub repository bhavesh10joshi/livelink, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhavesh10joshi/livelink
- Repository: https://github.com/bhavesh10joshi/livelink

## Overview

##### What this project is (type + purpose)
**LiveLink** is a **full-stack real-time chat application** (WhatsApp-like) with:
- **React + TypeScript + Tailwind** frontend (Vite)
- **Node.js + Express** backend
- **WebSockets** for real-time messaging / live updates
- **MongoDB + Mongoose** as the primary datastore
- Supporting services: **OAuth provider**, **Cloudinary** (images), **Nodemailer/SMTP** (email/OTP/invites)

- **Client–server separation**
- **Two communication planes**: REST (request/response) + WebSocket (bi-directional, event-driven)
- **Core domains**: Auth, Users/Friends, Groups, Messaging (1:1 and group), Notifications, Invites, Media/Profile images

##### Frontend (`frontend/`)
Key architectural “modules” are clear from `src/Pages/*` and `src/Components/*`:
- **Auth & password flows**: `SignInPage`, `CreateAnAccount`, `ForgotPass*`, `VerifyOtp`, `ChangePassword*`
- **Chat**: `ChattingDashboards/*`, `Chatting/*` (separate U2U vs U2G views)
- **Groups**: `CreateNewGroup`, `EditGroupInfo`, `AddMemberstoGroup`, `GroupInfo`, `DeleteGroupConfirm`
- **Users/Friends**: `SearchUserPage`, `FriendsSideBar`, `UserInfo`
- **Notifications**: `NotificationsDashboard`
- **Profile/settings**: `EditUserProfile`, `UserSettings`, `DeleteUserAccount`
- API endpoint centralization: `src/Config/ApiConfig.tsx`
- Validation on client: `src/ZodVaalidations/Zod.tsx`

##### Backend (`Backend/src/`)
This is a classic Express modular routing structure:
- Entry point: `src/index.ts`
- DB connection: `src/db/index.ts`
- Routing by domain:
- `Router/User/User.ts`
- `Router/Group/Group.ts`
- `Router/Messaging/UsertoUser/PersonalCommunication.ts`
- `Router/Messaging/UserToGroup/GroupCommunication.ts`
- `Router/Notifications/...`
- `Router/SendInvites/...`
- Cross-cutting concerns:
- `Middleware/Index.ts` (auth, request parsing, etc.)
- `ZodValidations/index.ts` (API input validation)
- `otp/otp.ts` (OTP generation/verification flows)
- `Nodemailer/emailvianode.ts` (email transport)
- `CloudinaryConfig/Cloudinary.ts` (image hosting integration)
- `uuid/index.ts`, `CurrentDateandTime/DateAndTime.ts`
- membership/relationship checks: `CheckForAFriend/*`, `CheckforaGroupMember/*`

##### Backend → MongoDB: store/verify user credentials (bcrypt implied)
3. Backend → Browser: JWT (and possibly refresh token if present—README doesn’t mention refresh; keep it simple: JWT)

##### OAuth login
- Browser → OAuth Provider (redirect / popup)
- Browser/OAuth Provider → Backend (token exchange/verification)
- Backend → MongoDB (create/link user)
- Backend → Browser (JWT)

##### One-to-one messaging (real-time)
- Browser ↔ Backend (WebSocket): send message event
- Backend → MongoDB: persist message
- Backend ↔ Recipient Browser (WebSocket): deliver message + ack event (if implemented)
REST fallback usage if any exists (not obvious from tree; keep focus on WS).

##### Messaging
- Browser ↔ Backend (WebSocket): send group message event
- Backend: Check group membership (`CheckforaGroupMember`)
- Backend → MongoDB: persist message + group membership references
- Backend → group member sockets: broadcast

##### Invites + OTP/email
- Browser → Backend (REST): invite user / OTP request
- Backend → Email (Nodemailer/SMTP): send invite/OTP
- Backend → MongoDB: store OTP/invite status (conceptually)

##### Profile/group images
- Browser → Backend (REST): upload image (or request signature)
- Backend → Cloudinary: store asset, receive URL
- Backend → MongoDB: persist URL on user/group document
- Browser loads image directly from Cloudinary CDN URL

##### Notifications
- Browser → Backend (REST): fetch notification list, mark read
- Backend → MongoDB: read/update notifications

##### How to split components (practical grouping)
Instead of listing dozens of React components, show frontend as 5–7 blocks:
- Auth UI (SignIn/SignUp/Forgot/OTP)
- Chat UI (U2U + U2G dashboards)
- Groups UI (create/edit/add members)
- Notifications UI
- Profile/Settings UI
- API Client (ApiConfig + fetch/axios wrapper)
- WebSocket Client

Backend should be split close to the folder structure (high fidelity):
- User Router
- Router
- Messaging Router (U2U)
- Messaging Router (U2G)
- Notifications Router (Personal + Group)
- Invites Router
- Middleware (JWT/Auth)
- Validation (Zod)
- Services: OTP, Email, Cloudinary
- DB access layer (Mongoose)

- **Browser**
- React SPA (Auth / Chat / Groups / Notifications / Profile)
- WebSocket Client
- REST API Client
- **Backend: Node/Express + WebSocket**
- Middleware (JWT)
- Zod Validation
- Routers:
- User
- Group
- Messaging (U2U, U2G)
- Notifications (Personal, Group)
- Invites
- Services:
- OTP
- Email (Nodemailer)
- Cloudinary
- DB Layer (Mongoose)
- **MongoDB**
- **Cloudinary**
- **OAuth Provider**
- **SMTP/Email Provider**

- REST traffic for management actions
- WS traffic for realtime message delivery/broadcast
- Persistence to MongoDB for all durable state
- Side effects to Cloudinary + Email services

This will be “as detailed as possible” while still readable and faithful to the repository.

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================
  %% Actors / Public Internet
  %% =========================
  subgraph "Public Internet (Untrusted)"
    User["End User"]:::actor
    Browser["Web Browser"]:::client
    User -->|"uses"| Browser
  end

  %% =========================
  %% Frontend (SPA)
  %% =========================
  subgraph "LiveLink Frontend (React + TypeScript + Tailwind)"
    FEEntry["SPA Entry (Vite)"]:::frontend
    FEApp["Root App (Routing/Layout)"]:::frontend

    subgraph "Frontend Feature Areas"
      FEAuth["Auth UI (SignIn/SignUp/Forgot/OTP/ChangePassword)"]:::frontend
      FEChat["Chat UI (U2U + U2G Dashboards)"]:::frontend
      FEGroups["Groups UI (Create/Edit/Add Members/Info/Delete)"]:::frontend
      FEFriends["Users/Friends UI (Search/Friends Sidebar/User Info)"]:::frontend
      FENotifyUI["Notifications UI (Dashboard)"]:::frontend
      FEProfile["Profile/Settings UI (Edit/Settings/Delete)"]:::frontend
    end

    FEApi["REST API Client (ApiConfig)"]:::frontend
    FEZod["Client Validation (Zod)"]:::frontend
    FEWS["WebSocket Client"]:::frontend

    FEEntry -->|"bootstraps"| FEApp
    FEApp -->|"renders"| FEAuth
    FEApp -->|"renders"| FEChat
    FEApp -->|"renders"| FEGroups
    FEApp -->|"renders"| FEFriends
    FEApp -->|"renders"| FENotifyUI
    FEApp -->|"renders"| FEProfile

    FEAuth -->|"uses"| FEApi
    FEChat -->|"uses"| FEApi
    FEGroups -->|"uses"| FEApi
    FEFriends -->|"uses"| FEApi
    FENotifyUI -->|"uses"| FEApi
    FEProfile -->|"uses"| FEApi

    FEAuth -->|"validates"| FEZod
    FEGroups -->|"validates"| FEZod
    FEProfile -->|"validates"| FEZod

    FEChat -->|"connects"| FEWS
    FENotifyUI -.->|"planned_WS_push"| FEWS
  end

  Browser -->|"loads"| FEEntry

  %% =========================
  %% Backend (API + WS)
  %% =========================
  subgraph "LiveLink Backend (Node.js + Express + WebSocket)"
    BEIndex["Express App + WS Server (Entry)"]:::backend

    subgraph "Cross-cutting"
      BEMW["Middleware (JWT/Auth, parsing)"]:::backend
      BEVal["API Validation (Zod)"]:::backend
      BEStatus["Status Codes/Constants"]:::backend
      BEUUID["UUID Utility"]:::backend
      BEDT["Date/Time Utility"]:::backend
    end

    subgraph "Domain Routers (REST Controllers)"
      BEUser["User Router (Auth/Users)"]:::api
      BEGroup["Group Router"]:::api
      BEInvites["Invites Router"]:::api
      BENotif["Notifications Routers (Personal + Group)"]:::api
    end

    subgraph "Realtime Messaging (WebSocket Handlers)"
      BEWSCore["WS Gateway (auth handshake + events)"]:::ws
      BEMsgU2U["Messaging U2U (PersonalCommunication)"]:::ws
      BEMsgU2G["Messaging U2G (GroupCommunication)"]:::ws
    end

    subgraph "Domain Guards"
      BEFriendGuard["Friend Check (CheckForAFriend)"]:::guard
      BEGroupGuard["Group Membership Check (CheckforaGroupMember)"]:::guard
    end

    subgraph "Services"
      BEOTP["OTP Service"]:::service
      BEEmail["Email Service (Nodemailer)"]:::service
      BEMedia["Media Service (Cloudinary)"]:::service
    end

    subgraph "Persistence"
      BEDB["DB Module (MongoDB/Mongoose Connector)"]:::db
      BERepo["Mongoose Models/Repositories (conceptual)"]:::db
      BEDB -->|"connects"| BERepo
    end

    %% request flow wiring
    BEIndex -->|"applies"| BEMW
    BEMW -->|"validates"| BEVal

    BEVal -->|"routes_to"| BEUser
    BEVal -->|"routes_to"| BEGroup
    BEVal -->|"routes_to"| BEInvites
    BEVal -->|"routes_to"| BENotif

    %% ws flow wiring
    BEIndex -->|"upgrades_to_WS"| BEWSCore
    BEWSCore -->|"events_to"| BEMsgU2U
    BEWSCore -->|"events_to"| BEMsgU2G

    %% guards
    BEGroup -->|"checks"| BEFriendGuard
    BEMsgU2U -->|"checks"| BEFriendGuard
    BEGroup -->|"checks"| BEGroupGuard
    BEMsgU2G -->|"checks"| BEGroupGuard

    %% persistence
    BEUser -->|"reads/writes"| BERepo
    BEGroup -->|"reads/writes"| BERepo
    BEInvites -->|"reads/writes"| BERepo
    BENotif -->|"reads/writes"| BERepo
    BEMsgU2U -->|"persists"| BERepo
    BEMsgU2G -->|"persists"| BERepo

    %% services usage
    BEUser -->|"issues/verifies"| BEOTP
    BEInvites -->|"triggers"| BEEmail
    BEOTP -->|"sends"| BEEmail
    BEGroup -->|"uploads"| BEMedia
    BEUser -->|"uploads"| BEMedia

    BEIndex -->|"uses"| BEStatus
    BEIndex -->|"uses"| BEUUID
    BEIndex -->|"uses"| BEDT
  end

  %% =========================
  %% Data Store
  %% =========================
  subgraph "Data Store (Trusted)"
    Mongo[(MongoDB)]:::db
  end
  BERepo -->|"CRUD"| Mongo

  %% =========================
  %% External Services
  %% =========================
  subgraph "External Services"
    OAuth["OAuth Provider (Google, etc.)"]:::external
    Cloudinary["Cloudinary (Media CDN/Storage)"]:::external
    SMTP["SMTP/Email Provider"]:::external
  end

  %% =========================
  %% Protocol-level Connections
  %% =========================
  Browser -->|"HTTPS/REST (JWT)"| FEApi
  FEApi -->|"HTTPS/REST"| BEIndex

  Browser -->|"WS (JWT in handshake)"| FEWS
  FEWS -->|"WS"| BEWSCore

  %% OAuth
  Browser -->|"OAuth_redirect/popup"| OAuth
  OAuth -->|"token_verification"| BEUser

  %% Media
  BEMedia -->|"upload_api"| Cloudinary
  Browser -->|"loads_images"| Cloudinary

  %% Email
  BEEmail -.->|"SMTP_send"| SMTP

  %% Notifications (optional push)
  BENotif -.->|"WS_push (planned)"| BEWSCore

  %% =========================
  %% Click Events (paths only)
  %% =========================
  click FEEntry "https://github.com/bhavesh10joshi/livelink/blob/master/frontend/src/main.tsx"
  click FEApp "https://github.com/bhavesh10joshi/livelink/blob/master/frontend/src/App.tsx"
  click FEAuth "https://github.com/bhavesh10joshi/livelink/blob/master/frontend/src/Pages/SignInPage.tsx"
  click FEChat "https://github.com/bhavesh10joshi/livelink/blob/master/frontend/src/Components/ChattingDashboards/UserToUserChatDashboard.tsx"
  click FEGroups "https://github.com/bhavesh10joshi/livelink/blob/master/frontend/src/Pages/CreateNewGroup.tsx"
  click FEFriends "https://github.com/bhavesh10joshi/livelink/blob/master/frontend/src/Pages/SearchUserPage.tsx"
  click FENotifyUI "https://github.com/bhavesh10joshi/livelink/blob/master/frontend/src/Components/NotificationsDashboard/Notificationdashboard.tsx"
  click FEProfile "https://github.com/bhavesh10joshi/livelink/blob/master/frontend/src/Pages/UserSettings.tsx"
  click FEApi "https://github.com/bhavesh10joshi/livelink/blob/master/frontend/src/Config/ApiConfig.tsx"
  click FEZod "https://github.com/bhavesh10joshi/livelink/blob/master/frontend/src/ZodVaalidations/Zod.tsx"

  click BEIndex "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/index.ts"
  click BEDB "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/db/index.ts"
  click BEMW "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/Middleware/Index.ts"
  click BEVal "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/ZodValidations/index.ts"

  click BEUser "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/Router/User/User.ts"
  click BEGroup "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/Router/Group/Group.ts"
  click BEMsgU2U "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/Router/Messaging/UsertoUser/PersonalCommunication.ts"
  click BEMsgU2G "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/Router/Messaging/UserToGroup/GroupCommunication.ts"
  click BENotif "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/Router/Notifications/PersonalNotifications/PersonalNotification.ts"
  click BEInvites "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/Router/SendInvites/FromUserForUser/ForGroup.ts"

  click BEOTP "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/otp/otp.ts"
  click BEEmail "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/Nodemailer/emailvianode.ts"
  click BEMedia "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/CloudinaryConfig/Cloudinary.ts"

  click BEFriendGuard "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/CheckForAFriend/CheckForaFriend.ts"
  click BEGroupGuard "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/CheckforaGroupMember/CheckGroupMember.ts"

  click BEUUID "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/uuid/index.ts"
  click BEDT "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/CurrentDateandTime/DateAndTime.ts"
  click BEStatus "https://github.com/bhavesh10joshi/livelink/blob/master/Backend/src/StatusCodes.ts"

  %% =========================
  %% Styles
  %% =========================
  classDef actor fill:#111827,stroke:#0b1220,color:#ffffff,stroke-width:2px
  classDef client fill:#1f2937,stroke:#111827,color:#ffffff,stroke-width:2px
  classDef frontend fill:#dbeafe,stroke:#2563eb,color:#0b1220,stroke-width:2px
  classDef backend fill:#dcfce7,stroke:#16a34a,color:#052e16,stroke-width:2px
  classDef api fill:#bbf7d0,stroke:#15803d,color:#052e16,stroke-width:2px
  classDef ws fill:#a7f3d0,stroke:#047857,color:#052e16,stroke-width:2px
  classDef guard fill:#fef9c3,stroke:#ca8a04,color:#422006,stroke-width:2px
  classDef service fill:#e9d5ff,stroke:#7c3aed,color:#2e1065,stroke-width:2px
  classDef db fill:#fff7ed,stroke:#ea580c,color:#431407,stroke-width:2px
  classDef external fill:#e5e7eb,stroke:#4b5563,color:#111827,stroke-width:2px
```
