# thanhdai2005/dac-san-ba-mien architecture

> Architecture diagram of the GitHub repository thanhdai2005/dac-san-ba-mien, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thanhdai2005/dac-san-ba-mien
- Repository: https://github.com/thanhdai2005/dac-san-ba-mien

## Overview

Dac San Ba Mien is a Vietnamese-food ordering platform with customer shopping and order management, a role-governed admin console, publishing, reviews, and real-time AI/human support. The principal customer flow is browsing products, managing a cart, checking out with a payment choice, and tracking an order; delivered orders can be reviewed. The graph combines README capabilities with sampled order, review, authentication, and chat code; unsampled subsystem links are limited to documented responsibilities and their existing directories.

Main entry points: [`backend/api/v1/client/controllers/order.controller.js`](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/client/controllers/order.controller.js) (Order processing), [`backend/api/v1/client/routes/index.route.js`](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/client/routes/index.route.js) (Client API), [`backend/socket/chat.handler.js`](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/socket/chat.handler.js) (Realtime chat), [`backend/api/v1/admin/controllers`](https://github.com/thanhdai2005/dac-san-ba-mien/tree/master/backend/api/v1/admin/controllers) (Catalog and order management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer experience"]
  node_client_app["Client app<br/>[App.tsx]"]
  node_catalog["Product catalog"]
  node_cart["Shopping cart<br/>[CartPage.tsx]"]
  node_checkout["Checkout<br/>[CheckoutPage.tsx]"]
  node_orders_ui["Order tracking<br/>[OrdersPage.tsx]"]
  node_reviews_ui["Product reviews"]
end

subgraph group_commerce["Commerce services"]
  node_client_api["Client API<br/>[index.route.js]"]
  node_order_logic["Order processing"]
  node_product_data[("Products<br/>[product.model.js]")]
  node_order_data[("Orders<br/>[order.model.js]")]
  node_cart_data[("Cart<br/>[cart.model.js]")]
  node_payments["Payment gateways<br/>[momo.js]"]
  node_payment_services["VNPAY integration<br/>[vnpay.js]"]
  node_mailer["Order email<br/>[mailer.js]"]
  node_review_logic["Review processing"]
  node_review_data[("Reviews<br/>[review.model.js]")]
end

subgraph group_admin["Administration"]
  node_admin_ui["Admin console<br/>[adminRoute.tsx]"]
  node_admin_api["Admin API<br/>[index.route.js]"]
  node_admin_ops["Catalog and order management"]
  node_role_data[("Roles and permissions<br/>[role.model.js]")]
end

subgraph group_support["Customer support"]
  node_chat_ui["Chat interfaces<br/>[ChatWidget.tsx]"]
  node_socket_chat["Realtime chat<br/>[chat.handler.js]"]
  node_conversation_data[("Conversations")]
  node_message_data[("Messages<br/>[message.model.js]")]
  node_gemini["Gemini AI<br/>[gemini.helper.js]"]
end

subgraph group_identity["Identity and content"]
  node_identity_ui["Customer identity<br/>[useAuthStore.ts]"]
  node_identity_api["Authentication API<br/>[auth.controller.js]"]
  node_user_data[("User accounts<br/>[user.model.js]")]
  node_publishing["Blogs and categories<br/>[blog.controller.js]"]
end

node_shopper(("Shopper"))
node_admin_user(("Admin staff"))
node_cloudinary["Cloudinary"]
node_momo_service["MoMo"]
node_vnpay_service["VNPAY"]

node_shopper -->|"uses"| node_client_app
node_client_app -->|"navigates"| node_catalog
node_catalog -->|"requests catalog"| node_client_api
node_cart -->|"manages cart"| node_client_api
node_checkout -->|"places order"| node_client_api
node_orders_ui -->|"tracks orders"| node_client_api
node_reviews_ui -->|"submits review"| node_client_api
node_client_api -->|"dispatches"| node_order_logic
node_order_logic -->|"checks stock"| node_product_data
node_order_logic -->|"reads cart"| node_cart_data
node_order_logic -->|"creates and updates"| node_order_data
node_order_logic -.->|"creates payment"| node_payments
node_order_logic -.->|"creates and verifies"| node_payment_services
node_order_logic -->|"sends confirmation"| node_mailer
node_client_api -->|"dispatches"| node_review_logic
node_review_logic -->|"validates and updates rating"| node_product_data
node_review_logic -->|"validates delivery"| node_order_data
node_review_logic -->|"creates and queries"| node_review_data
node_admin_user -->|"manages"| node_admin_ui
node_admin_ui -->|"calls"| node_admin_api
node_admin_api -->|"dispatches"| node_admin_ops
node_admin_ops -->|"manages products"| node_product_data
node_admin_ops -->|"manages orders"| node_order_data
node_admin_ops -->|"checks roles"| node_role_data
node_identity_ui -->|"authenticates"| node_identity_api
node_identity_api -->|"reads and writes"| node_user_data
node_identity_ui -->|"loads user detail"| node_client_api
node_client_api -->|"serves articles"| node_publishing
node_shopper -->|"requests support"| node_chat_ui
node_chat_ui -->|"exchanges messages"| node_socket_chat
node_socket_chat -->|"loads and saves"| node_conversation_data
node_socket_chat -->|"stores messages"| node_message_data
node_socket_chat -.->|"requests bot reply"| node_gemini
node_socket_chat -->|"emits updates"| node_chat_ui
node_admin_user -->|"handles live chats"| node_socket_chat
node_admin_ops -.->|"uploads media"| node_cloudinary
node_order_logic -.->|"requests payment"| node_momo_service
node_order_logic -.->|"requests payment"| node_vnpay_service

click node_client_app "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/App.tsx"
click node_catalog "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/pages/client/ProductListPage.tsx"
click node_cart "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/pages/client/CartPage.tsx"
click node_checkout "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/pages/client/CheckoutPage.tsx"
click node_orders_ui "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/pages/client/OrdersPage.tsx"
click node_reviews_ui "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/pages/client/OrderReviewPage.tsx"
click node_client_api "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/client/routes/index.route.js"
click node_order_logic "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/client/controllers/order.controller.js"
click node_product_data "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/product.model.js"
click node_order_data "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/order.model.js"
click node_cart_data "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/cart.model.js"
click node_payments "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/helpers/momo.js"
click node_payment_services "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/helpers/vnpay.js"
click node_mailer "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/helpers/mailer.js"
click node_review_logic "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/client/controllers/review.controller.js"
click node_review_data "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/review.model.js"
click node_admin_ui "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/routes/adminRoute.tsx"
click node_admin_api "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/admin/routes/index.route.js"
click node_admin_ops "https://github.com/thanhdai2005/dac-san-ba-mien/tree/master/backend/api/v1/admin/controllers"
click node_role_data "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/role.model.js"
click node_identity_ui "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/stores/useAuthStore.ts"
click node_identity_api "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/client/controllers/auth.controller.js"
click node_user_data "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/user.model.js"
click node_publishing "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/client/controllers/blog.controller.js"
click node_chat_ui "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/components/client/ChatWidget.tsx"
click node_socket_chat "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/socket/chat.handler.js"
click node_conversation_data "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/conversation.model.js"
click node_message_data "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/message.model.js"
click node_gemini "https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/helpers/gemini.helper.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_client_app,node_catalog,node_cart,node_checkout,node_orders_ui,node_reviews_ui toneBlue
class node_client_api,node_order_logic,node_product_data,node_order_data,node_cart_data,node_payments,node_payment_services,node_mailer,node_review_logic,node_review_data toneAmber
class node_admin_ui,node_admin_api,node_admin_ops,node_role_data toneMint
class node_chat_ui,node_socket_chat,node_conversation_data,node_message_data,node_gemini toneRose
class node_identity_ui,node_identity_api,node_user_data,node_publishing,node_shopper,node_admin_user,node_cloudinary,node_momo_service,node_vnpay_service toneIndigo
```

## Components

### Customer experience

- [Client app](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Product catalog](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/pages/client/ProductListPage.tsx): `frontend/src/pages/client/ProductListPage.tsx`
- [Shopping cart](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/pages/client/CartPage.tsx): `frontend/src/pages/client/CartPage.tsx`
- [Checkout](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/pages/client/CheckoutPage.tsx): `frontend/src/pages/client/CheckoutPage.tsx`
- [Order tracking](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/pages/client/OrdersPage.tsx): `frontend/src/pages/client/OrdersPage.tsx`
- [Product reviews](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/pages/client/OrderReviewPage.tsx): `frontend/src/pages/client/OrderReviewPage.tsx`

### Commerce services

- [Client API](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/client/routes/index.route.js): `backend/api/v1/client/routes/index.route.js`
- [Order processing](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/client/controllers/order.controller.js): `backend/api/v1/client/controllers/order.controller.js`
- [Products](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/product.model.js): `backend/models/product.model.js`
- [Orders](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/order.model.js): `backend/models/order.model.js`
- [Cart](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/cart.model.js): `backend/models/cart.model.js`
- [Payment gateways](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/helpers/momo.js): `backend/helpers/momo.js`
- [VNPAY integration](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/helpers/vnpay.js): `backend/helpers/vnpay.js`
- [Order email](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/helpers/mailer.js): `backend/helpers/mailer.js`
- [Review processing](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/client/controllers/review.controller.js): `backend/api/v1/client/controllers/review.controller.js`
- [Reviews](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/review.model.js): `backend/models/review.model.js`

### Administration

- [Admin console](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/routes/adminRoute.tsx): `frontend/src/routes/adminRoute.tsx`
- [Admin API](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/admin/routes/index.route.js): `backend/api/v1/admin/routes/index.route.js`
- [Catalog and order management](https://github.com/thanhdai2005/dac-san-ba-mien/tree/master/backend/api/v1/admin/controllers): `backend/api/v1/admin/controllers`
- [Roles and permissions](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/role.model.js): `backend/models/role.model.js`

### Customer support

- [Chat interfaces](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/components/client/ChatWidget.tsx): `frontend/src/components/client/ChatWidget.tsx`
- [Realtime chat](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/socket/chat.handler.js): `backend/socket/chat.handler.js`
- [Conversations](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/conversation.model.js): `backend/models/conversation.model.js`
- [Messages](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/message.model.js): `backend/models/message.model.js`
- [Gemini AI](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/helpers/gemini.helper.js): `backend/helpers/gemini.helper.js`

### Identity and content

- [Customer identity](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/frontend/src/stores/useAuthStore.ts): `frontend/src/stores/useAuthStore.ts`
- [Authentication API](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/client/controllers/auth.controller.js): `backend/api/v1/client/controllers/auth.controller.js`
- [User accounts](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/models/user.model.js): `backend/models/user.model.js`
- [Blogs and categories](https://github.com/thanhdai2005/dac-san-ba-mien/blob/master/backend/api/v1/client/controllers/blog.controller.js): `backend/api/v1/client/controllers/blog.controller.js`

### Other components

- **Shopper**
- **Admin staff**
- **Cloudinary**
- **MoMo**
- **VNPAY**

## Connections

- Shopper → Client app: uses
- Client app → Product catalog: navigates
- Product catalog → Client API: requests catalog
- Shopping cart → Client API: manages cart
- Checkout → Client API: places order
- Order tracking → Client API: tracks orders
- Product reviews → Client API: submits review
- Client API → Order processing: dispatches
- Order processing → Products: checks stock
- Order processing → Cart: reads cart
- Order processing → Orders: creates and updates
- Order processing → Payment gateways: creates payment
- Order processing → VNPAY integration: creates and verifies
- Order processing → Order email: sends confirmation
- Client API → Review processing: dispatches
- Review processing → Products: validates and updates rating
- Review processing → Orders: validates delivery
- Review processing → Reviews: creates and queries
- Admin staff → Admin console: manages
- Admin console → Admin API: calls
- Admin API → Catalog and order management: dispatches
- Catalog and order management → Products: manages products
- Catalog and order management → Orders: manages orders
- Catalog and order management → Roles and permissions: checks roles
- Customer identity → Authentication API: authenticates
- Authentication API → User accounts: reads and writes
- Customer identity → Client API: loads user detail
- Client API → Blogs and categories: serves articles
- Shopper → Chat interfaces: requests support
- Chat interfaces → Realtime chat: exchanges messages
- Realtime chat → Conversations: loads and saves
- Realtime chat → Messages: stores messages
- Realtime chat → Gemini AI: requests bot reply
- Realtime chat → Chat interfaces: emits updates
- Admin staff → Realtime chat: handles live chats
- Catalog and order management → Cloudinary: uploads media
- Order processing → MoMo: requests payment
- Order processing → VNPAY: requests payment
