# dungvu187/datn architecture

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

- Interactive diagram: https://gitdiagram.com/dungvu187/datn
- Repository: https://github.com/dungvu187/datn

## Overview

This repository implements a product storefront with a customer-facing React app, a separate staff/admin console, and an Express/MongoDB backend. Customers browse products, manage a cart, place and track orders, make payments, and can use chat; staff administer products, customers, storefront content, and sales and inventory orders. The backend also provides dashboard and chat capabilities. The source index documents several frontend-to-API and backend-to-model relationships, but most route/controller wiring was not sampled, so uncertain links are omitted or marked unverified.

Main entry points: [`ad/src/App.jsx`](https://github.com/dungvu187/datn/blob/main/ad/src/App.jsx) (Admin app), [`fe/src/App.jsx`](https://github.com/dungvu187/datn/blob/main/fe/src/App.jsx) (Customer app), [`be/index.js`](https://github.com/dungvu187/datn/blob/main/be/index.js) (Express API), [`be/models/product.js`](https://github.com/dungvu187/datn/blob/main/be/models/product.js) (Product records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer storefront"]
  node_customer_app["Customer app<br/>[App.jsx]"]
  node_shop_context["Shop state<br/>[shopcontext.jsx]"]
  node_catalog_view["Catalog and detail<br/>[productdisplay.jsx]"]
  node_cart_checkout["Cart and checkout<br/>[cart.jsx]"]
  node_customer_orders["Customer orders<br/>[myorder.jsx]"]
  node_customer_chat["Chat assistant<br/>[chatbox.jsx]"]
end

subgraph group_admin["Admin console"]
  node_admin_app["Admin app<br/>[App.jsx]"]
  node_admin_products["Product administration<br/>[products.jsx]"]
  node_admin_orders["Sales orders<br/>[orderdetail.jsx]"]
  node_admin_inventory["Inventory orders<br/>[iporderdetail.jsx]"]
  node_admin_export["Export orders<br/>[eporderdetail.jsx]"]
  node_admin_storefront["Storefront management"]
  node_admin_dashboard["Admin dashboard<br/>[dashboard.jsx]"]
  node_admin_api["Admin API clients"]
end

subgraph group_backend["Backend services"]
  node_api_server["Express API<br/>[index.js]"]
  node_cart_routes["Cart routes<br/>[cart.js]"]
  node_product_routes["Product routes<br/>[product.js]"]
  node_dashboard_logic["Dashboard analytics"]
  node_chat_search["Product retrieval<br/>[chatRetrieval.js]"]
  node_auth["Admin authentication<br/>[auth.js]"]
end

subgraph group_data["Persistent data"]
  node_product_store[("Product records<br/>[product.js]")]
  node_user_store[("User records<br/>[user.js]")]
  node_history_store[("Storage history<br/>[storagehistory.js]")]
end

node_shopper(("Shopper"))
node_admin_user(("Staff user"))

node_shopper -->|"uses"| node_customer_app
node_customer_app -->|"routes to"| node_catalog_view
node_customer_app -->|"routes to"| node_cart_checkout
node_customer_app -->|"routes to"| node_customer_orders
node_customer_app -->|"renders"| node_customer_chat
node_customer_app -->|"provides state"| node_shop_context
node_shop_context -.->|"requests API"| node_api_server
node_catalog_view -->|"uses state"| node_shop_context
node_admin_user -->|"uses"| node_admin_app
node_admin_app -->|"routes to"| node_admin_products
node_admin_app -->|"routes to"| node_admin_orders
node_admin_app -->|"routes to"| node_admin_inventory
node_admin_app -->|"routes to"| node_admin_export
node_admin_app -->|"routes to"| node_admin_storefront
node_admin_app -->|"routes to"| node_admin_dashboard
node_admin_inventory -->|"calls"| node_admin_api
node_admin_export -->|"calls"| node_admin_api
node_admin_api -.->|"requests API"| node_api_server
node_api_server -.->|"mounts routes"| node_cart_routes
node_api_server -.->|"mounts routes"| node_product_routes
node_api_server -->|"dispatches"| node_dashboard_logic
node_cart_routes -->|"reads"| node_product_store
node_cart_routes -->|"reads"| node_user_store
node_product_routes -.->|"uses"| node_product_store
node_dashboard_logic -->|"queries"| node_product_store
node_dashboard_logic -->|"queries"| node_user_store
node_chat_search -->|"searches"| node_product_store
node_auth -->|"loads user"| node_user_store
node_admin_inventory -.->|"views history"| node_history_store

click node_customer_app "https://github.com/dungvu187/datn/blob/main/fe/src/App.jsx"
click node_shop_context "https://github.com/dungvu187/datn/blob/main/fe/src/context/shopcontext.jsx"
click node_catalog_view "https://github.com/dungvu187/datn/blob/main/fe/src/components/productdisplay.jsx"
click node_cart_checkout "https://github.com/dungvu187/datn/blob/main/fe/src/pages/cart.jsx"
click node_customer_orders "https://github.com/dungvu187/datn/blob/main/fe/src/pages/myorder.jsx"
click node_customer_chat "https://github.com/dungvu187/datn/blob/main/fe/src/components/chatbox.jsx"
click node_admin_app "https://github.com/dungvu187/datn/blob/main/ad/src/App.jsx"
click node_admin_products "https://github.com/dungvu187/datn/blob/main/ad/src/components/products.jsx"
click node_admin_orders "https://github.com/dungvu187/datn/blob/main/ad/src/components/order/orderdetail.jsx"
click node_admin_inventory "https://github.com/dungvu187/datn/blob/main/ad/src/components/iporder/iporderdetail.jsx"
click node_admin_export "https://github.com/dungvu187/datn/blob/main/ad/src/components/eporder/eporderdetail.jsx"
click node_admin_storefront "https://github.com/dungvu187/datn/blob/main/ad/src/components/homecategorymanager.jsx"
click node_admin_dashboard "https://github.com/dungvu187/datn/blob/main/ad/src/components/dashboard.jsx"
click node_admin_api "https://github.com/dungvu187/datn/blob/main/ad/src/api/inventoryOrderAdministrationApi.js"
click node_api_server "https://github.com/dungvu187/datn/blob/main/be/index.js"
click node_cart_routes "https://github.com/dungvu187/datn/blob/main/be/components/cart.js"
click node_product_routes "https://github.com/dungvu187/datn/blob/main/be/components/product.js"
click node_dashboard_logic "https://github.com/dungvu187/datn/blob/main/be/services/dashboardService.js"
click node_chat_search "https://github.com/dungvu187/datn/blob/main/be/services/chatRetrieval.js"
click node_auth "https://github.com/dungvu187/datn/blob/main/be/middlewares/auth.js"
click node_product_store "https://github.com/dungvu187/datn/blob/main/be/models/product.js"
click node_user_store "https://github.com/dungvu187/datn/blob/main/be/models/user.js"
click node_history_store "https://github.com/dungvu187/datn/blob/main/be/models/storagehistory.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_customer_app,node_shop_context,node_catalog_view,node_cart_checkout,node_customer_orders,node_customer_chat,node_admin_user toneBlue
class node_admin_app,node_admin_products,node_admin_orders,node_admin_inventory,node_admin_export,node_admin_storefront,node_admin_dashboard,node_admin_api toneAmber
class node_api_server,node_cart_routes,node_product_routes,node_dashboard_logic,node_chat_search,node_auth toneMint
class node_product_store,node_user_store,node_history_store toneRose
class node_shopper toneIndigo
```

## Components

### Customer storefront

- [Customer app](https://github.com/dungvu187/datn/blob/main/fe/src/App.jsx): `fe/src/App.jsx`
- [Shop state](https://github.com/dungvu187/datn/blob/main/fe/src/context/shopcontext.jsx): `fe/src/context/shopcontext.jsx`
- [Catalog and detail](https://github.com/dungvu187/datn/blob/main/fe/src/components/productdisplay.jsx): `fe/src/components/productdisplay.jsx`
- [Cart and checkout](https://github.com/dungvu187/datn/blob/main/fe/src/pages/cart.jsx): `fe/src/pages/cart.jsx`
- [Customer orders](https://github.com/dungvu187/datn/blob/main/fe/src/pages/myorder.jsx): `fe/src/pages/myorder.jsx`
- [Chat assistant](https://github.com/dungvu187/datn/blob/main/fe/src/components/chatbox.jsx): `fe/src/components/chatbox.jsx`

### Admin console

- [Admin app](https://github.com/dungvu187/datn/blob/main/ad/src/App.jsx): `ad/src/App.jsx`
- [Product administration](https://github.com/dungvu187/datn/blob/main/ad/src/components/products.jsx): `ad/src/components/products.jsx`
- [Sales orders](https://github.com/dungvu187/datn/blob/main/ad/src/components/order/orderdetail.jsx): `ad/src/components/order/orderdetail.jsx`
- [Inventory orders](https://github.com/dungvu187/datn/blob/main/ad/src/components/iporder/iporderdetail.jsx): `ad/src/components/iporder/iporderdetail.jsx`
- [Export orders](https://github.com/dungvu187/datn/blob/main/ad/src/components/eporder/eporderdetail.jsx): `ad/src/components/eporder/eporderdetail.jsx`
- [Storefront management](https://github.com/dungvu187/datn/blob/main/ad/src/components/homecategorymanager.jsx): `ad/src/components/homecategorymanager.jsx`
- [Admin dashboard](https://github.com/dungvu187/datn/blob/main/ad/src/components/dashboard.jsx): `ad/src/components/dashboard.jsx`
- [Admin API clients](https://github.com/dungvu187/datn/blob/main/ad/src/api/inventoryOrderAdministrationApi.js): `ad/src/api/inventoryOrderAdministrationApi.js`

### Backend services

- [Express API](https://github.com/dungvu187/datn/blob/main/be/index.js): `be/index.js`
- [Cart routes](https://github.com/dungvu187/datn/blob/main/be/components/cart.js): `be/components/cart.js`
- [Product routes](https://github.com/dungvu187/datn/blob/main/be/components/product.js): `be/components/product.js`
- [Dashboard analytics](https://github.com/dungvu187/datn/blob/main/be/services/dashboardService.js): `be/services/dashboardService.js`
- [Product retrieval](https://github.com/dungvu187/datn/blob/main/be/services/chatRetrieval.js): `be/services/chatRetrieval.js`
- [Admin authentication](https://github.com/dungvu187/datn/blob/main/be/middlewares/auth.js): `be/middlewares/auth.js`

### Persistent data

- [Product records](https://github.com/dungvu187/datn/blob/main/be/models/product.js): `be/models/product.js`
- [User records](https://github.com/dungvu187/datn/blob/main/be/models/user.js): `be/models/user.js`
- [Storage history](https://github.com/dungvu187/datn/blob/main/be/models/storagehistory.js): `be/models/storagehistory.js`

### Other components

- **Shopper**
- **Staff user**

## Connections

- Shopper → Customer app: uses (evidence: `fe/src/App.jsx`)
- Customer app → Catalog and detail: routes to (evidence: `fe/src/App.jsx`)
- Customer app → Cart and checkout: routes to (evidence: `fe/src/App.jsx`)
- Customer app → Customer orders: routes to (evidence: `fe/src/App.jsx`)
- Customer app → Chat assistant: renders (evidence: `fe/src/App.jsx`)
- Customer app → Shop state: provides state (evidence: `fe/src/App.jsx`)
- Shop state → Express API: requests API
- Catalog and detail → Shop state: uses state (evidence: `fe/src/components/productdisplay.jsx`)
- Staff user → Admin app: uses (evidence: `ad/src/App.jsx`)
- Admin app → Product administration: routes to (evidence: `ad/src/App.jsx`)
- Admin app → Sales orders: routes to (evidence: `ad/src/App.jsx`)
- Admin app → Inventory orders: routes to (evidence: `ad/src/App.jsx`)
- Admin app → Export orders: routes to (evidence: `ad/src/App.jsx`)
- Admin app → Storefront management: routes to (evidence: `ad/src/App.jsx`)
- Admin app → Admin dashboard: routes to (evidence: `ad/src/App.jsx`)
- Inventory orders → Admin API clients: calls (evidence: `ad/src/components/iporder/iporderdetail.jsx`)
- Export orders → Admin API clients: calls (evidence: `ad/src/components/eporder/eporderdetail.jsx`)
- Admin API clients → Express API: requests API
- Express API → Cart routes: mounts routes (evidence: `be/index.js`)
- Express API → Product routes: mounts routes (evidence: `be/index.js`)
- Express API → Dashboard analytics: dispatches
- Cart routes → Product records: reads (evidence: `be/components/cart.js`)
- Cart routes → User records: reads (evidence: `be/components/cart.js`)
- Product routes → Product records: uses
- Dashboard analytics → Product records: queries (evidence: `be/services/dashboardService.js`)
- Dashboard analytics → User records: queries (evidence: `be/services/dashboardService.js`)
- Product retrieval → Product records: searches (evidence: `be/services/chatRetrieval.js`)
- Admin authentication → User records: loads user (evidence: `be/middlewares/auth.js`)
- Inventory orders → Storage history: views history
