# hq-nguyen/beautyskin-client architecture

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

- Interactive diagram: https://gitdiagram.com/hq-nguyen/beautyskin-client
- Repository: https://github.com/hq-nguyen/beautyskin-client

## Overview

##### Project type and purpose
- This is a single-page frontend application (built with ReactJS and Vite) for a Skincare Shop Management System.
- It provides UIs for customers, staff, and admins, handling everything from product browsing and skin-type quizzes to order checkout and feedback submission.

##### File structure
- Top-level configuration & build files: package.json, vite.config.js, tailwind.config.js, deploy.sh, .gitignore.
- “public” holds static assets (favicon, index.html template).
- “src” is the heart of the app:
- App.jsx, main.jsx bootstrap the React application.
- config/ (axios + firebase setup)
- apis/ (REST API wrappers for blog, product, order, customer, staff, etc.)
- redux/ (Redux store + slices for cart, compare, user)
- contexts/ (React Contexts for feedback & product)
- components/ (reusable UI pieces grouped by feature)
- layout/ (layout components for Main, Admin, Staff, Checkout, Support)
- pages/ (page-level components mapped to routes)
- routes/ (ProtectedRoute & Routers.jsx define client-side routing)

##### Pulling in README insights
- Confirms ReactJS + TailwindCSS + RESTful API integration.
- High-level features: Homepage, Skin Testing, Product Recommendations, Feedback.

a. Main components to represent:
- Browser (Client)
- Vite / dev server (for development)
- React Application (SPA)
– React Router (Routers.jsx + ProtectedRoute)
– Layouts (MainLayout, AdminLayout, etc.)
– Pages (Home, Shop, Checkout, Admin Dashboards, Quiz, etc.)
– Components (Navbar, Footer, Card, Sidebar, etc.)
– State management
· Redux Store (cartSlice, compareSlice, userSlice)
· Context Providers (FeedbackContext, ProductContext)
- API Layer
– Axios instance (src/config/axios.js)
– RESTful endpoints (src/apis/*)
- External Services
– Backend API (VITE_API_BASE_URL)
– Firebase (Auth, Storage)

b. Relationships and interactions
- Browser sends HTTP(S) requests to the Vite dev server (or static files in production).
- Vite serves the React bundle.
- React Router maps URL → Page component.
- Page components dispatch actions to Redux or call Context methods.
- Redux/Context invoke axios to call external Backend API or Firebase services.
- Responses flow back → Redux store/Context → UI components update.

c. Architectural patterns & design principles
- SPA (Single-Page Application) with client-side routing (React Router).
- Component-based architecture, feature grouping in “components/” and “pages/”.
- Separation of concerns:
– UI layer (components + layouts)
– State layer (Redux + Context)
– API layer (axios wrappers)
- Environment/config isolation via .env and src/config.
- Reusable hooks (src/hooks/*) and utils (src/utils/*).

d. Key technologies & libraries
- ReactJS + Vite
- React Router
- Redux Toolkit
- React Context API
- Axios
- TailwindCSS
- Firebase SDK

##### Elements
- Clear labels for each component (e.g., “Redux Store”, “FeedbackContext Provider”)
– Browser → React Router → Page → API call → Backend
– API response → Redux/Context → Component render
– Green for state management (Redux/Context)
– Orange for API layer
– Gray for external systems (Backend API, Firebase)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client & Dev Server
    Browser["Browser"]:::external
    ViteDev["Vite Dev Server"]:::integration
    Browser --> ViteDev
    ViteDev --> ReactApp

    %% UI Layer
    subgraph "UI Layer"
        ReactApp["React Application (SPA)"]:::ui
        ReactApp --> MainEntry
        MainEntry["main.jsx"]:::ui
        MainEntry --> AppComp
        AppComp["App.jsx"]:::ui
        AppComp --> RouterComp
        subgraph "Routing"
            RouterComp["Routers.jsx"]:::ui
            ProtectedComp["ProtectedRoute.jsx"]:::ui
            RouterComp --> ProtectedComp
        end
        subgraph "Layouts"
            MainLayout["MainLayout.jsx"]:::ui
            AdminLayout["AdminLayout.jsx"]:::ui
            StaffLayout["StaffLayout.jsx"]:::ui
            CheckoutLayout["CheckoutLayout.jsx"]:::ui
            SupportLayout["SupportLayout.jsx"]:::ui
            UserLayout["UserLayout.jsx"]:::ui
        end
        ProtectedComp --> MainLayout
        ProtectedComp --> AdminLayout
        ProtectedComp --> StaffLayout
        ProtectedComp --> CheckoutLayout
        ProtectedComp --> SupportLayout
        ProtectedComp --> UserLayout

        subgraph "Pages"
            HomePage["Home.jsx"]:::ui
            ShopPage["Shop.jsx"]:::ui
            CheckoutPage["checkout.jsx"]:::ui
            TestSkinPage["TestSkinType.jsx"]:::ui
            AdminDash["Dashboard.jsx (Admin)"]:::ui
            StaffDash["Dashboard.jsx (Staff)"]:::ui
            BlogPage["Blog.jsx"]:::ui
            BlogDetail["BlogDetail.jsx"]:::ui
        end
        MainLayout --> HomePage
        MainLayout --> ShopPage
        MainLayout --> TestSkinPage
        MainLayout --> BlogPage
        MainLayout --> BlogDetail
        CheckoutLayout --> CheckoutPage
        AdminLayout --> AdminDash
        StaffLayout --> StaffDash

        subgraph "Components"
            Navbar["Navbar.jsx"]:::ui
            Footer["Footer.jsx"]:::ui
            ProductCard["ProductItem.jsx"]:::ui
            QuestionComp["Question.jsx"]:::ui
            OrderHist["OrderHistory.jsx"]:::ui
        end
        HomePage --> Navbar
        HomePage --> Footer
        ShopPage --> ProductCard
        TestSkinPage --> QuestionComp
        StaffDash --> OrderHist

        %% UI to State
        HomePage -->|dispatch/call| ReduxStore
        ShopPage -->|dispatch/call| ReduxStore
        CheckoutPage -->|dispatch/call| ReduxStore
        TestSkinPage -->|useContext| FeedbackContext
        ShopPage -->|useContext| ProductContext
    end

    %% State Layer
    subgraph "State Layer"
        ReduxStore["Redux Store"]:::state
        subgraph "Slices"
            CartSlice["cartSlice.js"]:::state
            CompareSlice["compareSlice.js"]:::state
            UserSlice["userSlice.js"]:::state
        end
        ReduxStore --> CartSlice
        ReduxStore --> CompareSlice
        ReduxStore --> UserSlice

        FeedbackContext["FeedbackContext.jsx"]:::state
        ProductContext["ProductContext.jsx"]:::state
    end

    %% Integration Layer
    subgraph "Integration Layer"
        AxiosConfig["axios.js"]:::integration
        FirebaseConfig["firebase.js"]:::integration
        subgraph "API Services"
            APIServices["src/apis/*"]:::integration
        end
        ReduxStore --> AxiosConfig
        FeedbackContext --> AxiosConfig
        ProductContext --> AxiosConfig
        ReduxStore --> FirebaseConfig
        FeedbackContext --> FirebaseConfig
        AxiosConfig --> APIServices
        FirebaseConfig --> FirebaseConfig
    end

    %% External Services
    subgraph "External Services"
        BackendAPI["Backend API (VITE_API_BASE_URL)"]:::external
        FirebaseService["Firebase (Auth, Storage)"]:::external
    end
    APIServices --> BackendAPI
    FirebaseConfig --> FirebaseService

    %% Static & Config
    subgraph "Static & Config"
        PublicIndex["public/index.html"]:::external
        TailwindCfg["tailwind.config.js"]:::integration
        GlobalStyles["index.css"]:::integration
        PublicIndex --> ReactApp
        TailwindCfg --> ReactApp
        GlobalStyles --> ReactApp
    end

    %% Click Events
    click ViteDev "https://github.com/hq-nguyen/beautyskin-client/blob/main/vite.config.js"
    click MainEntry "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/main.jsx"
    click AppComp "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/App.jsx"
    click RouterComp "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/routes/Routers.jsx"
    click ProtectedComp "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/routes/ProtectedRoute.jsx"
    click MainLayout "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/layout/MainLayout.jsx"
    click AdminLayout "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/layout/AdminLayout.jsx"
    click StaffLayout "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/layout/StaffLayout.jsx"
    click CheckoutLayout "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/layout/CheckoutLayout.jsx"
    click SupportLayout "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/layout/SupportLayout.jsx"
    click UserLayout "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/layout/UserLayout.jsx"
    click HomePage "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/pages/Home.jsx"
    click ShopPage "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/pages/Shop/Shop.jsx"
    click CheckoutPage "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/pages/Checkout/checkout.jsx"
    click TestSkinPage "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/pages/TestSkinType/TestSkinType.jsx"
    click AdminDash "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/pages/Admin/Dashboard/Dashboard.jsx"
    click StaffDash "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/pages/Staff/Dashboard.jsx"
    click BlogPage "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/pages/Blog/Blog.jsx"
    click BlogDetail "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/pages/Blog/BlogDetail.jsx"
    click Navbar "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/components/Navbar/Navbar.jsx"
    click Footer "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/components/Footer/Footer.jsx"
    click ProductCard "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/components/Card/ProductItem.jsx"
    click QuestionComp "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/components/Quiz/Question.jsx"
    click OrderHist "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/components/Order/OrderHistory.jsx"
    click ReduxStore "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/redux/store.js"
    click CartSlice "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/redux/features/cartSlice.js"
    click CompareSlice "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/redux/features/compareSlice.js"
    click UserSlice "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/redux/features/useSlice.js"
    click FeedbackContext "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/contexts/FeedbackContext.jsx"
    click ProductContext "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/contexts/ProductContext.jsx"
    click AxiosConfig "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/config/axios.js"
    click FirebaseConfig "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/config/firebase.js"
    click APIServices "https://github.com/hq-nguyen/beautyskin-client/tree/main/src/apis/"
    click PublicIndex "https://github.com/hq-nguyen/beautyskin-client/blob/main/public/index.html"
    click TailwindCfg "https://github.com/hq-nguyen/beautyskin-client/blob/main/tailwind.config.js"
    click GlobalStyles "https://github.com/hq-nguyen/beautyskin-client/blob/main/src/index.css"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#000
    classDef state fill:#D6F5D6,stroke:#28a745,color:#000
    classDef integration fill:#FFE4B3,stroke:#e69500,color:#000
    classDef external fill:#E0E0E0,stroke:#636363,color:#000
```
