# tancrb/ptn_shop_fe architecture

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

- Interactive diagram: https://gitdiagram.com/tancrb/ptn_shop_fe
- Repository: https://github.com/tancrb/ptn_shop_fe

## Overview

##### High-Level Architecture Components

a) Client Layer (Frontend)
- Core App Components
- Layout Components
- Pages/Routes
- Shared Components
- Context Providers

##### Component Structure

a) Layouts (Blue section)
- AuthLayout
- MainLayout
- MainLayoutAdmin
- ProductLayout

b) Pages (Green section)
- Public Pages (Home, Products, Blog, Contact, etc.)
- Admin Pages (Dashboard, Account Manager, Order Manager, etc.)
- Authentication Pages (Login, Register)

c) Components (Yellow section)
- UI Components (Button, Input, Dialog, Star, etc.)
- Navigation Components (Headers, Navigation, Breadcrumbs)
- Notification Components (Toastify variants)

d) Containers (Purple section)
- Home Content Containers
- Product Content Containers
- Contact Content Containers

##### State Management & Data Flow

a) Context Layer (Orange section)
- CartContext
- How it connects to relevant components

##### Feature Modules

Related features:

a) Admin Module
- Account Management
- Order Management
- Product Management
- Dashboard

b) Shopping Module
- Product Listing
- Product Details
- Shopping Cart
- Wishlist

##### Technical Details

Technical annotations:

- TailwindCSS for styling
- React Router for navigation
- Public assets structure

- Double lines: Two-way communication

##### Additional Notes
- Admin-only routes
- Protected routes
- Authentication flow
- Where forms and dialogs are used

##### The modular nature of the UI components

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions that impact development and maintenance while avoiding overwhelming detail at the component level.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Application React"
        %% Layout Layer
        subgraph Layouts
            AuthLayout["Auth Layout"]:::layout
            MainLayout["Main Layout"]:::layout
            MainLayoutAdmin["Admin Layout"]:::layout
            ProductLayout["Product Layout"]:::layout
        end

        %% Pages Layer
        subgraph Pages
            subgraph "Public Pages"
                Home["Home Page"]:::page
                Products["Products Page"]:::page
                Blog["Blog Page"]:::page
                Contact["Contact Page"]:::page
            end

            subgraph "Admin Pages"
                Dashboard["Dashboard"]:::admin
                AccountMgr["Account Manager"]:::admin
                OrderMgr["Order Manager"]:::admin
                ProductMgr["Product Manager"]:::admin
            end

            subgraph "Auth Pages"
                Login["Login"]:::auth
                Register["Register"]:::auth
            end
        end

        %% Components Layer
        subgraph "UI Components"
            Button["Button"]:::component
            Input["Input"]:::component
            Dialog["Dialog"]:::component
            Star["Star Rating"]:::component
        end

        subgraph "Navigation Components"
            HeaderDash["Header Dashboard"]:::nav
            HeaderTop["Header Top"]:::nav
            Nav["Navigation"]:::nav
            Breadcrumbs["Breadcrumbs"]:::nav
        end

        %% Containers Layer
        subgraph "Content Containers"
            HomeContent["Home Content"]:::container
            ProductContent["Product Content"]:::container
            ContactContent["Contact Content"]:::container
        end

        %% Forms Layer
        subgraph "Forms"
            PaymentForm["Payment Form"]:::form
            ProductForm["Product Form"]:::form
            LoginForm["Login Form"]:::form
            RegisterForm["Register Form"]:::form
        end

        %% Context Layer
        CartContext["Cart Context"]:::context
    end

    %% Relationships
    MainLayout --> Nav
    MainLayout --> HeaderTop
    MainLayoutAdmin --> HeaderDash
    ProductLayout --> Breadcrumbs

    Home --> HomeContent
    Products --> ProductContent
    Contact --> ContactContent

    CartContext -.-> Products
    CartContext -.-> PaymentForm

    %% Click Events
    click AuthLayout "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/layouts/auth-layout/AuthLayout.jsx"
    click MainLayout "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/layouts/main-layout/MainLayout.jsx"
    click MainLayoutAdmin "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/layouts/main-layout/MainLayoutAdmin.jsx"
    click ProductLayout "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/layouts/product-layout/ProductLayout.jsx"
    click Button "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/components/Button/Button.jsx"
    click Input "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/components/Input/Input.jsx"
    click Dialog "https://github.com/TanCRB/ptn_shop_fe/tree/main/src/components/Dialog"
    click Star "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/components/Star/Star.jsx"
    click Nav "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/components/headers/navigation/Navigation.jsx"
    click Home "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/pages/Home/HomePage.jsx"
    click Products "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/pages/Products/ProductsPage.jsx"
    click Blog "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/pages/Blog/BlogPage.jsx"
    click Contact "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/pages/Contact/ContactPage.jsx"
    click Dashboard "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/pages/admin/dashboard-admin/DashboardAdmin.jsx"
    click AccountMgr "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/pages/admin/account-manager/AccountManager.jsx"
    click OrderMgr "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/pages/admin/order-manager/OrderManager.jsx"
    click ProductMgr "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/pages/admin/products-manager/ProductsManager.jsx"
    click HomeContent "https://github.com/TanCRB/ptn_shop_fe/tree/main/src/container/contents-home/"
    click ProductContent "https://github.com/TanCRB/ptn_shop_fe/tree/main/src/container/contents-product/"
    click ContactContent "https://github.com/TanCRB/ptn_shop_fe/tree/main/src/container/contents-contact/"
    click CartContext "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/contexts/CartContext.jsx"
    click HeaderDash "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/components/headers/dashboard/HeaderDashboard.jsx"
    click HeaderTop "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/components/headers/header/HeaderTop.jsx"
    click Breadcrumbs "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/components/breadcrumbs/Breadcrumbs.jsx"
    click PaymentForm "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/components/Dialog/FormPay/FormPay.jsx"
    click ProductForm "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/components/Dialog/FormProduct/FormProduct.jsx"
    click LoginForm "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/pages/Login/LoginForm.jsx"
    click RegisterForm "https://github.com/TanCRB/ptn_shop_fe/blob/main/src/pages/Register/RegisterForm.jsx"

    %% Styles
    classDef layout fill:#2196F3,stroke:#1976D2,color:white
    classDef page fill:#4CAF50,stroke:#388E3C,color:white
    classDef admin fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef auth fill:#FF9800,stroke:#F57C00,color:white
    classDef component fill:#FFC107,stroke:#FFA000,color:black
    classDef nav fill:#00BCD4,stroke:#0097A7,color:white
    classDef container fill:#673AB7,stroke:#512DA8,color:white
    classDef form fill:#E91E63,stroke:#C2185B,color:white
    classDef context fill:#FF5722,stroke:#E64A19,color:white
```
