# code4life-labs/dongnai-travel architecture

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

- Interactive diagram: https://gitdiagram.com/code4life-labs/dongnai-travel
- Repository: https://github.com/code4life-labs/dongnai-travel

## Overview

##### Main Components
- UI / Presentation Layer:
– Screens: Organized under the app/screens folder (e.g., HomeScreen, BlogsScreen, MapScreen, ChatBotScreen, etc.)
– Navigators: Under app/navigations, showing navigation groups (auth, home, blogs, chatbot, explore, etc.)
– Components: Reusable UI components (buttons, headers, lists, charts, etc.) in app/components.
– Assets & Animations: Illustrate the media resources (images, animations, fonts) that enrich the UI.

- State Management & Business Logic:
– Redux Store: Representing overall state management with slices (blogs, user, notifications, settings, theme, etc.) in app/redux.
– Custom Hooks and HOCs: Found under app/customHooks and app/hocs, illustrate how UI components tap into business logic.
– Global styles and utilities (in app/globals and app/utilities).

- API Integration Layer:
– REST APIs: Highlight the axios-based modules in app/apis/axios that handle blog CRUD operations, class-related APIs, and others. Clearly denote endpoints such as blog/get, blog/post, and blog/delete.
– Authorized API Instances: Note the use of authorizedAxiosInstance (in app/axios) to manage secure API calls.

- Shared/Reusable Libraries:

- External Services / Back-End Integration:
– External APIs: Represent services such as Google API, Cloudinary, and GPT integrations (for the Travel Bot functionality).
– Databases: Although not directly in the file tree (backend isn’t part of this codebase), note the integration with MongoDB as mentioned in the README.

##### Relationships & Interactions
- UI Components and Screens:
- Navigation Layer:
- Redux & Custom Hooks:
– Illustrate the flow of data from components → custom hooks/Redux actions → API integration, and then the Redux state updates reflecting on the UI.
- API Modules:
– Show connections between the mobile code (axios modules and socket modules) and the external backend services.
- Shared Libraries:
– Place these as utility blocks that connect with various UI components (for example, the “mark-format” library used in blog text formatting).

##### Architectural Patterns & Design Principles
- Component-Based Architecture: With a clear separation between reusable UI components and screen containers.
- Separation of Concerns: Distinct directories for navigators, state (Redux), API integrations, hooks, and utilities.
- Data Flow: Unidirectional data flow through Redux, integrating with asynchronous interactions via axios and real-time socket communications.
- Modularization: The API folder is neatly organized by domain (blog, class, etc.), while the libraries folder highlights separate concerns (formatting, mappings, charting).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Frontend (React Native)
    subgraph "Mobile Frontend (React Native)"
        %% UI / Presentation Layer
        subgraph "UI / Presentation Layer"
            HS["HomeScreen"]:::ui
            BS["BlogsScreen"]:::ui
            MS["MapScreen"]:::ui
            CBS["ChatBotScreen"]:::ui
            AuthNav["AuthNavigator"]:::ui
            BlogsNav["BlogsNavigator"]:::ui
            ChatBotNav["ChatBotNavigator"]:::ui
            ExploreNav["ExploreNavigator"]:::ui
            HomeNav["HomeNavigator"]:::ui
            UIComp["Reusable UI Components"]:::ui
            Assets["Assets"]:::ui
            Anim["Animations"]:::ui
        end

        %% State Management & Business Logic
        subgraph "State Management (Redux)"
            Redux["Redux Store"]:::state
            BlogsSlice["Blogs Slice"]:::state
            UserSlice["User Slice"]:::state
            NotSlice["Notifications Slice"]:::state
            Hooks["Custom Hooks"]:::state
            HOCs["HOCs"]:::state
            GlobalStyles["Global Styles"]:::state
            Utilities["Utilities"]:::state
        end

        %% API Integration Layer
        subgraph "API Integration Layer"
            RestAPI["REST API (axios)"]:::api
            SocketAPI["Socket API"]:::api
            AuthAPI["Authorized API Instance"]:::api
        end

        %% Shared / Reusable Libraries
        subgraph "Shared Libraries"
            MarkFormat["Mark-format"]:::lib
            MapsLib["Maps Library"]:::lib
            WeatherCharts["Weather Charts"]:::lib
        end
    end

    %% External Backend & Services
    subgraph "External Backend & Services"
        NodeAPI["NodeJS/Express"]:::external
        Mongo["MongoDB"]:::external
        Google["Google API"]:::external
        Cloudinary["Cloudinary"]:::external
        GPT["GPT Integration"]:::external
    end

    %% Connections - UI to State Management
    HS -->|"dispatches"| Redux
    BS -->|"dispatches"| Redux
    MS -->|"dispatches"| Redux
    CBS -->|"dispatches"| Redux
    AuthNav -->|"navigates to"| HS
    BlogsNav -->|"navigates to"| BS
    ChatBotNav -->|"navigates to"| CBS
    ExploreNav -->|"navigates to"| MS
    HomeNav -->|"navigates to"| HS

    %% Connections - State Management interacting with API Integration Layer
    Redux -->|"triggers"| RestAPI
    Redux -->|"triggers"| SocketAPI
    Hooks -->|"calls"| RestAPI
    HOCs -->|"enhance"| UIComp

    %% Connections - API Integration Layer to External Services
    RestAPI -->|"fetches data"| NodeAPI
    SocketAPI -->|"real-time events"| NodeAPI
    AuthAPI -->|"secures calls"| RestAPI
    NodeAPI -->|"responds"| RestAPI
    NodeAPI -->|"pushes updates"| SocketAPI

    %% Connections - Shared Libraries integration with UI
    BS -->|"formats content via"| MarkFormat
    MS -->|"renders maps with"| MapsLib
    CBS -->|"displays charts using"| WeatherCharts

    %% Connections - Global Styles and Utilities update UI components
    GlobalStyles --> UIComp
    Utilities --> UIComp

    %% Click Events for UI / Presentation Layer
    click HS "https://github.com/code4life-labs/dongnai-travel/blob/master/app/screens/home/HomeScreen.jsx"
    click BS "https://github.com/code4life-labs/dongnai-travel/blob/master/app/screens/blogs/BlogsScreen.jsx"
    click MS "https://github.com/code4life-labs/dongnai-travel/blob/master/app/screens/map/MapScreen.jsx"
    click CBS "https://github.com/code4life-labs/dongnai-travel/blob/master/app/screens/chat_bot/ChatBotScreen.jsx"
    click AuthNav "https://github.com/code4life-labs/dongnai-travel/blob/master/app/navigations/auth_navigator/AuthNavigator.jsx"
    click BlogsNav "https://github.com/code4life-labs/dongnai-travel/blob/master/app/navigations/blogs_navigator/BlogsNavigator.jsx"
    click ChatBotNav "https://github.com/code4life-labs/dongnai-travel/blob/master/app/navigations/chatbot_navigator/ChatBotNavigator.jsx"
    click ExploreNav "https://github.com/code4life-labs/dongnai-travel/blob/master/app/navigations/explore_navigator/ExploreNavigator.jsx"
    click HomeNav "https://github.com/code4life-labs/dongnai-travel/blob/master/app/navigations/home_navigator/HomeNavigator.jsx"
    click UIComp "https://github.com/code4life-labs/dongnai-travel/tree/master/app/components"
    click Assets "https://github.com/code4life-labs/dongnai-travel/tree/master/app/assets"
    click Anim "https://github.com/code4life-labs/dongnai-travel/blob/master/app/animations/dropDownAnimation.js"

    %% Click Events for State Management & Business Logic
    click BlogsSlice "https://github.com/code4life-labs/dongnai-travel/blob/master/app/redux/blogs/BlogsSlice.js"
    click UserSlice "https://github.com/code4life-labs/dongnai-travel/blob/master/app/redux/user/UserSlice.js"
    click NotSlice "https://github.com/code4life-labs/dongnai-travel/blob/master/app/redux/notifications/NotificationsSlice.js"
    click Hooks "https://github.com/code4life-labs/dongnai-travel/tree/master/app/customHooks"
    click HOCs "https://github.com/code4life-labs/dongnai-travel/tree/master/app/hocs"
    click GlobalStyles "https://github.com/code4life-labs/dongnai-travel/tree/master/app/globals/styles"
    click Utilities "https://github.com/code4life-labs/dongnai-travel/tree/master/app/utilities"

    %% Click Events for API Integration Layer
    click RestAPI "https://github.com/code4life-labs/dongnai-travel/tree/master/app/apis/axios"
    click SocketAPI "https://github.com/code4life-labs/dongnai-travel/blob/master/app/apis/socket/blog/events/createBlog.js"
    click AuthAPI "https://github.com/code4life-labs/dongnai-travel/blob/master/app/axios/authorizedAxiosInstance.js"

    %% Click Events for Shared Libraries
    click MarkFormat "https://github.com/code4life-labs/dongnai-travel/tree/master/app/libs/mark-format"
    click MapsLib "https://github.com/code4life-labs/dongnai-travel/tree/master/app/libs/react-native-maps-line-arrow"
    click WeatherCharts "https://github.com/code4life-labs/dongnai-travel/tree/master/app/libs/react-native-weather-chart"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef state fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef api fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef external fill:#FFC0CB,stroke:#000,stroke-width:2px;
    classDef lib fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
