# nguyen-trung-tien/tientech-shop architecture

> Architecture diagram of the GitHub repository nguyen-trung-tien/tientech-shop, 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/nguyen-trung-tien/tientech-shop
- Repository: https://github.com/nguyen-trung-tien/tientech-shop

## Overview

TIENTECH Shop is an AI-enabled e-commerce application with customer shopping and checkout, order and payment handling, and administrative operations. The graph combines documented architecture and capabilities with paths from the tree; sampled source confirms review service persistence, review-image uploads, address API use, and variant API use, but does not expose all subsystem wiring.

Main entry points: [`BackEnd/src/controllers/OrderController.js`](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/controllers/OrderController.js) (Request controllers), [`BackEnd/src/services/order/OrderService.js`](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/order/OrderService.js) (Cart and order services), [`FrontEnd/src/utils/axiosClient.jsx`](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/utils/axiosClient.jsx) (Frontend API), [`BackEnd/src/models/index.js`](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/models/index.js) (Commerce models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Customer storefront"]
  node_store_ui["Storefront pages<br/>[UserRoutes.jsx]"]
  node_catalog_ui["Product discovery"]
  node_cart_ui["Cart and checkout<br/>[CheckoutPage.jsx]"]
  node_orders_ui["Orders and reviews<br/>[OrderHistory.jsx]"]
end

subgraph group_commerce["Commerce backend"]
  node_routes["API routes<br/>[index.js]"]
  node_controllers["Request controllers<br/>[OrderController.js]"]
  node_catalog_service["Catalog services<br/>[ProductService.js]"]
  node_order_service["Cart and order services<br/>[OrderService.js]"]
  node_order_cases["Order use cases"]
  node_review_service["Review services<br/>[ReviewService.js]"]
  node_data_models["Commerce models<br/>[index.js]"]
  node_payment_service["Payment service<br/>[PaymentService.js]"]
  node_payment_gateway["VNPay and PayPal"]
end

subgraph group_admin_ai["Admin and AI"]
  node_admin_ui["Admin console<br/>[Dashboard.jsx]"]
  node_admin_service["Admin services<br/>[AdminService.js]"]
  node_ai_features["AI capabilities"]
  node_ai_providers["AI providers<br/>[gemini.js]"]
end

subgraph group_platform["Application platform"]
  node_api_client["Frontend API<br/>[axiosClient.jsx]"]
  node_express_app["Express application<br/>[app.js]"]
  node_auth["Authentication<br/>[authMiddleware.js]"]
  node_mysql[("MySQL")]
  node_redis[("Redis cache<br/>[redis.js]")]
  node_media_storage["Cloudinary"]
end

node_customer(("Customer"))
node_admin(("Administrator"))

node_customer -->|"browses"| node_store_ui
node_store_ui -->|"discovers products"| node_catalog_ui
node_customer -->|"shops"| node_cart_ui
node_customer -->|"manages purchases"| node_orders_ui
node_catalog_ui -->|"requests catalog"| node_api_client
node_cart_ui -->|"requests checkout"| node_api_client
node_orders_ui -->|"requests orders"| node_api_client
node_api_client -->|"sends requests"| node_express_app
node_express_app -->|"dispatches"| node_routes
node_routes -->|"checks access"| node_auth
node_routes -->|"dispatches"| node_controllers
node_controllers -->|"invokes"| node_catalog_service
node_controllers -->|"invokes"| node_order_service
node_controllers -->|"invokes"| node_review_service
node_order_service -->|"uses"| node_order_cases
node_catalog_service -->|"reads and writes"| node_data_models
node_order_service -->|"reads and writes"| node_data_models
node_review_service -->|"reads and writes"| node_data_models
node_data_models -->|"persists data"| node_mysql
node_order_service -->|"coordinates payment"| node_payment_service
node_payment_service -.->|"initiates payment"| node_payment_gateway
node_admin -->|"manages shop"| node_admin_ui
node_admin_ui -->|"requests operations"| node_api_client
node_controllers -->|"invokes"| node_admin_service
node_controllers -->|"invokes"| node_ai_features
node_ai_features -.->|"uses models"| node_ai_providers
node_review_service -->|"uploads review images"| node_media_storage
node_order_service -.->|"uses cache"| node_redis

click node_store_ui "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/routes/UserRoutes.jsx"
click node_catalog_ui "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/pages/ProductListPage/ProductListPage.jsx"
click node_cart_ui "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/pages/CheckoutPage/CheckoutPage.jsx"
click node_orders_ui "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/pages/OrdersHistory/OrderHistory.jsx"
click node_api_client "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/utils/axiosClient.jsx"
click node_express_app "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/app.js"
click node_routes "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/routes/index.js"
click node_auth "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/middleware/authMiddleware.js"
click node_controllers "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/controllers/OrderController.js"
click node_catalog_service "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/product/ProductService.js"
click node_order_service "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/order/OrderService.js"
click node_order_cases "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/order/use-cases/OrderCreationUseCase.js"
click node_review_service "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/marketing/ReviewService.js"
click node_data_models "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/models/index.js"
click node_payment_service "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/order/PaymentService.js"
click node_admin_ui "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/Admin/pages/Dashboard/Dashboard.jsx"
click node_admin_service "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/common/AdminService.js"
click node_ai_features "https://github.com/nguyen-trung-tien/tientech-shop/tree/main/BackEnd/src/services/ai"
click node_ai_providers "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/config/gemini.js"
click node_redis "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/config/redis.js"
click node_media_storage "https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/config/cloudinaryConfig.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_store_ui,node_catalog_ui,node_cart_ui,node_orders_ui toneBlue
class node_routes,node_controllers,node_catalog_service,node_order_service,node_order_cases,node_review_service,node_data_models,node_payment_service,node_payment_gateway toneAmber
class node_admin_ui,node_admin_service,node_ai_features,node_ai_providers toneMint
class node_api_client,node_express_app,node_auth,node_mysql,node_redis,node_media_storage toneRose
class node_customer,node_admin toneIndigo
```

## Components

### Customer storefront

- [Storefront pages](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/routes/UserRoutes.jsx): `FrontEnd/src/routes/UserRoutes.jsx`
- [Product discovery](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/pages/ProductListPage/ProductListPage.jsx): `FrontEnd/src/pages/ProductListPage/ProductListPage.jsx`
- [Cart and checkout](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/pages/CheckoutPage/CheckoutPage.jsx): `FrontEnd/src/pages/CheckoutPage/CheckoutPage.jsx`
- [Orders and reviews](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/pages/OrdersHistory/OrderHistory.jsx): `FrontEnd/src/pages/OrdersHistory/OrderHistory.jsx`

### Commerce backend

- [API routes](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/routes/index.js): `BackEnd/src/routes/index.js`
- [Request controllers](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/controllers/OrderController.js): `BackEnd/src/controllers/OrderController.js`
- [Catalog services](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/product/ProductService.js): `BackEnd/src/services/product/ProductService.js`
- [Cart and order services](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/order/OrderService.js): `BackEnd/src/services/order/OrderService.js`
- [Order use cases](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/order/use-cases/OrderCreationUseCase.js): `BackEnd/src/services/order/use-cases/OrderCreationUseCase.js`
- [Review services](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/marketing/ReviewService.js): `BackEnd/src/services/marketing/ReviewService.js`
- [Commerce models](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/models/index.js): `BackEnd/src/models/index.js`
- [Payment service](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/order/PaymentService.js): `BackEnd/src/services/order/PaymentService.js`
- **VNPay and PayPal**

### Admin and AI

- [Admin console](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/Admin/pages/Dashboard/Dashboard.jsx): `FrontEnd/src/Admin/pages/Dashboard/Dashboard.jsx`
- [Admin services](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/services/common/AdminService.js): `BackEnd/src/services/common/AdminService.js`
- [AI capabilities](https://github.com/nguyen-trung-tien/tientech-shop/tree/main/BackEnd/src/services/ai): `BackEnd/src/services/ai`
- [AI providers](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/config/gemini.js): `BackEnd/src/config/gemini.js`

### Application platform

- [Frontend API](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/FrontEnd/src/utils/axiosClient.jsx): `FrontEnd/src/utils/axiosClient.jsx`
- [Express application](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/app.js): `BackEnd/src/app.js`
- [Authentication](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/middleware/authMiddleware.js): `BackEnd/src/middleware/authMiddleware.js`
- **MySQL**
- [Redis cache](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/config/redis.js): `BackEnd/src/config/redis.js`
- [Cloudinary](https://github.com/nguyen-trung-tien/tientech-shop/blob/main/BackEnd/src/config/cloudinaryConfig.js): `BackEnd/src/config/cloudinaryConfig.js`

### Other components

- **Customer**
- **Administrator**

## Connections

- Customer → Storefront pages: browses
- Storefront pages → Product discovery: discovers products
- Customer → Cart and checkout: shops
- Customer → Orders and reviews: manages purchases
- Product discovery → Frontend API: requests catalog
- Cart and checkout → Frontend API: requests checkout
- Orders and reviews → Frontend API: requests orders
- Frontend API → Express application: sends requests
- Express application → API routes: dispatches
- API routes → Authentication: checks access
- API routes → Request controllers: dispatches
- Request controllers → Catalog services: invokes
- Request controllers → Cart and order services: invokes
- Request controllers → Review services: invokes
- Cart and order services → Order use cases: uses
- Catalog services → Commerce models: reads and writes
- Cart and order services → Commerce models: reads and writes
- Review services → Commerce models: reads and writes
- Commerce models → MySQL: persists data
- Cart and order services → Payment service: coordinates payment
- Payment service → VNPay and PayPal: initiates payment
- Administrator → Admin console: manages shop
- Admin console → Frontend API: requests operations
- Request controllers → Admin services: invokes
- Request controllers → AI capabilities: invokes
- AI capabilities → AI providers: uses models
- Review services → Cloudinary: uploads review images
- Cart and order services → Redis cache: uses cache
