# ben0588/react-fragrance-dawn architecture

> Architecture diagram of the GitHub repository ben0588/react-fragrance-dawn, 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/ben0588/react-fragrance-dawn
- Repository: https://github.com/ben0588/react-fragrance-dawn

## Overview

##### Main Components
- Frontend UI: The user interface built with React. This includes components for the home page, product pages, cart management, account pages, service pages, and the article section.
- Admin Interface: A separate section within the app (under pages/admin and components/admin) that handles login, product management, coupon management, order tracking, and article management.
- State Management: Utilizes Redux Toolkit with multiple slices (e.g., cartSlice, adminSlice, loadingSlice, etc.) to manage application state — both for customer interactions and admin functionalities.
- API Layer: The “src/api” and “src/store/apis” directories serve as the module for handling communication with back-end endpoints. Although this project presently hosts static JSON files (in public/data assets), the API logic is set up to interface with external services.
- Routing: Managed by React Router (as seen in “src/PagesRoutes.jsx” and the various “src/pages” directories) to determine which page or component is rendered based on application state or user action.
- Assets & Styles: Images, videos, JSON data, and SCSS styles (located in “public”, “src/assets”, and “src/style”) that support UI rendering and design.
- Custom Hooks & Utilities: “src/hooks” (e.g., useMessage, usePriceToTw) provide reusable logic or utilities across components.

##### Relationships and Interactions
- The main App component (src/App.jsx) bootstraps the application, rendering the overall layout (from “src/components/layout/Layout.jsx”) which in turn hosts the header, footer, and dynamic content based on routing.
- Data Flow: UI components dispatch actions or use RTK Query to trigger API requests; these, in turn, update the Redux store. Components then subscribe to state changes to reflect UI updates.
- API interactions are abstracted into separate modules (both in “src/api” and “src/store/apis”) which means the UI components rely on these services to fetch or update data.
- The design follows component-driven architecture using various reusable components (e.g., pagination, modals, carousels) that are composed into pages.

##### Architectural Patterns and Technologies
- Component-Based Design: Every UI piece is broken into self-contained components, enabling code reusability.
- Redux for State Management: Multiple slices indicate a centralized store managing independent pieces of state (e.g., cart, admin, loading indicators, messages, etc.).
- Separation of Concerns: Clear delineation between API calls, state management, visual assets, page components, and administrative functionalities.

##### Detailed Elements
- Client Side: App, Pages (Home, Product, Cart, Account, Order, Service, Article, etc.), Components (UI elements like Carousel, Card, Pagination, Form inputs, etc.)
- Admin Side: Components and Pages specifically for admin (AdminDashboard, AdminArticleSection, AdminProductsSection, Login, and Modals such as CouponModal, OrderModal, etc.)
- State Management: Redux Store & Slices (annotate each major slice like cartSlice, adminSlice, etc.)
- API Layer: API modules for admin, client, etc.
- Assets & Static Resources: A block for Public and Assets (images, JSON data, videos).
- Custom Hooks and utilities.
- Flow from App to individual pages based on routing.
- Data flow from UI components triggering API requests, which update the Redux store.
- Interdependencies among API, Redux slices, and UI components.
- Data management components (e.g., Redux, API modules)
- External resources (public assets, external libraries)
- Annotating interactions with labels (for instance, “Dispatch Action”, “API Request”, “State Update”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Routing & Bootstrap Layer
    A["App Bootstrap"]:::routing
    R["Routing"]:::routing
    A -->|"navigate"| R

    %% Frontend UI Layer
    subgraph "Frontend UI"
        H["Home Page"]:::frontend
        AR["Article Page"]:::frontend
        C["Cart Page"]:::frontend
        O["Order Page"]:::frontend
        P["Products Page"]:::frontend
        S["Service Page"]:::frontend
        AC["Account Page"]:::frontend
        W["Wishlist Page"]:::frontend
        UC["UI Components"]:::frontend
    end
    R -->|"navigate"| H
    R -->|"navigate"| AR
    R -->|"navigate"| C
    R -->|"navigate"| O
    R -->|"navigate"| P
    R -->|"navigate"| S
    R -->|"navigate"| AC
    R -->|"navigate"| W

    %% Admin Interface Layer
    subgraph "Admin Interface"
        AP["Admin Pages"]:::admin
        ACmp["Admin Components"]:::admin
    end
    R -->|"navigate"| AP

    %% State Management Layer
    subgraph "State Management"
        RS["Redux Store"]:::state
        RSl["Redux Slices"]:::state
        AE["API Endpoints"]:::state
    end
    RS --> RSl
    RS --> AE

    %% API Layer
    subgraph "API Layer"
        AM["API Modules"]:::api
    end
    AE -->|"API_Call"| AM

    %% Assets & Styles Layer
    subgraph "Assets & Styles"
        SA["Static Assets"]:::assets
        ST["Styling"]:::assets
    end

    %% Custom Hooks Layer
    CH["Custom Hooks"]:::hooks

    %% Interactions within Frontend UI
    H -->|"interaction"| UC
    AR -->|"interaction"| UC
    C -->|"interaction"| UC
    O -->|"interaction"| UC
    P -->|"interaction"| UC
    S -->|"interaction"| UC
    AC -->|"interaction"| UC
    W -->|"interaction"| UC

    %% Admin UI Interaction
    AP -->|"interaction"| ACmp

    %% Data Flow: UI dispatching to State Management
    UC -->|"Dispatch"| RS
    ACmp -->|"Dispatch"| RS

    %% UI using Custom Hooks and Assets
    UC -->|"Uses"| CH
    UC -->|"Uses"| SA
    UC -->|"Uses"| ST

    %% State update back to UI
    RS -->|"Update"| UC

    %% Click Events
    click H "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/pages/home"
    click AR "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/pages/article"
    click C "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/pages/cart"
    click O "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/pages/order"
    click P "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/pages/products"
    click S "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/pages/service"
    click AC "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/pages/account"
    click W "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/pages/wishlist"
    click UC "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/components"
    click AP "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/pages/admin"
    click ACmp "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/components/admin"
    click RS "https://github.com/ben0588/react-fragrance-dawn/blob/main/src/store/store.jsx"
    click RSl "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/store/slice"
    click AE "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/store/apis"
    click AM "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/api"
    click A "https://github.com/ben0588/react-fragrance-dawn/blob/main/src/App.jsx"
    click R "https://github.com/ben0588/react-fragrance-dawn/blob/main/src/PagesRoutes.jsx"
    click SA "https://github.com/ben0588/react-fragrance-dawn/tree/main/public"
    click ST "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/style"
    click CH "https://github.com/ben0588/react-fragrance-dawn/tree/main/src/hooks"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef admin fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef state fill:#FFFF99,stroke:#000,stroke-width:1px;
    classDef api fill:#FFC0CB,stroke:#000,stroke-width:1px;
    classDef routing fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef assets fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef hooks fill:#E0FFFF,stroke:#000,stroke-width:1px;
```
