# madjid123/dexchat architecture

> Architecture diagram of the GitHub repository madjid123/dexchat, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/madjid123/dexchat
- Repository: https://github.com/madjid123/dexchat

## Overview

##### Main Components Identification

a) Frontend Layer:
- User Interface Components (src/components)
- Feature Modules (src/features)
- State Management (Redux - evident from store.ts and slices)
- Authentication System (src/contexts/authentication)
- WebSocket Integration (src/utils/socket.ts)

b) External Services:
- REST API Integration (src/services)
- WebSocket Server (for real-time communication)

**┌─────────────────────────────────────────────────────────┐**
- Client Application                      │
- ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐   │
- Auth   │ │  Chat    │ │ Profile  │ │ Discover │   │
- Module  │ │  Module  │ │  Module  │ │  Module  │   │
- ┘ └──────────┘ └──────────┘ └──────────┘   │

- ┌──────────────────────┐  ┌─────────────────────────┐ │
- Redux Store       │  │    Context Providers     │ │
- ┘  └─────────────────────────┘ │
- ┘

**┌─────────────────────────────────────────────────────────┐**
- ┌──────────┐  ┌──────────┐  ┌──────────────────────┐  │
- Redux   │  │  Socket  │  │     REST Client      │  │
- Store   │──│  Client  │  │  (Axios Instance)   │  │
- ┘  └──────────┘  └──────────────────────┘  │
- ┘

**┌─────────────────────┐  ┌─────────────────────┐**
- WebSocket Server │  │      REST API       │
- ┘  └─────────────────────┘

##### Important Relationships to Highlight

- Bidirectional communication between Socket Client and WebSocket Server
- Redux state flow to components
- Authentication flow through the system
- API call patterns

##### Technical Stack Callouts

- React + TypeScript
- Redux Toolkit
- WebSocket
- Axios
- TailwindCSS
- Vite (build tool)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Application"]
        App["App Component"]:::app
        Layout["Layout Component"]:::ui
        
        subgraph Features["Feature Modules"]
            direction TB
            Chat["Chat Module"]:::feature
            Profile["Profile Module"]:::feature
            Discover["Discover Module"]:::feature
            Rooms["Rooms Module"]:::feature
        end
        
        subgraph State["State Management"]
            direction TB
            Redux["Redux Store"]:::state
            AuthContext["Auth Context"]:::state
            
            subgraph Slices["Redux Slices"]
                direction TB
                MessagesSlice["Messages Slice"]:::state
                RoomsSlice["Rooms Slice"]:::state
                AuthSlice["Auth Slice"]:::state
                ProfileSlice["Profile Slice"]:::state
            end
        end
        
        subgraph Auth["Authentication"]
            direction TB
            Login["Login"]:::auth
            Register["Register"]:::auth
            PrivateRoute["Private Route"]:::auth
        end
        
        subgraph Services["Communication Services"]
            direction TB
            Socket["WebSocket Client"]:::service
            RestClient["REST Client (Axios)"]:::service
        end
        
        subgraph UI["UI Components"]
            direction TB
            Button["Button"]:::ui
            Input["Input"]:::ui
            ConversationUI["Conversation UI"]:::ui
            ProfileUI["Profile UI"]:::ui
            DiscoverUI["Discover UI"]:::ui
            RoomsUI["Rooms UI"]:::ui
        end
    end
    
    subgraph External["External Services"]
        direction TB
        WebSocketServer["WebSocket Server"]:::external
        RestAPI["REST API"]:::external
    end
    
    %% Relationships
    App --> Layout
    Layout --> Features
    Layout --> UI
    
    Chat --> Socket
    Chat --> Redux
    Profile --> Redux
    Discover --> Redux
    Rooms --> Redux
    
    Redux --> Slices
    
    Socket <--> WebSocketServer
    RestClient <--> RestAPI
    
    Auth --> AuthContext
    Features --> Services
    
    %% Click Events
    click App "https://github.com/madjid123/dexchat/blob/main/src/App.tsx"
    click Layout "https://github.com/madjid123/dexchat/blob/main/src/components/Layout/Layout.tsx"
    click Redux "https://github.com/madjid123/dexchat/blob/main/src/app/store.ts"
    click AuthContext "https://github.com/madjid123/dexchat/blob/main/src/contexts/authentication/AuthContext.tsx"
    click MessagesSlice "https://github.com/madjid123/dexchat/blob/main/src/features/Conversation/MessagesSlice.ts"
    click RoomsSlice "https://github.com/madjid123/dexchat/blob/main/src/features/user/RoomsSlice.ts"
    click AuthSlice "https://github.com/madjid123/dexchat/blob/main/src/features/user/authSlice.ts"
    click ProfileSlice "https://github.com/madjid123/dexchat/blob/main/src/features/user/profileSlice.ts"
    click Login "https://github.com/madjid123/dexchat/blob/main/src/pages/Auth/Login/Login.tsx"
    click Register "https://github.com/madjid123/dexchat/blob/main/src/pages/Auth/Register/Register.tsx"
    click PrivateRoute "https://github.com/madjid123/dexchat/blob/main/src/components/PrivateRoute/PrivateRoute.tsx"
    click Socket "https://github.com/madjid123/dexchat/blob/main/src/utils/socket.ts"
    click ConversationUI "https://github.com/madjid123/dexchat/blob/main/src/components/UserSpace/Conversation/Conversation.tsx"
    click ProfileUI "https://github.com/madjid123/dexchat/blob/main/src/components/Profile/Profile.tsx"
    click DiscoverUI "https://github.com/madjid123/dexchat/blob/main/src/components/UserSpace/Discover/Discover.tsx"
    click RoomsUI "https://github.com/madjid123/dexchat/blob/main/src/components/UserSpace/Rooms/Rooms.tsx"
    click RestClient "https://github.com/madjid123/dexchat/blob/main/src/config/axios.ts"
    click Button "https://github.com/madjid123/dexchat/blob/main/src/components/Button/Button.tsx"
    click Input "https://github.com/madjid123/dexchat/blob/main/src/components/Input/Input.tsx"
    
    %% Styles
    classDef app fill:#2563eb,color:white
    classDef feature fill:#3b82f6,color:white
    classDef state fill:#22c55e,color:white
    classDef auth fill:#7c3aed,color:white
    classDef service fill:#f97316,color:white
    classDef ui fill:#64748b,color:white
    classDef external fill:#6366f1,color:white
    
    %% Legend
    subgraph Legend
        direction TB
        L1["Application"]:::app
        L2["Feature Module"]:::feature
        L3["State Management"]:::state
        L4["Authentication"]:::auth
        L5["Services"]:::service
        L6["UI Components"]:::ui
        L7["External Services"]:::external
    end
```
