# easylearningbd/messenger-chat-app-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/easylearningbd/messenger-chat-app-frontend
- Repository: https://github.com/easylearningbd/messenger-chat-app-frontend

## Overview

##### Project type and purpose
- This is a single-page application (SPA) bootstrapped with Create React App.
- Purpose: a real-time chat interface (messaging UI), with user authentication and message sending/receiving, styled via SCSS, using Redux for state management.

##### File structure
- Top-level folders:
- public/ (static HTML, manifest, robots, images)
- src/
– components/ (React UI components: Login, Register, Messenger, Message, etc.)
– store/ (Redux store configuration, actions, reducers, types)
– sass/ (SCSS partials: base/reset, components, layout, utils)
– audio/ (notification sounds)
– App.js, index.js (entry points), routing and root component
- No backend code here—assume one or more external services for auth and messaging.

##### Extract insights from the README
- Standard CRA scripts; no built-in server logic.
- Production build outputs static assets for deployment (e.g., hosted on CDN or static-site host).

a. Main components
- Browser / Client
- Static asset server or CDN (serving index.html + JS/CSS bundle + audio/images)
- React Application
– Entry (public/index.html → src/index.js → App)
– UI Components (components folder)
– Routing Layer (React Router, ProtectRoute)
– Styling Layer (SCSS modules compiled into CSS)
- State Management
– Redux Store (store/index.js)
– Actions & Reducers (authAction, messengerAction, authReducer, messengerReducer)
- Service / API Layer
– HTTP or WebSocket client modules (not explicitly present, but implied by actions)
- External Services
– Authentication Service (login/register API)
– Messaging Service (send/receive messages API)
b. Relationships & interactions
1. User → Browser → Loads index.html & bundles
2. index.js bootstraps React and Redux Provider
3. Components → dispatch actions → API client → External Services
4. External Services → responses/events → Actions → Reducers → Store update → Components re-render
5. SCSS compile step during build, static assets served by CDN
c. Architectural patterns & principles
– Component-based UI (React)
– Unidirectional data flow (Flux/Redux)
– Separation of concerns: UI vs. state vs. services vs. assets
– Route protection (ProtectRoute component for guarded routes)
d. Key technologies
– React, React Router
– Redux (actions, reducers, types)
– Sass/SCSS for styling
– Create React App (Webpack, Babel under the hood)
– Audio assets for notifications

##### Details to capture
- Entry point: public/index.html → src/index.js
- App component hosts Routes: /login, /register, /messenger
- ProtectRoute wrapper ensuring authenticated access
- Messenger component splits into Friends list (ActiveFriend, FriendInfo), message stream (Message), and input (MessageSend)
- Redux store configured in src/store/index.js, with two slices: auth and messenger
- Audio assets invoked by Messenger for notifications

- How the CRA build pipeline produces the static SPA assets
- How React components and Redux work together
- How the client interacts with external auth and messaging services
- The styling and asset delivery pipelines

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Static Hosting Layer
    subgraph "Static Hosting Layer"
        direction TB
        StaticIndex["public/index.html"]:::asset
        StaticManifest["public/manifest.json"]:::asset
        StaticRobots["public/robots.txt"]:::asset
        StaticImages["public/image/"]:::asset
    end

    Browser["User Browser"]:::external
    StaticCDN["CDN / Static Server"]:::asset

    %% React Application Layer
    subgraph "React Application Layer"
        direction TB
        IndexJS["src/index.js"]:::frontend
        AppJS["src/App.js"]:::frontend
        AppCSS["src/App.css"]:::styling
        MainSCSS["src/main.scss"]:::styling
        ProtectRoute["ProtectRoute"]:::frontend
    end

    %% UI Components
    subgraph "UI Components (src/components)" 
        direction TB
        Login["Login.jsx"]:::frontend
        Register["Register.jsx"]:::frontend
        Messenger["Messenger.jsx"]:::frontend
        Friends["Friends.jsx"]:::frontend
        ActiveFriend["ActiveFriend.jsx"]:::frontend
        FriendInfo["FriendInfo.jsx"]:::frontend
        RightSide["RightSide.jsx"]:::frontend
        MessageComp["Message.jsx"]:::frontend
        MessageSend["MessageSend.jsx"]:::frontend
    end

    %% State Management Layer
    subgraph "State Management Layer"
        direction TB
        Store["src/store/index.js"]:::state
        AuthAction["authAction.js"]:::state
        MessengerAction["messengerAction.js"]:::state
        AuthReducer["authReducer.js"]:::state
        MessengerReducer["messengerReducer.js"]:::state
        AuthTypes["authType.js"]:::state
        MessengerTypes["messengerType.js"]:::state
    end

    %% Styling Layer
    subgraph "Styling Layer (SCSS)"
        direction TB
        Reset["_reset.scss"]:::styling
        ActiveFriendSCSS["_activeFriend.scss"]:::styling
        FriendInfoSCSS["_friendInfo.scss"]:::styling
        FriendsSCSS["_friends.scss"]:::styling
        MessageSCSS["_message.scss"]:::styling
        MessageSendSCSS["_messageSend.scss"]:::styling
        MessengerSCSS["_messenger.scss"]:::styling
        RegisterSCSS["_register.scss"]:::styling
        RightSideSCSS["_rightSide.scss"]:::styling
        GridSCSS["_grid.scss"]:::styling
        UtilsSCSS["_utils.scss"]:::styling
    end

    %% Audio Layer
    subgraph "Audio Assets"
        direction TB
        NotifAudio["notification.mp3"]:::audio
        SendingAudio["sending.mp3"]:::audio
    end

    %% Service/API Layer
    subgraph "Service/API Layer"
        direction TB
        APIClient["HTTP/WebSocket Client"]:::service
    end

    %% External Services
    subgraph "External Services"
        direction TB
        AuthService["Authentication Service"]:::external
        MsgService["Messaging Service"]:::external
    end

    %% Build Step
    Build["npm run build"]:::process

    %% Connections
    StaticIndex -->|served by| StaticCDN
    StaticManifest -->|served by| StaticCDN
    StaticRobots -->|served by| StaticCDN
    StaticImages -->|served by| StaticCDN
    Browser -->|loads| StaticIndex
    Browser -->|loads| AppJS
    Browser -->|loads| AppCSS

    StaticCDN -->|delivers| Browser

    Browser -->|bootstraps| IndexJS
    IndexJS -->|renders| AppJS
    AppJS --> ProtectRoute
    ProtectRoute -->|routes to| Login
    ProtectRoute -->|routes to| Register
    ProtectRoute -->|routes to| Messenger

    Messenger --> Friends
    Messenger --> ActiveFriend
    Messenger --> FriendInfo
    Messenger --> RightSide
    Messenger --> MessageComp
    Messenger --> MessageSend

    %% State flow
    Login -->|dispatch| AuthAction
    Register -->|dispatch| AuthAction
    Messenger -->|dispatch| MessengerAction
    MessageSend -->|dispatch| MessengerAction

    AuthAction --> AuthReducer
    MessengerAction --> MessengerReducer
    AuthReducer --> Store
    MessengerReducer --> Store
    Store -->|provides state| AppJS
    Store -->|provides state| Messenger

    %% API calls
    AuthAction -->|calls| APIClient
    MessengerAction -->|calls| APIClient
    APIClient -->|requests| AuthService
    APIClient -->|requests| MsgService
    AuthService -->|response| APIClient
    MsgService -->|push events| APIClient
    APIClient -->|updates| AuthAction
    APIClient -->|updates| MessengerAction

    %% Styling & Audio
    AppJS --> Reset
    AppJS --> ActiveFriendSCSS
    AppJS --> FriendInfoSCSS
    AppJS --> FriendsSCSS
    AppJS --> MessageSCSS
    AppJS --> MessageSendSCSS
    AppJS --> MessengerSCSS
    AppJS --> RegisterSCSS
    AppJS --> RightSideSCSS
    AppJS --> GridSCSS
    AppJS --> UtilsSCSS

    Messenger --> NotifAudio
    Messenger --> SendingAudio

    %% Build to CDN
    Build -->|outputs| StaticCDN

    %% Click Events
    click StaticIndex "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/public/index.html"
    click StaticManifest "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/public/manifest.json"
    click StaticRobots "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/public/robots.txt"
    click StaticImages "https://github.com/easylearningbd/messenger-chat-app-frontend/tree/master/public/image/"
    click IndexJS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/index.js"
    click AppJS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/App.js"
    click AppCSS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/App.css"
    click MainSCSS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/main.scss"
    click ProtectRoute "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/components/ProtectRoute.jsx"
    click Login "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/components/Login.jsx"
    click Register "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/components/Register.jsx"
    click Messenger "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/components/Messenger.jsx"
    click Friends "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/components/Friends.jsx"
    click ActiveFriend "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/components/ActiveFriend.jsx"
    click FriendInfo "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/components/FriendInfo.jsx"
    click RightSide "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/components/RightSide.jsx"
    click MessageComp "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/components/Message.jsx"
    click MessageSend "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/components/MessageSend.jsx"
    click Store "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/store/index.js"
    click AuthAction "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/store/actions/authAction.js"
    click MessengerAction "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/store/actions/messengerAction.js"
    click AuthReducer "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/store/reducers/authReducer.js"
    click MessengerReducer "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/store/reducers/messengerReducer.js"
    click AuthTypes "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/store/types/authType.js"
    click MessengerTypes "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/store/types/messengerType.js"
    click Reset "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/sass/base/_reset.scss"
    click ActiveFriendSCSS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/sass/components/_activeFriend.scss"
    click FriendInfoSCSS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/sass/components/_friendInfo.scss"
    click FriendsSCSS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/sass/components/_friends.scss"
    click MessageSCSS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/sass/components/_message.scss"
    click MessageSendSCSS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/sass/components/_messageSend.scss"
    click MessengerSCSS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/sass/components/_messenger.scss"
    click RegisterSCSS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/sass/components/_register.scss"
    click RightSideSCSS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/sass/components/_rightSide.scss"
    click GridSCSS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/sass/layout/_grid.scss"
    click UtilsSCSS "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/sass/utils/_utils.scss"
    click NotifAudio "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/audio/notification.mp3"
    click SendingAudio "https://github.com/easylearningbd/messenger-chat-app-frontend/blob/master/src/audio/sending.mp3"

    %% Styles
    classDef external fill:#CCCCCC,stroke:#333,stroke-width:1px
    classDef asset fill:#FFF2CC,stroke:#333,stroke-width:1px
    classDef frontend fill:#CCE5FF,stroke:#333,stroke-width:1px
    classDef state fill:#FFD699,stroke:#333,stroke-width:1px
    classDef service fill:#D5E8D4,stroke:#333,stroke-width:1px
    classDef styling fill:#E1D5E7,stroke:#333,stroke-width:1px
    classDef audio fill:#F8CECC,stroke:#333,stroke-width:1px
    classDef process fill:#F5F5F5,stroke:#333,stroke-width:1px
```
