# phuc165/client_ec architecture

> Architecture diagram of the GitHub repository phuc165/client_ec, 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/phuc165/client_ec
- Repository: https://github.com/phuc165/client_ec

## Overview

##### Main Components
- Vite Build System: At the top or as the foundational layer, illustrate Vite as the build tool that manages bundling and development (via HMR) for the app.
- Static Assets & HTML: Include the “index.html” and “public” folder that supply static files (images and other public resources).
- React Application Core: Highlight the “src” folder. Under this, note several subcomponents:
- Entry Point: “src/main.jsx” and “src/App.jsx” that boot up the React app.
- Layouts: “src/Layouts” contains various layouts (DefaultLayout, HomeLayout) along with common elements like Headers, Footers, and utility components (e.g., ToTopButton).
- Pages & Routing: “src/pages” includes individual application pages (home, about, login, signup, productDetail etc.). The “src/routes/index.js” file likely defines the routing configuration.
- Reusable Components: “src/components” includes components like Banner, BestSeller, Category, ProductCard, etc.
- State Management: “src/redux” is dedicated to the Redux store and slices (authSlice, cartSlice, productSlice, orderSlice), exemplifying how global state is managed across the application.

##### Establish Relationships and Interactions
- Flow from “src/main.jsx” to “src/App.jsx” marking the entry point into the React component tree.
- Within the React app, visually distinguish the layout components, which wrap around the page components. Use grouping to show that different page routes (e.g., home, about, login, productDetail) get wrapped by either the DefaultLayout or HomeLayout.
- A connectivity line between the routing module (“src/routes”) and the page components to denote navigation flow.
- Static assets and styling layers (Sass files) as supporting layers that feed into the rendering of components.

##### Architectural Patterns & Design Principles
- Component-Based Architecture: Show how modular React components (e.g., reusable UI components like ProductCard, Navigation, StarRatingDisplay) are designed for reuse.
- Separation of Concerns: Differentiate between visual layout (Layouts, components), business logic (pages and Redux slices), and static resources (assets, public folder).
- State Management: Emphasize the centralized Redux store pattern that coordinates state changes across various parts of the UI.
- Routing: Represent that the “src/routes” module orchestrates the rendering of pages depending on the URL, a key part of the SPA design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Config Layer
    subgraph "Build & Config"
        Vite["Vite Build Tool"]:::build
        ViteConfig["vite.config.js"]:::build
        Package["package.json"]:::build
        Vite --> ViteConfig
        Vite --> Package
    end

    %% Static Assets & HTML Layer
    subgraph "Static Assets & HTML"
        IndexHTML["index.html"]:::static
        Public["Public Folder"]:::static
        IndexHTML --> Public
    end

    %% React Application Entry Layer
    subgraph "React Application Entry"
        Main["main.jsx"]:::entry
        App["App.jsx"]:::entry
        Main --> App
    end

    %% UI Layer
    subgraph "UI Layer"
        Layout["Layouts"]:::ui
        Default["Default Layout"]:::ui
        Home["Home Layout"]:::ui
        Routing["Routing Module"]:::ui
        Pages["Page Components"]:::ui
        Components["UI Components"]:::ui
        Layout --> Default
        Layout --> Home
        Routing --> Pages
    end

    %% Supporting Assets Layer
    subgraph "Supporting Assets"
        SVG["SVG Icons"]:::assets
        Styles["Styles"]:::assets
    end

    %% State Management Layer
    subgraph "State Management"
        Redux["Redux Store & Slices"]:::state
    end

    %% Connections among Layers
    Vite --> IndexHTML
    IndexHTML --> Main
    App --> Layout
    App --> Routing
    App --> Components
    Routing --> Pages
    Pages -->|dispatch| Redux
    Components -->|dispatch| Redux
    Redux -->|state| Components
    Redux -->|state| Pages
    SVG --> Components
    Styles --> Components

    %% Class Definitions for Colour Coding
    classDef build fill:#FFCCFF,stroke:#990099,stroke-width:2px;
    classDef static fill:#CCE5FF,stroke:#004085,stroke-width:2px;
    classDef entry fill:#CCFFCC,stroke:#238823,stroke-width:2px;
    classDef ui fill:#FFEBCC,stroke:#CC7A00,stroke-width:2px;
    classDef assets fill:#E0FFFF,stroke:#008B8B,stroke-width:2px;
    classDef state fill:#FFD6CC,stroke:#CC3300,stroke-width:2px;

    %% Click Events
    click Vite "https://github.com/phuc165/client_ec/blob/master/vite.config.js"
    click ViteConfig "https://github.com/phuc165/client_ec/blob/master/vite.config.js"
    click Package "https://github.com/phuc165/client_ec/blob/master/package.json"
    click IndexHTML "https://github.com/phuc165/client_ec/blob/master/index.html"
    click Public "https://github.com/phuc165/client_ec/tree/master/public/"
    click Main "https://github.com/phuc165/client_ec/blob/master/src/main.jsx"
    click App "https://github.com/phuc165/client_ec/blob/master/src/App.jsx"
    click Layout "https://github.com/phuc165/client_ec/tree/master/src/Layouts"
    click Default "https://github.com/phuc165/client_ec/tree/master/src/Layouts/DefaultLayout"
    click Home "https://github.com/phuc165/client_ec/tree/master/src/Layouts/HomeLayout"
    click Routing "https://github.com/phuc165/client_ec/blob/master/src/routes/index.js"
    click Pages "https://github.com/phuc165/client_ec/tree/master/src/pages"
    click Components "https://github.com/phuc165/client_ec/tree/master/src/components"
    click SVG "https://github.com/phuc165/client_ec/tree/master/src/assets/svg"
    click Styles "https://github.com/phuc165/client_ec/tree/master/src/styles"
    click Redux "https://github.com/phuc165/client_ec/tree/master/src/redux"
```
