# shashank0092/jchat-front-end architecture

> Architecture diagram of the GitHub repository shashank0092/jchat-front-end, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shashank0092/jchat-front-end
- Repository: https://github.com/shashank0092/jchat-front-end

## Overview

##### Main Components
- Entry Point & Bootstrapping: Show the starting point where index.html and main.tsx initialize the React app.
- Providers & Contexts: Include components like the AuthZeroProvider (src/Providers/AuthZeroProvider.tsx) for authentication, and SocketContext (src/context/SocketContext.tsx) managing real-time websocket communications.
- API Layer: Represent the api folder (src/api/index.ts), which abstracts backend API interactions.
- UI & Components: Illustrate the diverse range of UI components. Separate directories such as Base components, Forms (LoginForm, RegisterForm, AddChat component), Google Login, Typing animation, UI elements (Navbar, Contacts, etc.), Image Upload, and Voice Recorder become key building blocks.
- Pages & Routing: In the src/pages directory you have specific pages for Chat, Login, Register, ForgetPassword, VideoCall, and VoiceCall. Include the RoutesComponent (with PrivateRoute and PublicRoute) that govern navigation and access control.
- Utility Functions & Interfaces: The utills folder (utilities like ImageAuthenticator, MediaTypes, and SocketEvents) and interface definitions that help standardize data among components.

##### Architectural Patterns & Design Principles
- Separation of Concerns: The directory structure hints at a clean separation between presentation (components and pages), business logic (API and utilities), and state management (contexts/providers).

##### Relevant Technologies & Frameworks
- React, TypeScript, and Vite form the core tech stack for the front-end.
- ESLint and Prettier (hinted by .eslintrc.cjs and package configuration) ensure code quality.
- Integration with Auth0 (as suggested by AuthZeroProvider) and possible socket libraries for real-time functionalities.
- Tailwind CSS (configured via tailwind.config.js) is likely used for styling.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Entry Point & Bootstrapping
    subgraph "Entry Point & Bootstrapping"
        EP1["index.html"]:::entry
        EP2["main.tsx"]:::entry
    end

    %% Providers & Contexts
    subgraph "Providers & Contexts"
        P1["AuthZeroProvider"]:::provider
        P2["AuthContext"]:::provider
        P3["SocketContext"]:::provider
    end

    %% API Layer
    subgraph "API Layer"
        API["APIService"]:::api
    end

    %% UI Components
    subgraph "UI Components"
        subgraph "Base Components"
            U1["Modal"]:::ui
        end
        subgraph "Forms Components"
            U2["LoginForm"]:::ui
            U3["RegisterForm"]:::ui
            U4["AddChatComponent"]:::ui
            U5["UserDetails"]:::ui
        end
        subgraph "Google Login"
            U6["LoginGoogle"]:::ui
            U7["LogoutGoogle"]:::ui
        end
        subgraph "Typing Animation"
            U8["Typing"]:::ui
        end
        subgraph "UI Elements"
            U9["ContactNavbar"]:::ui
            U10["Contacts"]:::ui
            U11["SearchContact"]:::ui
        end
        subgraph "Image Upload"
            U12["ImageUpload"]:::ui
        end
        subgraph "Voice Recorder"
            U13["VoiceRecorder"]:::ui
        end
    end

    %% Pages & Routing
    subgraph "Pages & Routing"
        Pgs1["ChatPage"]:::page
        Pgs2["ForgetPassword"]:::page
        Pgs3["LoginPage"]:::page
        Pgs4["RegisterPage"]:::page
        Pgs5["VideoCall"]:::page
        Pgs6["VoiceCall"]:::page
        Pgs7["PrivateRoute"]:::page
        Pgs8["PublicRoute"]:::page
    end

    %% Utilities & Interfaces
    subgraph "Utilities & Interfaces"
        Uti1["ImageAuthenticator"]:::util
        Uti2["ImageKeyParse"]:::util
        Uti3["MediaTypes"]:::util
        Uti4["SocketEvents"]:::util
        Uti5["Utilities (index)"]:::util
        Uti6["API Interfaces"]:::util
        Uti7["Chat Interfaces"]:::util
        Uti8["User Interfaces"]:::util
    end

    %% Hooks
    subgraph "Hooks"
        H1["SpeechToText"]:::hook
    end

    %% Relationships

    %% Bootstrapping initializes Providers & Contexts
    EP2 -->|"bootstraps"| P1
    EP2 -->|"bootstraps"| P2
    EP2 -->|"bootstraps"| P3

    %% Providers feed data into Pages
    P1 -->|"provides auth"| Pgs1
    P1 -->|"provides auth"| Pgs3
    P1 -->|"provides auth"| Pgs4
    P2 -->|"manages state"| Pgs1
    P3 -->|"real-time updates"| Pgs1
    P3 -->|"real-time updates"| Pgs5
    P3 -->|"real-time updates"| Pgs6

    %% Pages communicate with API Layer and UI Components
    Pgs1 -->|"triggers API call"| API
    Pgs3 -->|"triggers API call"| API
    Pgs4 -->|"triggers API call"| API

    %% UI Components interact with API and are used within Pages
    U2 -->|"form submission"| API
    U3 -->|"form submission"| API
    U4 -->|"new chat action"| API
    U5 -->|"user details update"| API
    U12 -->|"uploads image"| API
    U8 -->|"animation trigger"| Pgs1

    %% Pages integrate UI Components
    Pgs1 -->|"renders"| U1
    Pgs1 -->|"renders"| U10
    Pgs1 -->|"renders"| U11
    Pgs1 -->|"renders"| U12
    Pgs1 -->|"renders"| U8

    %% Routing layer directs access to pages
    Pgs7 -->|"guards access"| Pgs1
    Pgs8 -->|"allows public access"| Pgs3
    Pgs8 -->|"allows public access"| Pgs4

    %% Google Login integration
    U6 -->|"triggers login"| Pgs3
    U7 -->|"triggers logout"| P1

    %% Additional UI Elements in pages
    Pgs1 -->|"includes"| U9

    %% Voice functionalities
    U13 -->|"used in"| Pgs6
    H1 -->|"enhances"| Pgs6

    %% Utilities used by API and Providers
    API -->|"utilizes"| Uti6
    API -->|"utilizes"| Uti7
    API -->|"utilizes"| Uti8
    API -->|"utilizes"| Uti1
    API -->|"utilizes"| Uti2
    API -->|"utilizes"| Uti3
    API -->|"utilizes"| Uti4
    API -->|"utilizes"| Uti5

    %% Click Events
    click EP1 "https://github.com/shashank0092/jchat-front-end/blob/master/index.html"
    click EP2 "https://github.com/shashank0092/jchat-front-end/blob/master/src/main.tsx"
    click P1 "https://github.com/shashank0092/jchat-front-end/blob/master/src/Providers/AuthZeroProvider.tsx"
    click P2 "https://github.com/shashank0092/jchat-front-end/blob/master/src/context/AuthContext.tsx"
    click P3 "https://github.com/shashank0092/jchat-front-end/blob/master/src/context/SocketContext.tsx"
    click API "https://github.com/shashank0092/jchat-front-end/blob/master/src/api/index.ts"
    click U1 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/Base/Modal.tsx"
    click U2 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/Forms/LoginForm.tsx"
    click U3 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/Forms/RegisterForm.tsx"
    click U4 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/Forms/AddChatComponet/AddChat.tsx"
    click U5 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/Forms/AddChatComponet/UserDetails.tsx"
    click U6 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/GoogleLogin/LoginGoogle.tsx"
    click U7 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/GoogleLogin/LogoutGoogle.tsx"
    click U8 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/Typing/Typing.tsx"
    click U9 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/UI/ContactNavbar.tsx"
    click U10 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/UI/Contacts.tsx"
    click U11 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/UI/SearchContact.tsx"
    click U12 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/UploadImage/ImageUpload.tsx"
    click U13 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/VoiceRecorder/VoiceRecorder.tsx"
    click Pgs1 "https://github.com/shashank0092/jchat-front-end/blob/master/src/pages/Chat/Chat.tsx"
    click Pgs2 "https://github.com/shashank0092/jchat-front-end/blob/master/src/pages/ForgetPassword/ForgetPassword.tsx"
    click Pgs3 "https://github.com/shashank0092/jchat-front-end/blob/master/src/pages/Login/Login.tsx"
    click Pgs4 "https://github.com/shashank0092/jchat-front-end/blob/master/src/pages/Register/Register.tsx"
    click Pgs5 "https://github.com/shashank0092/jchat-front-end/blob/master/src/pages/VideoCall/VideoCall.tsx"
    click Pgs6 "https://github.com/shashank0092/jchat-front-end/blob/master/src/pages/VoiceCall/VoiceCall.tsx"
    click Pgs7 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/RoutesComponent/PrivateRoute.tsx"
    click Pgs8 "https://github.com/shashank0092/jchat-front-end/blob/master/src/components/RoutesComponent/PublicRoute.tsx"
    click Uti1 "https://github.com/shashank0092/jchat-front-end/blob/master/src/utills/ImageAuthenticator.ts"
    click Uti2 "https://github.com/shashank0092/jchat-front-end/blob/master/src/utills/ImageKeyParse.ts"
    click Uti3 "https://github.com/shashank0092/jchat-front-end/blob/master/src/utills/MediaTypes.ts"
    click Uti4 "https://github.com/shashank0092/jchat-front-end/blob/master/src/utills/SocketEvents.ts"
    click Uti5 "https://github.com/shashank0092/jchat-front-end/blob/master/src/utills/index.ts"
    click Uti6 "https://github.com/shashank0092/jchat-front-end/blob/master/src/interface/api.ts"
    click Uti7 "https://github.com/shashank0092/jchat-front-end/blob/master/src/interface/chat.ts"
    click Uti8 "https://github.com/shashank0092/jchat-front-end/blob/master/src/interface/user.ts"
    click H1 "https://github.com/shashank0092/jchat-front-end/blob/master/src/hooks/SpeechToText.ts"

    %% Styles
    classDef entry fill:#f9e79f,stroke:#af601a,stroke-width:2px;
    classDef provider fill:#d6eaf8,stroke:#2e86c1,stroke-width:2px;
    classDef api fill:#fadbd8,stroke:#c0392b,stroke-width:2px;
    classDef ui fill:#d5f5e3,stroke:#28b463,stroke-width:2px;
    classDef page fill:#edbb99,stroke:#ca6f1e,stroke-width:2px;
    classDef util fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
    classDef hook fill:#d2b4de,stroke:#8e44ad,stroke-width:2px;
```
