# trunghai04/muasamviet_old architecture

> Architecture diagram of the GitHub repository trunghai04/muasamviet_old, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/trunghai04/muasamviet_old
- Repository: https://github.com/trunghai04/muasamviet_old

## Overview

MuaSamViet is a React storefront backed by an Express/MySQL API. The main customer journey is browsing products, managing a cart, checking out, and tracking orders; separate branches cover accounts, administration, partner operations, and customer support. The graph includes documented capabilities even where source was not sampled. Dashed links mark documented or plausible integration points whose implementation-level wiring was not shown.

Main entry points: [`client/src/App.jsx`](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/App.jsx) (Web app router), [`client/src/pages/checkout/Checkout.jsx`](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/checkout/Checkout.jsx) (Checkout), [`server/src/server.js`](https://github.com/trunghai04/muasamviet_old/blob/main/server/src/server.js) (Express API and sockets), [`client/src/context/CartContext.jsx`](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/context/CartContext.jsx) (Cart state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_app["Web app router<br/>[App.jsx]"]
  node_home["Home and catalog<br/>[Home.jsx]"]
  node_product["Product details<br/>[ProductDetails.jsx]"]
  node_promotions["Flash sales<br/>[FlashSale.jsx]"]
end

subgraph group_commerce["Commerce"]
  node_cartstate["Cart state<br/>[CartContext.jsx]"]
  node_cartpage["Cart<br/>[Cart.jsx]"]
  node_checkout["Checkout<br/>[Checkout.jsx]"]
  node_confirmation["Order confirmation"]
  node_orderhistory["Order history<br/>[OrderHistory.jsx]"]
  node_wishlist["Wishlist<br/>[Wishlist.jsx]"]
  node_catalogroutes["Catalog endpoints<br/>[products.js]"]
  node_catalogcontroller["Product controller"]
  node_productmodel["Product model<br/>[Product.js]"]
  node_orderroutes["Order endpoints<br/>[orders.js]"]
  node_ordercontroller["Order controller<br/>[orderController.js]"]
end

subgraph group_identity["Identity"]
  node_authstate["Auth state<br/>[AuthContext.jsx]"]
  node_account["Account and loyalty<br/>[MyAccount.jsx]"]
  node_authpages["Sign-in and registration<br/>[Register.jsx]"]
  node_authroutes["Auth routes<br/>[auth.js]"]
  node_authcontroller["Auth controller<br/>[authController.js]"]
  node_userstore["User model<br/>[User.js]"]
  node_email["Email service<br/>[email.js]"]
end

subgraph group_operations["Operations"]
  node_admin["Admin dashboard<br/>[AdminDashboard.jsx]"]
  node_partner["Partner dashboard"]
  node_support["Support and feedback<br/>[Support.jsx]"]
  node_chat["Real-time chat<br/>[Chat.jsx]"]
  node_api["Express API and sockets<br/>[server.js]"]
  node_database[("MySQL database<br/>[database.js]")]
end

node_shopper(("Shopper"))

node_shopper -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_product
node_app -->|"routes to"| node_promotions
node_app -->|"routes to"| node_cartpage
node_app -->|"routes to"| node_checkout
node_app -->|"routes to"| node_confirmation
node_app -->|"routes to"| node_wishlist
node_app -->|"routes to"| node_authpages
node_app -->|"routes to"| node_account
node_app -->|"routes to"| node_admin
node_app -->|"routes to"| node_partner
node_app -->|"routes to"| node_support
node_app -->|"routes to"| node_chat
node_app -->|"provides"| node_authstate
node_app -->|"provides"| node_cartstate
node_cartpage -->|"uses"| node_cartstate
node_checkout -->|"uses"| node_cartstate
node_checkout -->|"uses"| node_authstate
node_product -->|"uses"| node_cartstate
node_authpages -->|"uses"| node_authstate
node_api -->|"mounts"| node_authroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_authcontroller -->|"reads and writes"| node_userstore
node_authcontroller -->|"sends email"| node_email
node_api -->|"mounts"| node_catalogroutes
node_catalogcontroller -->|"uses"| node_productmodel
node_ordercontroller -->|"queries"| node_database
node_productmodel -->|"queries"| node_database
node_userstore -->|"queries"| node_database
node_shopper -->|"browses"| node_home
node_shopper -->|"manages cart"| node_cartpage
node_checkout -.->|"submits order"| node_orderroutes
node_orderroutes -.->|"dispatches"| node_ordercontroller
node_orderhistory -.->|"requests history"| node_orderroutes
node_chat -.->|"realtime connection"| node_api
node_wishlist -.->|"requests wishlist"| node_api

click node_app "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/App.jsx"
click node_home "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/Home.jsx"
click node_product "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/products/ProductDetails.jsx"
click node_promotions "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/flash-sale/FlashSale.jsx"
click node_authstate "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/context/AuthContext.jsx"
click node_cartstate "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/context/CartContext.jsx"
click node_cartpage "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/cart/Cart.jsx"
click node_checkout "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/checkout/Checkout.jsx"
click node_confirmation "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/checkout/OrderConfirmation.jsx"
click node_orderhistory "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/user/OrderHistory.jsx"
click node_wishlist "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/wishlist/Wishlist.jsx"
click node_account "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/user/MyAccount.jsx"
click node_authpages "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/auth/Register.jsx"
click node_admin "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/admin/AdminDashboard.jsx"
click node_partner "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/partner/PartnerDashboard.jsx"
click node_support "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/support/Support.jsx"
click node_chat "https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/chat/Chat.jsx"
click node_api "https://github.com/trunghai04/muasamviet_old/blob/main/server/src/server.js"
click node_authroutes "https://github.com/trunghai04/muasamviet_old/blob/main/server/src/routes/auth.js"
click node_authcontroller "https://github.com/trunghai04/muasamviet_old/blob/main/server/src/controllers/authController.js"
click node_userstore "https://github.com/trunghai04/muasamviet_old/blob/main/server/src/models/User.js"
click node_catalogroutes "https://github.com/trunghai04/muasamviet_old/blob/main/server/src/routes/products.js"
click node_catalogcontroller "https://github.com/trunghai04/muasamviet_old/blob/main/server/src/controllers/productController.js"
click node_productmodel "https://github.com/trunghai04/muasamviet_old/blob/main/server/src/models/Product.js"
click node_orderroutes "https://github.com/trunghai04/muasamviet_old/blob/main/server/src/routes/orders.js"
click node_ordercontroller "https://github.com/trunghai04/muasamviet_old/blob/main/server/src/controllers/orderController.js"
click node_database "https://github.com/trunghai04/muasamviet_old/blob/main/server/src/config/database.js"
click node_email "https://github.com/trunghai04/muasamviet_old/blob/main/server/src/config/email.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_home,node_product,node_promotions toneBlue
class node_cartstate,node_cartpage,node_checkout,node_confirmation,node_orderhistory,node_wishlist,node_catalogroutes,node_catalogcontroller,node_productmodel,node_orderroutes,node_ordercontroller toneAmber
class node_authstate,node_account,node_authpages,node_authroutes,node_authcontroller,node_userstore,node_email toneMint
class node_admin,node_partner,node_support,node_chat,node_api,node_database toneRose
class node_shopper toneIndigo
```

## Components

### Storefront

- [Web app router](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Home and catalog](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/Home.jsx): `client/src/pages/Home.jsx`
- [Product details](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/products/ProductDetails.jsx): `client/src/pages/products/ProductDetails.jsx`
- [Flash sales](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/flash-sale/FlashSale.jsx): `client/src/pages/flash-sale/FlashSale.jsx`

### Commerce

- [Cart state](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/context/CartContext.jsx): `client/src/context/CartContext.jsx`
- [Cart](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/cart/Cart.jsx): `client/src/pages/cart/Cart.jsx`
- [Checkout](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/checkout/Checkout.jsx): `client/src/pages/checkout/Checkout.jsx`
- [Order confirmation](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/checkout/OrderConfirmation.jsx): `client/src/pages/checkout/OrderConfirmation.jsx`
- [Order history](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/user/OrderHistory.jsx): `client/src/pages/user/OrderHistory.jsx`
- [Wishlist](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/wishlist/Wishlist.jsx): `client/src/pages/wishlist/Wishlist.jsx`
- [Catalog endpoints](https://github.com/trunghai04/muasamviet_old/blob/main/server/src/routes/products.js): `server/src/routes/products.js`
- [Product controller](https://github.com/trunghai04/muasamviet_old/blob/main/server/src/controllers/productController.js): `server/src/controllers/productController.js`
- [Product model](https://github.com/trunghai04/muasamviet_old/blob/main/server/src/models/Product.js): `server/src/models/Product.js`
- [Order endpoints](https://github.com/trunghai04/muasamviet_old/blob/main/server/src/routes/orders.js): `server/src/routes/orders.js`
- [Order controller](https://github.com/trunghai04/muasamviet_old/blob/main/server/src/controllers/orderController.js): `server/src/controllers/orderController.js`

### Identity

- [Auth state](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Account and loyalty](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/user/MyAccount.jsx): `client/src/pages/user/MyAccount.jsx`
- [Sign-in and registration](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/auth/Register.jsx): `client/src/pages/auth/Register.jsx`
- [Auth routes](https://github.com/trunghai04/muasamviet_old/blob/main/server/src/routes/auth.js): `server/src/routes/auth.js`
- [Auth controller](https://github.com/trunghai04/muasamviet_old/blob/main/server/src/controllers/authController.js): `server/src/controllers/authController.js`
- [User model](https://github.com/trunghai04/muasamviet_old/blob/main/server/src/models/User.js): `server/src/models/User.js`
- [Email service](https://github.com/trunghai04/muasamviet_old/blob/main/server/src/config/email.js): `server/src/config/email.js`

### Operations

- [Admin dashboard](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/admin/AdminDashboard.jsx): `client/src/pages/admin/AdminDashboard.jsx`
- [Partner dashboard](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/partner/PartnerDashboard.jsx): `client/src/pages/partner/PartnerDashboard.jsx`
- [Support and feedback](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/support/Support.jsx): `client/src/pages/support/Support.jsx`
- [Real-time chat](https://github.com/trunghai04/muasamviet_old/blob/main/client/src/pages/chat/Chat.jsx): `client/src/pages/chat/Chat.jsx`
- [Express API and sockets](https://github.com/trunghai04/muasamviet_old/blob/main/server/src/server.js): `server/src/server.js`
- [MySQL database](https://github.com/trunghai04/muasamviet_old/blob/main/server/src/config/database.js): `server/src/config/database.js`

### Other components

- **Shopper**

## Connections

- Shopper → Web app router: uses (evidence: `README.md`)
- Web app router → Home and catalog: routes to (evidence: `client/src/App.jsx`)
- Web app router → Product details: routes to (evidence: `client/src/App.jsx`)
- Web app router → Flash sales: routes to (evidence: `client/src/App.jsx`)
- Web app router → Cart: routes to (evidence: `client/src/App.jsx`)
- Web app router → Checkout: routes to (evidence: `client/src/App.jsx`)
- Web app router → Order confirmation: routes to (evidence: `client/src/App.jsx`)
- Web app router → Wishlist: routes to (evidence: `client/src/App.jsx`)
- Web app router → Sign-in and registration: routes to (evidence: `client/src/App.jsx`)
- Web app router → Account and loyalty: routes to (evidence: `client/src/App.jsx`)
- Web app router → Admin dashboard: routes to (evidence: `client/src/App.jsx`)
- Web app router → Partner dashboard: routes to (evidence: `client/src/App.jsx`)
- Web app router → Support and feedback: routes to (evidence: `client/src/App.jsx`)
- Web app router → Real-time chat: routes to (evidence: `client/src/App.jsx`)
- Web app router → Auth state: provides (evidence: `client/src/App.jsx`)
- Web app router → Cart state: provides (evidence: `client/src/App.jsx`)
- Cart → Cart state: uses (evidence: `client/src/pages/cart/Cart.jsx`)
- Checkout → Cart state: uses (evidence: `client/src/pages/checkout/Checkout.jsx`)
- Checkout → Auth state: uses (evidence: `client/src/pages/checkout/Checkout.jsx`)
- Product details → Cart state: uses (evidence: `client/src/pages/products/ProductDetails.jsx`)
- Sign-in and registration → Auth state: uses (evidence: `client/src/pages/auth/Register.jsx`)
- Express API and sockets → Auth routes: mounts (evidence: `server/src/server.js`)
- Auth routes → Auth controller: dispatches (evidence: `server/src/routes/auth.js`)
- Auth controller → User model: reads and writes (evidence: `server/src/controllers/authController.js`)
- Auth controller → Email service: sends email (evidence: `server/src/controllers/authController.js`)
- Express API and sockets → Catalog endpoints: mounts (evidence: `server/src/server.js`)
- Product controller → Product model: uses (evidence: `server/src/controllers/productController.js`)
- Order controller → MySQL database: queries (evidence: `server/src/controllers/orderController.js`)
- Product model → MySQL database: queries (evidence: `server/src/models/Product.js`)
- User model → MySQL database: queries (evidence: `server/src/models/User.js`)
- Shopper → Home and catalog: browses (evidence: `README.md`)
- Shopper → Cart: manages cart (evidence: `README.md`)
- Checkout → Order endpoints: submits order
- Order endpoints → Order controller: dispatches
- Order history → Order endpoints: requests history
- Real-time chat → Express API and sockets: realtime connection
- Wishlist → Express API and sockets: requests wishlist
