# wilderif/meetify-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/wilderif/meetify-frontend
- Repository: https://github.com/wilderif/meetify-frontend

## Overview

##### Project’s Major Components
- State Management & Hooks:
- The “store” directory (using Zustand) and custom hooks (in src/hooks) manage state for authentication, chat data, loading indicators, etc.
- API and Services: The “services” directory encapsulates API calls to the backend (e.g., postDetail, userProfile) and forms the data access layer.
- Routing and Layout: The “pages” directory along with “layout” components and “routes.tsx” define how the different parts of the application are connected (i.e., pages, modal overlays for login/register, etc.).
- Real-Time Communication:
- Socket.io client integration for real-time chat functionalities.
- This shows up in both component features (Chat components) and hooks that manage socket events.
- Build and Configuration: Included are configuration files (vite.config.ts, Storybook configuration, ESLint, and TypeScript config files) that show how development and production builds are handled.

##### Relationships and Data Flows
- User Interaction Flow: A user interacts with pages (e.g., login modal, post creation form, chat rooms). These pages are assembled using a hierarchy of common and feature-specific components.

##### Architectural Patterns and Design Principles
- Modular and Component-Based Architecture: With well-defined directories for “components”, “features”, “layout”, and “services”, the project follows a separation of concerns that makes individual pieces reusable and easily tested.
- State Management via Global Store: With Zustand, global states such as authentication and chat status are maintained, improving component decoupling.
- Real-Time Data Communication: The use of Socket.io-client in conjunction with custom hooks supports event-driven real-time updates for chat functionality.
- Clear Separation between UI and Business Logic: API interactions are kept in the “services” layer so that UI components only invoke these methods, adhering to clean separation principles.

##### Relevant Technologies, Frameworks, and Libraries to Highlight
- React and TypeScript: Core technologies for building the UI and ensuring type safety.
- Styled-components: For styling individual components.
- Zustand: For state management.
- React Router: To manage navigation between pages.
- Socket.io-client: For enabling real-time chat interactions.
- Storybook: For developing and testing UI components in isolation.
- Vite: For bundling and fast development builds.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Application
    subgraph "Frontend Application"
        %% Pages & Routes subgraph
        subgraph "Pages & Routes"
            PR_Pages["Pages"]:::presentation
            PR_Routes["Routes"]:::presentation
        end
        
        LayoutComponents["Layout Components"]:::presentation
        UI_Library["UI Library (Common Components)"]:::presentation
        
        %% Feature-specific Components
        subgraph "Feature Components"
            Login["Login"]:::presentation
            Chat["Chat Components"]:::presentation
            PostDetail["Post Detail"]:::presentation
            PostCreate["Post Create Page"]:::presentation
            PostPage["Post Page"]:::presentation
            PostUpdate["Post Update Page"]:::presentation
            MyInfo["MyInfoPage"]:::presentation
            ProfileDropdown["ProfileDropdown"]:::presentation
            Register["Register"]:::presentation
        end
        
        %% State Management & Hooks
        subgraph "State Management"
            GlobalStores["Global Stores (Zustand)"]:::state
            CustomHooks["Custom Hooks"]:::state
            SocketHook["Socket Hook (Chat)"]:::state
        end
        
        %% API & Services Layer
        subgraph "API & Services"
            PostDetailService["Post Detail Service"]:::services
            UserProfileService["User Profile Service"]:::services
        end
        
        BuildConfig["Build & Config"]:::config
    end

    %% External Backend
    ExternalBackend["Backend API & Database"]:::external

    %% Data Flow Arrows
    PR_Pages --> GlobalStores
    PR_Routes --> GlobalStores
    Login --> CustomHooks
    Chat --> CustomHooks
    PostDetail --> CustomHooks
    PostCreate --> CustomHooks
    PostPage --> CustomHooks
    PostUpdate --> CustomHooks
    MyInfo --> CustomHooks
    ProfileDropdown --> CustomHooks
    Register --> CustomHooks

    CustomHooks --> GlobalStores
    CustomHooks --> PostDetailService
    CustomHooks --> UserProfileService

    PostDetailService -->|"REST_API"| ExternalBackend
    UserProfileService -->|"REST_API"| ExternalBackend

    Chat --> SocketHook
    SocketHook -->|"Socket.io"| ExternalBackend

    BuildConfig -.-> PR_Pages

    %% Click Events
    click PR_Pages "https://github.com/wilderif/meetify-frontend/tree/main/src/pages"
    click PR_Routes "https://github.com/wilderif/meetify-frontend/blob/main/src/routes.tsx"
    click LayoutComponents "https://github.com/wilderif/meetify-frontend/tree/main/src/components/layout"
    click UI_Library "https://github.com/wilderif/meetify-frontend/tree/main/src/components/common"
    click Login "https://github.com/wilderif/meetify-frontend/tree/main/src/components/features/login"
    click Chat "https://github.com/wilderif/meetify-frontend/tree/main/src/components/features/Chat"
    click PostDetail "https://github.com/wilderif/meetify-frontend/tree/main/src/components/layout/PostDetail"
    click PostCreate "https://github.com/wilderif/meetify-frontend/tree/main/src/pages/PostCreatePage"
    click PostPage "https://github.com/wilderif/meetify-frontend/tree/main/src/pages/PostPage"
    click PostUpdate "https://github.com/wilderif/meetify-frontend/tree/main/src/pages/PostUpdatePage"
    click MyInfo "https://github.com/wilderif/meetify-frontend/tree/main/src/pages/MyInfoPage"
    click ProfileDropdown "https://github.com/wilderif/meetify-frontend/tree/main/src/components/features/profileDropdown"
    click Register "https://github.com/wilderif/meetify-frontend/tree/main/src/components/features/register"
    click GlobalStores "https://github.com/wilderif/meetify-frontend/tree/main/src/store"
    click CustomHooks "https://github.com/wilderif/meetify-frontend/tree/main/src/hooks"
    click SocketHook "https://github.com/wilderif/meetify-frontend/blob/main/src/hooks/Chat/useSocket.ts"
    click PostDetailService "https://github.com/wilderif/meetify-frontend/tree/main/src/services/postDetail"
    click UserProfileService "https://github.com/wilderif/meetify-frontend/tree/main/src/services/userProfile"
    click BuildConfig "https://github.com/wilderif/meetify-frontend/blob/main/vite.config.ts"

    %% Styles
    classDef presentation fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef state fill:#aed6f1,stroke:#333,stroke-width:2px;
    classDef services fill:#d2b4de,stroke:#333,stroke-width:2px;
    classDef external fill:#abebc6,stroke:#333,stroke-width:2px;
    classDef config fill:#f5b7b1,stroke:#333,stroke-width:2px;
```
