# lounguyen68/socially-app architecture

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

- Interactive diagram: https://gitdiagram.com/lounguyen68/socially-app
- Repository: https://github.com/lounguyen68/socially-app

## Overview

##### Main Components

- Mobile Application Framework:
- Overall app as a React Native mobile application.
- Native Android layer (contained in the “android” folder) that wraps the React Native code and handles native functionalities.

- User Interface Layer:
- Entry point file (App.tsx) that bootstraps the React Native app.
- UI components (found in the src/components directory) that include reusable building blocks (e.g., Avatar, Button, Header, etc.).
- Screen components (under src/screens such as login.screen.tsx, home.screen.tsx, conversation-detail.screen.tsx, etc.) that represent the distinct views of the application.
- Navigation modules (stored in src/navigation) that organize the app’s routing (e.g., auth.navigition.tsx, home.navigation.tsx, etc.).

- State Management and Context:
- Redux store and slices (found in src/redux, including chatRoomSlice.ts, conversationsSlice.ts, userSlice.ts) which manage global state.
- React Contexts (in src/context) such as Notification, Popup, Services, and Socket, managing side effects and global services.

- Business and API Integration Layer:
- API layer with endpoints (src/api) for actions like login, registration, creating conversations/messages, and refreshing tokens.
- Services layer (under src/services) that includes HTTP, chat, notification, storage, and upload services to encapsulate business logic and API communication.
- Helpers and constants (in src/helpers and src/constants) that assist with utility functions and configuration data.

##### Relationships and Data Flow

- User signaling via UI components (screens and components) triggers navigation events and Redux actions.
- Navigation components direct users through authentication, conversation, and profile flows.
- Redux and Context providers manage global state and side effects (such as real-time updates via sockets).
- API service calls (located in src/api and wrapped by services in src/services) facilitate data exchange with backend systems.
- The native integration on Android bridges the React Native app and native platform features (as seen in the android folder).

##### Architectural Patterns and Design Principles

- Modularization: The project is split into clear domains (UI, navigation, API, services, state management, etc.).
- Separation of Concerns: Each folder (components, screens, services, etc.) handles a specific responsibility.
- Unidirectional Data Flow: Data flows from UI components triggering actions, managed by Redux, and results from API calls update state that is reflected in the UI.
- Integration of Native and JavaScript Layers: The Android folder exists for handling native build configurations and platform-specific integrations.

##### Relevant Technologies and Frameworks

- React Native framework driving the mobile application.
- TypeScript for type checking (as indicated by .tsx and .ts files) and improved developer experience.
- Redux for state management.
- React Navigation for screen routing.
- Various API libraries (likely Axios or Fetch, wrapped within the services) for networking.
- Integration with native Android (with Gradle build files and Kotlin source files).

- From the UI to the navigation layer and state management.
- From Redux/contexts to API services.
- Between API services and external backend systems.
- A different style for business logic (Redux, Context, Services).
- Connectors or notes highlighting key patterns (separation of concerns, modularization, unidirectional data flow).

- The native Android container integrating React Native.
- The React Native front-end divided into components, screens, and navigation.
- State management via Redux and context providers.
- API and services layers handling communications with external systems.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Application Framework
    subgraph "Mobile Application Framework"
        RN["App.tsx"]:::app
        NA["Native Android Layer"]:::native
    end

    %% User Interface Layer
    subgraph "User Interface Layer"
        UI["UI Components"]:::ui
        SC["Screen Components"]:::ui
        NM["Navigation Modules"]:::ui
    end

    %% State Management & Context
    subgraph "State Management & Context"
        RS["Redux Store & Slices"]:::state
        CT["React Contexts"]:::state
    end

    %% Business & API Integration Layer
    subgraph "Business & API Integration Layer"
        API["API Integration"]:::api
        SV["Services Layer"]:::api
        HP["Helpers"]:::api
        CC["Constants"]:::api
    end

    %% Connections between Mobile Application Framework and UI Layer
    RN -->|"bootstraps"| UI
    RN -->|"bootstraps"| SC
    NA -->|"integrates_with"| RN

    %% Connections within UI Layer
    UI -->|"renders"| SC
    UI -->|"init-nav"| NM

    %% Connections from UI Layer to State Management & Context
    SC -->|"triggers_actions"| RS
    NM -->|"routes_actions"| RS
    RN -->|"provides_context"| CT
    CT -->|"handles_side-effects"| RS
    RS -->|"updates_UI"| SC

    %% Connections from State Management to Business & API Integration Layer
    RS -->|"calls_API"| API
    API -->|"invokes_services"| SV
    SV -->|"uses_helpers"| HP
    SV -->|"uses_constants"| CC

    %% Click Events
    click RN "https://github.com/lounguyen68/socially-app/blob/develop/App.tsx"
    click NA "https://github.com/lounguyen68/socially-app/tree/develop/android/"
    click UI "https://github.com/lounguyen68/socially-app/tree/develop/src/components/"
    click SC "https://github.com/lounguyen68/socially-app/tree/develop/src/screens/"
    click NM "https://github.com/lounguyen68/socially-app/tree/develop/src/navigation/"
    click RS "https://github.com/lounguyen68/socially-app/tree/develop/src/redux/"
    click CT "https://github.com/lounguyen68/socially-app/tree/develop/src/context/"
    click API "https://github.com/lounguyen68/socially-app/tree/develop/src/api/"
    click SV "https://github.com/lounguyen68/socially-app/tree/develop/src/services/"
    click HP "https://github.com/lounguyen68/socially-app/tree/develop/src/helpers/"
    click CC "https://github.com/lounguyen68/socially-app/tree/develop/src/constants/"

    %% Styles
    classDef app fill:#CDEBFF,stroke:#000,stroke-width:2px;
    classDef native fill:#E8F5E9,stroke:#000,stroke-width:2px;
    classDef ui fill:#FFF3E0,stroke:#000,stroke-width:2px;
    classDef state fill:#E3F2FD,stroke:#000,stroke-width:2px;
    classDef api fill:#F3E5F5,stroke:#000,stroke-width:2px;
```
