# lion3993vn/njs1703_himari_fe architecture

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

- Interactive diagram: https://gitdiagram.com/lion3993vn/njs1703_himari_fe
- Repository: https://github.com/lion3993vn/njs1703_himari_fe

## Overview

##### Main Components Identification
- Entry Point & Bootstrapping:
- Index.html and main.jsx as the starting point.
- Vite’s role in building and bundling the application.
- App Container & Routing:
- App.jsx as the high-level component.
- Router (located in src/routers/router.jsx) that directs navigation through the application.
- Layout & Presentation:
- Layout components like AdminLayout.jsx and RootLayout.jsx.
- Shared components (e.g., Header, Siderbar in src/components/Admin) that are used across various pages.
- Domain-Specific Admin Pages:
- Dashboard (src/adminpage/dashboard) – includes charts and overview components.
- Blog Module (src/adminpage/Blog) – includes separate paths for BlogCategory and BlogManagement.
- Brand, Category, Product, Order, User, Notification, and Symptoms – each with their pages, tables, forms for add/edit.
- That each domain often contains a hierarchy of components (i.e., pages, then nested components for CRUD operations).
- Services and API Communication:
- Chart out the service layer under src/service, which contains methods for API calls (e.g., blogAPI.js, productAPI.js, orderApi.js, etc.).
- Central instance file (src/service/instance.js) that likely configures the HTTP client (e.g., Axios).
- State Management and Contexts:
- Usage of React contexts (for example, AuthContext in src/context/AuthContext.jsx) for shared state.
- Assets, Hooks, and Utilities:
- Mention the assets folder for static resources.
- That the project makes use of custom hooks (e.g., customNavigate.jsx) and utility functions for data formatting and enums.

##### Defining Relationships and Interactions
- Flow from the entry point (main.jsx) through the router, directing users to different admin pages based on the URL.
- Each page (e.g., BlogPage, OrderManagement, Dashboard) interacts with respective API service modules to fetch or update data.
- The layout components wrap these pages to provide a consistent UI (header, sidebar).
- User actions in pages propagate through components and often trigger API calls via the service layer.
- The AuthContext provider wraps the application to manage authentication state that affects route protection and UI rendering.
- Callouts from components (e.g., image upload components, cropping features) should be shown as interactions with specialized components.

##### Architectural Patterns and Design Principles
- The separation of concerns is clear: UI components, routing/layout, state management, and API communications are organized in distinct directories.
- The modular design in the adminpage directory (and its subdirectories) indicates an effort to follow component reusability and container/presentational component patterns.
- That each module is designed to handle its CRUD operations (for example, separate components for adding, editing, and listing items).

##### Practical Steps
a. Begin by drawing the high-level structure: the entry point (index.html & main.jsx) leading to the App component and then spreading out to the router.
b. Branch from the router into primary layout segments (AdminLayout, RootLayout) and annotate that these handle shared views (header, sidebar).
c. Within the Admin section, subdivide into areas like Dashboard, Blog, Order, etc., each depicted as a container that aggregates related components.
f. A grouping for assets, hooks, and utilities which support the overall functionality but do not directly interact with the user flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Point & Bootstrapping
    subgraph "Entry Point & Bootstrapping"
        A1["index.html"]:::entry
        A2["main.jsx"]:::entry
    end

    %% Application Core
    subgraph "Application Core"
        B1["App.jsx"]:::core
        B2["Router (router.jsx)"]:::core
        B3["Auth Context (AuthContext.jsx)"]:::context
    end

    %% Layout & Presentation
    subgraph "Layouts"
        C1["AdminLayout.jsx"]:::layout
        C2["RootLayout.jsx"]:::layout
        C3["Header.jsx"]:::layout
        C4["Sidebar.jsx"]:::layout
    end

    %% Domain-Specific Admin Pages
    subgraph "Admin Pages"
        D1["Dashboard Module\n(src/adminpage/dashboard)"]:::module
        D2["Blog Module\n(src/adminpage/Blog)"]:::module
        D3["Brand Module\n(src/adminpage/brand)"]:::module
        D4["Category Module\n(src/adminpage/category)"]:::module
        D5["Product Module\n(src/adminpage/product)"]:::module
        D6["Order Module\n(src/adminpage/order)"]:::module
        D7["User Module\n(src/adminpage/user)"]:::module
        D8["Notification Module\n(src/adminpage/notification)"]:::module
        D9["Symptoms Module\n(src/adminpage/symptoms)"]:::module
    end

    %% Services and API Communication
    subgraph "Services & API"
        E1["Service Layer\n(src/service)"]:::service
        E2["API Modules\n(src/service/api)"]:::service
    end

    %% Assets, Hooks, and Utilities
    subgraph "Assets, Hooks & Utilities"
        F1["Assets\n(src/assets)"]:::utility
        F2["Custom Hooks\n(src/hooks/customNavigate.jsx)"]:::utility
        F3["Utilities\n(src/utils)"]:::utility
    end

    %% Connections
    A1 --> A2
    A2 --> B1
    B1 --> B2
    B1 --> B3

    %% Routing to Layouts
    B2 --> C1
    B2 --> C2
    C1 --> C3
    C1 --> C4

    %% Layouts to Admin Pages
    C1 --> D1
    C1 --> D2
    C1 --> D3
    C1 --> D4
    C1 --> D5
    C1 --> D6
    C1 --> D7
    C1 --> D8
    C1 --> D9

    %% Admin Pages interacting with Services
    D1 --> E1
    D2 --> E1
    D3 --> E1
    D4 --> E1
    D5 --> E1
    D6 --> E1
    D7 --> E1
    D8 --> E1
    D9 --> E1
    E1 --> E2

    %% Assets and Utilities support the application
    F1 --- B1
    F2 --- B1
    F3 --- B1

    %% Auth Context wraps the application core
    B3 --- B1

    %% Click Events for Entry Point & Bootstrapping
    click A1 "https://github.com/lion3993vn/njs1703_himari_fe/blob/main//index.html"
    click A2 "https://github.com/lion3993vn/njs1703_himari_fe/blob/main//src/main.jsx"

    %% Click Events for Application Core
    click B1 "https://github.com/lion3993vn/njs1703_himari_fe/blob/main//src/App.jsx"
    click B2 "https://github.com/lion3993vn/njs1703_himari_fe/blob/main//src/routers/router.jsx"
    click B3 "https://github.com/lion3993vn/njs1703_himari_fe/blob/main//src/context/AuthContext.jsx"

    %% Click Events for Layout & Presentation
    click C1 "https://github.com/lion3993vn/njs1703_himari_fe/blob/main//src/layout/AdminLayout.jsx"
    click C2 "https://github.com/lion3993vn/njs1703_himari_fe/blob/main//src/layout/RootLayout.jsx"
    click C3 "https://github.com/lion3993vn/njs1703_himari_fe/blob/main//src/components/Admin/Header.jsx"
    click C4 "https://github.com/lion3993vn/njs1703_himari_fe/blob/main//src/components/Admin/Siderbar.jsx"

    %% Click Events for Domain-Specific Admin Pages
    click D1 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/adminpage/dashboard"
    click D2 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/adminpage/Blog"
    click D3 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/adminpage/brand"
    click D4 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/adminpage/category"
    click D5 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/adminpage/product"
    click D6 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/adminpage/order"
    click D7 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/adminpage/user"
    click D8 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/adminpage/notification"
    click D9 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/adminpage/symptoms"

    %% Click Events for Services & API Communication
    click E1 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/service"
    click E2 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/service/api"

    %% Click Events for Assets, Hooks, and Utilities
    click F1 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/assets"
    click F2 "https://github.com/lion3993vn/njs1703_himari_fe/blob/main//src/hooks/customNavigate.jsx"
    click F3 "https://github.com/lion3993vn/njs1703_himari_fe/tree/main//src/utils"

    %% Styles
    classDef entry fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef core fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef layout fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef module fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef service fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef context fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef utility fill:#fefefe,stroke:#818182,stroke-width:2px,fill:#e9ecef;
```
