# nghiaxhh/boom architecture

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

- Interactive diagram: https://gitdiagram.com/nghiaxhh/boom
- Repository: https://github.com/nghiaxhh/boom

## Overview

##### Main Components
- Entry Point & Bootstrapping:
- App component (src/App.js) which acts as the central container.

- UI Structure:
- Layouts: Identify different layout components (e.g., “AppLayout”, “AuthLayout”, “MainLayout”) in the “src/layouts” directory. These manage the overall page structure and are often used by pages depending on user state (authenticated or not).
- Pages: Represent each major page (e.g., “Authentication”, “HomePage”, “PointSystem”, “Rewards”, “UserInfo”, “PageNotFound”, “RootPage”). Each page might compose several child components.
- Assets & Styling: Group directories like “public” (static HTML and manifest files), “src/assets” (images), “src/styles” (CSS/SCSS, Tailwind config file). These supply static resources and global styling.

- State Management:
- “src/store” module to highlight centralized state management. Note the “commonSlice.js” and “store.js”, which indicates a Redux slice implementation or similar.

- Routing & Navigation:
- “src/routes” which include route constants and route definitions. This layer handles navigation between the different pages and layout components.

- Services & Helpers:
- Modules like “src/services” (AuthServices, FileServices, Statistics, UserServices, apiRouter.js) to illustrate the API or business logic interactions.
- The “src/helper” directory contains constants and utility functions, which support various parts of the application.

- Hooks:
- “src/hook” directory (e.g., useQueryMe) as part of the custom hook system to interact with the state or perform side effects.

##### Relationships & Interactions
- Data Flow:
- Start from “index.js” where ReactDOM renders the App. The App component then loads the routing component which directs users to various pages based on the URL.
- Layout components wrap around page components, providing common UI framing (like navigation bars in “MainLayout/Navbar.jsx”).
- Each page uses UI components (from “components”) to render specific parts of the view. Pages might also invoke custom hooks and call service APIs.

- API & Service Integration:

- Utility Functions:
- That helper functions are used across components to maintain consistency (e.g., managing constants, data formatting, etc.)

##### Architectural Patterns & Design Principles
- Component-based development: Clearly indicate that UI is built from small, reusable pieces.
- Separation of Concerns: Illustrate how layouts, pages, components, services, and store are kept in separate modules.
- Use of Hooks: Represent the custom hooks acting as intermediaries to abstract logic from presentation components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Point
    subgraph "Entry Point"
        index("src/index.js"):::entry
        app("src/App.js"):::entry
    end
    index -->|"renders"| app

    %% UI Layer
    subgraph "UI Layer"
        %% Layouts
        subgraph "Layouts"
            appLayout("AppLayout"):::layout
            authLayout("AuthLayout"):::layout
            mainLayout("MainLayout"):::layout
            navbar("Navbar"):::layoutComp
        end

        %% Pages
        subgraph "Pages"
            authentication("Authentication Pages"):::page
            homePage("HomePage"):::page
            pointSystem("PointSystem"):::page
            rewards("Rewards"):::page
            userInfo("UserInfo"):::page
            pageNotFound("PageNotFound"):::page
            rootPage("RootPage"):::page
        end

        %% Reusable Components
        subgraph "Reusable Components"
            button("Button"):::component
            icon("IconSvg"):::component
            modal("ModalCommon"):::component
            toast("Toastify"):::component
        end
    end

    %% State Management & Logic
    subgraph "State Management & Logic"
        store("Redux/Store"):::state
        routes("Routing"):::route
        hooks("Custom Hooks"):::hook
        services("API Services"):::service
        helpers("Helpers & Utils"):::helper
    end

    %% Static Assets & Styling
    subgraph "Static Assets & Styling"
        assets("Public Assets"):::asset
        images("Images"):::asset
        styles("Styles & Config"):::asset
    end

    %% Relationships
    app -->|"uses"| routes
    routes -->|"defines"| authentication
    routes -->|"defines"| homePage
    routes -->|"defines"| pointSystem
    routes -->|"defines"| rewards
    routes -->|"defines"| userInfo
    routes -->|"defines"| pageNotFound
    routes -->|"defines"| rootPage

    authentication -->|"wrappedBy"| authLayout
    homePage -->|"wrappedBy"| mainLayout
    pointSystem -->|"wrappedBy"| mainLayout
    rewards -->|"wrappedBy"| mainLayout
    userInfo -->|"wrappedBy"| mainLayout
    pageNotFound -->|"wrappedBy"| mainLayout

    mainLayout -->|"includes"| navbar

    homePage -->|"uses"| button
    rewards -->|"uses"| toast
    userInfo -->|"uses"| icon
    %% Indicate pages also use modal from various interactions
    homePage -->|"uses"| modal

    authentication -->|"updates"| store
    homePage -->|"updates"| store
    pointSystem -->|"updates"| store
    rewards -->|"updates"| store
    userInfo -->|"updates"| store
    pageNotFound -->|"updates"| store
    rootPage -->|"updates"| store
    store -->|"triggers"| authentication

    hooks -->|"accesses"| store
    hooks -->|"calls"| services
    services -->|"utilizes"| helpers

    %% Assets integration
    assets -->|"loads into"| app
    images -->|"used by"| app
    styles -->|"applied to"| app

    %% Click Events
    click index "https://github.com/nghiaxhh/boom/blob/main/src/index.js"
    click app "https://github.com/nghiaxhh/boom/blob/main/src/App.js"
    click appLayout "https://github.com/nghiaxhh/boom/blob/main/src/layouts/AppLayout/index.jsx"
    click authLayout "https://github.com/nghiaxhh/boom/blob/main/src/layouts/AuthLayout/index.jsx"
    click mainLayout "https://github.com/nghiaxhh/boom/blob/main/src/layouts/MainLayout/index.jsx"
    click navbar "https://github.com/nghiaxhh/boom/blob/main/src/layouts/MainLayout/Navbar.jsx"
    click authentication "https://github.com/nghiaxhh/boom/tree/main/src/pages/Authentication"
    click homePage "https://github.com/nghiaxhh/boom/tree/main/src/pages/HomePage"
    click pointSystem "https://github.com/nghiaxhh/boom/tree/main/src/pages/PointSystem"
    click rewards "https://github.com/nghiaxhh/boom/tree/main/src/pages/Rewards"
    click userInfo "https://github.com/nghiaxhh/boom/tree/main/src/pages/UserInfo"
    click pageNotFound "https://github.com/nghiaxhh/boom/tree/main/src/pages/PageNotFound"
    click rootPage "https://github.com/nghiaxhh/boom/tree/main/src/pages/RootPage"
    click button "https://github.com/nghiaxhh/boom/tree/main/src/components/Button"
    click icon "https://github.com/nghiaxhh/boom/tree/main/src/components/IconSvg"
    click modal "https://github.com/nghiaxhh/boom/tree/main/src/components/ModalCommon"
    click toast "https://github.com/nghiaxhh/boom/tree/main/src/components/Toastify"
    click assets "https://github.com/nghiaxhh/boom/tree/main/public"
    click images "https://github.com/nghiaxhh/boom/tree/main/src/assets/images"
    click styles "https://github.com/nghiaxhh/boom/tree/main/src/styles"
    click store "https://github.com/nghiaxhh/boom/tree/main/src/store"
    click routes "https://github.com/nghiaxhh/boom/tree/main/src/routes"
    click services "https://github.com/nghiaxhh/boom/tree/main/src/services"
    click helpers "https://github.com/nghiaxhh/boom/tree/main/src/helper"
    click hooks "https://github.com/nghiaxhh/boom/tree/main/src/hook"

    %% Styles
    classDef entry fill:#f9c74f,stroke:#000,stroke-width:1px;
    classDef layout fill:#90be6d,stroke:#000,stroke-width:1px;
    classDef layoutComp fill:#a3e635,stroke:#000,stroke-width:1px;
    classDef page fill:#f94144,stroke:#000,stroke-width:1px;
    classDef component fill:#577590,stroke:#000,stroke-width:1px;
    classDef state fill:#43aa8b,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5;
    classDef route fill:#277da1,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5;
    classDef hook fill:#ffcc00,stroke:#000,stroke-width:1px,stroke-dasharray: 3 3;
    classDef service fill:#f3722c,stroke:#000,stroke-width:1px,stroke-dasharray: 3 3;
    classDef helper fill:#f9844a,stroke:#000,stroke-width:1px,stroke-dasharray: 3 3;
    classDef asset fill:#90caf9,stroke:#000,stroke-width:1px;
```
