# nhuxhr/musicont architecture

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

- Interactive diagram: https://gitdiagram.com/nhuxhr/musicont
- Repository: https://github.com/nhuxhr/musicont

## Overview

##### Project Overview & Main Components
- Project Type: A mobile music player application built with React Native & Expo.
- Primary Roles:
- UI Presentation: Screens, Widgets, and Components.
- State Management: Redux store with reducers and states.
- Asset Management: Local image/assets files.
- External Libraries: Expo modules (expo-av, expo-ads-admob, etc.), React Navigation, and third-party components.

##### And Label Architectural Layers
a. Entry Point:
- App.tsx: The bootstrap file that initializes navigation, redux provider, and the overall app.
b. Presentation/UI Layer:
- Screens (src/screens): Contains various user-facing screens (Home, Favourite, Playlist, Playing, Search, Recent, Songs) each entry file representing a mobile view.
- Widgets (src/widgets): Higher-level UI elements like Header, Drawer, Footer, and Modals.
c. Business Logic / Data Layer:
- Store (src/store): Contains the Redux configuration, reducers (app, player, storage), and state definitions.
- Constants (src/constants): Definitions for screen names, dispatch configuration, and other globally used values.
- Helpers & Hooks (src/helpers and src/hooks): Utility functions (millisToMin, storage utilities), and custom hooks (e.g., Audio hook) for handling business logic and side-effects.
d. Asset & Configuration:
- Configuration Files: Babel, tsconfig, app.json – serving as entry points for Expo and build tooling.

##### Relationships and Data Flow
- Navigation: Use React Navigation (configured in screens) as the control flow between different UI screens.
- Data Handling & State Management: Screens and components dispatch actions to the Redux store which then updates the application state, shared across components.
- External Services: Libraries such as expo-av handle audio playback, and expo-ads-admob manages ad displays. These are integrated within specific components and hooks.
- Utility/Core Functions: Helpers and constants mediate data formatting and device-specific configuration (e.g., time conversion in millisToMin).
- UI Composition: Widgets combine various smaller React components to create complex, reusable UI elements like the header or side drawer.

##### Architectural Patterns and Design Principles
- Component-Based Architecture: The project is structured around reusable components and screens.
- Separation of Concerns: Clear division between UI (screens, components, widgets), state management (store/reducers), and utility/helper functions.
- Unidirectional Data Flow: Redux is used to manage global state ensuring predictable state transitions.
- Extensible and Modular: Directory structure with dedicated folders for assets, hooks, helpers, and constants indicates modularity that supports easier future expansion.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Point Layer
    subgraph "Entry Point"
        A("App.tsx"):::entry
    end

    %% Presentation/UI Layer
    subgraph "Presentation/UI Layer"
        subgraph "Screens"
            H("Home Screen"):::screen
            F("Favourite Screen"):::screen
            P("Playlist Screen"):::screen
            PL("Playing Screen"):::screen
            S("Search Screen"):::screen
            R("Recent Screen"):::screen
            So("Songs Screen"):::screen
        end
        subgraph "Components"
            EC("Explore Card"):::component
            MC("MusicList Card"):::component
            PC("Playlist Card"):::component
            RC("Recent Card"):::component
            ICON("Icon Component"):::component
            ADS("Ads Component"):::component
        end
        subgraph "Widgets"
            HDR("Header Widget"):::widget
            DRW("Drawer Widget"):::widget
            FTR("Footer Widget"):::widget
            MOD1("MoreOptions Modal"):::widget
            MOD2("Playlist Modal"):::widget
            SEC("Sections"):::widget
        end
    end

    %% Business Logic / Data Layer
    subgraph "Business Logic / Data Layer"
        RS("Redux Store"):::logic
        CT("Constants"):::logic
        HELPER("Helpers"):::logic
        HOOK("Hooks"):::logic
    end

    %% Assets & Configuration
    subgraph "Assets & Configuration"
        AST("Assets"):::config
        CFG("Configurations"):::config
    end

    %% External Services
    subgraph "External Services"
        EXAV("Expo-av (Audio Playback)"):::external
        EXADM("expo-ads-admob (Ads)"):::external
        RNAV("React Navigation"):::external
    end

    %% Connections from Entry Point
    A -->|"init-nav"| RNAV
    A -->|"loads"| H
    A -->|"loads"| EC
    A -->|"init-redux"| RS
    A -->|"loads assets"| AST

    %% Screens dispatch actions to Redux Store
    H -->|"dispatchAction"| RS
    F -->|"dispatchAction"| RS
    P -->|"dispatchAction"| RS
    PL -->|"dispatchAction"| RS
    S -->|"dispatchAction"| RS
    R -->|"dispatchAction"| RS
    So -->|"dispatchAction"| RS

    %% Widgets composition and usage example
    HDR -->|"uses"| ICON
    DRW -->|"uses"| ICON

    %% External integrations from Business Logic and Components
    HOOK -->|"calls"| EXAV
    ADS -->|"integrates"| EXADM

    %% Click Events
    click A "https://github.com/nhuxhr/musicont/blob/master/App.tsx"
    click H "https://github.com/nhuxhr/musicont/blob/master/src/screens/Home/index.js"
    click F "https://github.com/nhuxhr/musicont/blob/master/src/screens/Favourite/index.js"
    click P "https://github.com/nhuxhr/musicont/blob/master/src/screens/Playlist/index.js"
    click PL "https://github.com/nhuxhr/musicont/blob/master/src/screens/Playing/index.js"
    click S "https://github.com/nhuxhr/musicont/blob/master/src/screens/Search/index.js"
    click R "https://github.com/nhuxhr/musicont/blob/master/src/screens/Recent/index.js"
    click So "https://github.com/nhuxhr/musicont/blob/master/src/screens/Songs/index.js"
    click EC "https://github.com/nhuxhr/musicont/blob/master/src/components/Cards/Explore.js"
    click MC "https://github.com/nhuxhr/musicont/blob/master/src/components/Cards/MusicList.js"
    click PC "https://github.com/nhuxhr/musicont/blob/master/src/components/Cards/Playlist.js"
    click RC "https://github.com/nhuxhr/musicont/blob/master/src/components/Cards/Recent.js"
    click ICON "https://github.com/nhuxhr/musicont/blob/master/src/components/Icon.tsx"
    click ADS "https://github.com/nhuxhr/musicont/blob/master/src/components/Ads.js"
    click HDR "https://github.com/nhuxhr/musicont/blob/master/src/widgets/Header/index.js"
    click DRW "https://github.com/nhuxhr/musicont/blob/master/src/widgets/Drawer/index.js"
    click FTR "https://github.com/nhuxhr/musicont/blob/master/src/widgets/Footer/index.js"
    click MOD1 "https://github.com/nhuxhr/musicont/blob/master/src/widgets/Modals/MoreOptions.js"
    click MOD2 "https://github.com/nhuxhr/musicont/blob/master/src/widgets/Modals/Playlist.js"
    click SEC "https://github.com/nhuxhr/musicont/tree/master/src/widgets/Sections"
    click RS "https://github.com/nhuxhr/musicont/tree/master/src/store"
    click CT "https://github.com/nhuxhr/musicont/tree/master/src/constants"
    click HELPER "https://github.com/nhuxhr/musicont/tree/master/src/helpers"
    click HOOK "https://github.com/nhuxhr/musicont/tree/master/src/hooks"
    click AST "https://github.com/nhuxhr/musicont/tree/master/assets"
    click CFG "https://github.com/nhuxhr/musicont/blob/master/app.json"

    %% Styles
    classDef entry fill:#f9c,stroke:#333,stroke-width:2px,fill-opacity:0.3
    classDef screen fill:#bbf,stroke:#333,stroke-width:2px
    classDef component fill:#cfc,stroke:#333,stroke-width:2px
    classDef widget fill:#ffc,stroke:#333,stroke-width:2px
    classDef logic fill:#fbb,stroke:#333,stroke-width:2px
    classDef config fill:#acf,stroke:#333,stroke-width:2px
    classDef external fill:#fac,stroke:#333,stroke-width:2px
```
