# truong-hoang112/website architecture

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

- Interactive diagram: https://gitdiagram.com/truong-hoang112/website
- Repository: https://github.com/truong-hoang112/website

## Overview

AnhTraiStore is a Node.js/Express technology-commerce site with customer shopping, administration, realtime support, and an AI shopping assistant. The main customer journey runs from product discovery through cart and coupon handling to order placement and tracking; administrators manage the catalog and order lifecycle. The graph reflects the documented capabilities and sampled entry-point wiring. Individual route internals and some optional integration calls were not sampled, so uncertain links are omitted.

Main entry points: [`src/routes/index.js`](https://github.com/truong-hoang112/website/blob/main/src/routes/index.js) (Route registry), [`src/config/database.js`](https://github.com/truong-hoang112/website/blob/main/src/config/database.js) (MySQL store), [`public/js/app.js`](https://github.com/truong-hoang112/website/blob/main/public/js/app.js) (Store interface), [`src/routes/admin.js`](https://github.com/truong-hoang112/website/blob/main/src/routes/admin.js) (Admin operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_server["HTTP server<br/>[server.js]"]
  node_app["Express app<br/>[app.js]"]
  node_route_registry["Route registry<br/>[index.js]"]
  node_pages["Page routes<br/>[pages.js]"]
  node_frontend["Store interface<br/>[app.js]"]
  node_auth["Account and profile<br/>[auth.js]"]
end

subgraph group_shop["Shopping and orders"]
  node_products["Product catalog<br/>[products.js]"]
  node_cart["Cart and wishlist<br/>[cart.js]"]
  node_wishlist["Wishlist<br/>[wishlist.js]"]
  node_coupons["Coupons<br/>[coupons.js]"]
  node_orders["Orders and checkout<br/>[orders.js]"]
end

subgraph group_admin["Store administration"]
  node_admin_routes["Admin operations<br/>[admin.js]"]
  node_admin_views["Admin screens"]
end

subgraph group_support["Support and AI"]
  node_messages["Support messages<br/>[messages.js]"]
  node_socket["Realtime chat<br/>[chat-socket.js]"]
  node_ai_route["AI chat endpoint<br/>[ai-chat.js]"]
  node_ai_service["Store AI<br/>[store-ai.js]"]
end

subgraph group_infra["Data and integrations"]
  node_mysql[("MySQL store<br/>[database.js]")]
  node_schema["Store schema<br/>[anhtraistore.sql]"]
  node_gemini{{"Gemini API"}}
  node_cloud{{"Cloudinary"}}
  node_storage["Image storage service<br/>[cloud-storage.js]"]
  node_mail["SMTP mail<br/>[mail.js]"]
end

node_customer(("Customer"))
node_administrator(("Administrator"))
node_browser(("Web browser"))

node_customer -->|"uses"| node_browser
node_administrator -->|"uses"| node_browser
node_browser -->|"HTTP requests"| node_app
node_server -->|"creates"| node_app
node_app -->|"registers routes"| node_route_registry
node_app -->|"mounts pages"| node_pages
node_route_registry -->|"dispatches"| node_auth
node_route_registry -->|"dispatches"| node_products
node_route_registry -->|"dispatches"| node_cart
node_route_registry -->|"dispatches"| node_orders
node_route_registry -->|"dispatches"| node_wishlist
node_route_registry -->|"dispatches"| node_coupons
node_route_registry -->|"dispatches"| node_admin_routes
node_route_registry -->|"dispatches"| node_messages
node_route_registry -->|"dispatches"| node_ai_route
node_pages -->|"serves pages"| node_browser
node_browser -->|"runs"| node_frontend
node_frontend -->|"searches products"| node_products
node_frontend -->|"updates cart"| node_cart
node_frontend -->|"updates wishlist"| node_wishlist
node_auth -->|"reads and writes"| node_mysql
node_auth -.->|"sends OTP"| node_mail
node_products -->|"reads catalog"| node_mysql
node_cart -->|"reads and writes"| node_mysql
node_wishlist -->|"reads and writes"| node_mysql
node_coupons -->|"checks coupons"| node_mysql
node_orders -->|"creates and updates"| node_mysql
node_admin_routes -->|"manages store data"| node_mysql
node_admin_routes -.->|"uploads images"| node_storage
node_admin_routes -->|"serves screens"| node_admin_views
node_storage -.->|"uploads and deletes"| node_cloud
node_messages -->|"stores conversations"| node_mysql
node_server -->|"configures chat"| node_socket
node_socket -->|"checks conversation access"| node_mysql
node_socket -->|"realtime events"| node_browser
node_ai_route -->|"requests assistance"| node_ai_service
node_ai_service -->|"queries store data"| node_mysql
node_ai_service -.->|"calls model"| node_gemini
node_schema -->|"defines schema"| node_mysql

click node_server "https://github.com/truong-hoang112/website/blob/main/server.js"
click node_app "https://github.com/truong-hoang112/website/blob/main/src/app.js"
click node_route_registry "https://github.com/truong-hoang112/website/blob/main/src/routes/index.js"
click node_pages "https://github.com/truong-hoang112/website/blob/main/src/routes/pages.js"
click node_frontend "https://github.com/truong-hoang112/website/blob/main/public/js/app.js"
click node_auth "https://github.com/truong-hoang112/website/blob/main/src/routes/auth.js"
click node_products "https://github.com/truong-hoang112/website/blob/main/src/routes/products.js"
click node_cart "https://github.com/truong-hoang112/website/blob/main/src/routes/cart.js"
click node_wishlist "https://github.com/truong-hoang112/website/blob/main/src/routes/wishlist.js"
click node_coupons "https://github.com/truong-hoang112/website/blob/main/src/routes/coupons.js"
click node_orders "https://github.com/truong-hoang112/website/blob/main/src/routes/orders.js"
click node_admin_routes "https://github.com/truong-hoang112/website/blob/main/src/routes/admin.js"
click node_admin_views "https://github.com/truong-hoang112/website/tree/main/views/admin"
click node_messages "https://github.com/truong-hoang112/website/blob/main/src/routes/messages.js"
click node_socket "https://github.com/truong-hoang112/website/blob/main/src/realtime/chat-socket.js"
click node_ai_route "https://github.com/truong-hoang112/website/blob/main/src/routes/ai-chat.js"
click node_ai_service "https://github.com/truong-hoang112/website/blob/main/src/services/store-ai.js"
click node_mysql "https://github.com/truong-hoang112/website/blob/main/src/config/database.js"
click node_schema "https://github.com/truong-hoang112/website/blob/main/database/anhtraistore.sql"
click node_storage "https://github.com/truong-hoang112/website/blob/main/src/services/cloud-storage.js"
click node_mail "https://github.com/truong-hoang112/website/blob/main/src/config/mail.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_server,node_app,node_route_registry,node_pages,node_frontend,node_auth,node_browser toneBlue
class node_products,node_cart,node_wishlist,node_coupons,node_orders toneAmber
class node_admin_routes,node_admin_views toneMint
class node_messages,node_socket,node_ai_route,node_ai_service toneRose
class node_mysql,node_schema,node_gemini,node_cloud,node_storage,node_mail,node_customer,node_administrator toneIndigo
```

## Components

### Web application

- [HTTP server](https://github.com/truong-hoang112/website/blob/main/server.js): `server.js`
- [Express app](https://github.com/truong-hoang112/website/blob/main/src/app.js): `src/app.js`
- [Route registry](https://github.com/truong-hoang112/website/blob/main/src/routes/index.js): `src/routes/index.js`
- [Page routes](https://github.com/truong-hoang112/website/blob/main/src/routes/pages.js): `src/routes/pages.js`
- [Store interface](https://github.com/truong-hoang112/website/blob/main/public/js/app.js): `public/js/app.js`
- [Account and profile](https://github.com/truong-hoang112/website/blob/main/src/routes/auth.js): `src/routes/auth.js`

### Shopping and orders

- [Product catalog](https://github.com/truong-hoang112/website/blob/main/src/routes/products.js): `src/routes/products.js`
- [Cart and wishlist](https://github.com/truong-hoang112/website/blob/main/src/routes/cart.js): `src/routes/cart.js`
- [Wishlist](https://github.com/truong-hoang112/website/blob/main/src/routes/wishlist.js): `src/routes/wishlist.js`
- [Coupons](https://github.com/truong-hoang112/website/blob/main/src/routes/coupons.js): `src/routes/coupons.js`
- [Orders and checkout](https://github.com/truong-hoang112/website/blob/main/src/routes/orders.js): `src/routes/orders.js`

### Store administration

- [Admin operations](https://github.com/truong-hoang112/website/blob/main/src/routes/admin.js): `src/routes/admin.js`
- [Admin screens](https://github.com/truong-hoang112/website/tree/main/views/admin): `views/admin`

### Support and AI

- [Support messages](https://github.com/truong-hoang112/website/blob/main/src/routes/messages.js): `src/routes/messages.js`
- [Realtime chat](https://github.com/truong-hoang112/website/blob/main/src/realtime/chat-socket.js): `src/realtime/chat-socket.js`
- [AI chat endpoint](https://github.com/truong-hoang112/website/blob/main/src/routes/ai-chat.js): `src/routes/ai-chat.js`
- [Store AI](https://github.com/truong-hoang112/website/blob/main/src/services/store-ai.js): `src/services/store-ai.js`

### Data and integrations

- [MySQL store](https://github.com/truong-hoang112/website/blob/main/src/config/database.js): `src/config/database.js`
- [Store schema](https://github.com/truong-hoang112/website/blob/main/database/anhtraistore.sql): `database/anhtraistore.sql`
- **Gemini API**
- **Cloudinary**
- [Image storage service](https://github.com/truong-hoang112/website/blob/main/src/services/cloud-storage.js): `src/services/cloud-storage.js`
- [SMTP mail](https://github.com/truong-hoang112/website/blob/main/src/config/mail.js): `src/config/mail.js`

### Other components

- **Customer**
- **Administrator**
- **Web browser**

## Connections

- Customer → Web browser: uses
- Administrator → Web browser: uses
- Web browser → Express app: HTTP requests
- HTTP server → Express app: creates
- Express app → Route registry: registers routes
- Express app → Page routes: mounts pages
- Route registry → Account and profile: dispatches
- Route registry → Product catalog: dispatches
- Route registry → Cart and wishlist: dispatches
- Route registry → Orders and checkout: dispatches
- Route registry → Wishlist: dispatches
- Route registry → Coupons: dispatches
- Route registry → Admin operations: dispatches
- Route registry → Support messages: dispatches
- Route registry → AI chat endpoint: dispatches
- Page routes → Web browser: serves pages
- Web browser → Store interface: runs
- Store interface → Product catalog: searches products
- Store interface → Cart and wishlist: updates cart
- Store interface → Wishlist: updates wishlist
- Account and profile → MySQL store: reads and writes
- Account and profile → SMTP mail: sends OTP
- Product catalog → MySQL store: reads catalog
- Cart and wishlist → MySQL store: reads and writes
- Wishlist → MySQL store: reads and writes
- Coupons → MySQL store: checks coupons
- Orders and checkout → MySQL store: creates and updates
- Admin operations → MySQL store: manages store data
- Admin operations → Image storage service: uploads images
- Admin operations → Admin screens: serves screens
- Image storage service → Cloudinary: uploads and deletes
- Support messages → MySQL store: stores conversations
- HTTP server → Realtime chat: configures chat
- Realtime chat → MySQL store: checks conversation access
- Realtime chat → Web browser: realtime events
- AI chat endpoint → Store AI: requests assistance
- Store AI → MySQL store: queries store data
- Store AI → Gemini API: calls model
- Store schema → MySQL store: defines schema
