# hgnhat1511/gift-recommender-system architecture

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

- Interactive diagram: https://gitdiagram.com/hgnhat1511/gift-recommender-system
- Repository: https://github.com/hgnhat1511/gift-recommender-system

## Overview

Giftly is a gift-commerce storefront with an Express API. Shoppers discover catalog items or use explainable Gift Finder matching, manage a guest or account cart, then sign in for COD checkout and order follow-up. The backend also supports account services and admin operations for catalog, inventory, orders, coupons, returns, and reviews. The graph follows documented API and product flows; unsampled implementations are represented by their known source paths, while uncertain internal links are omitted.

Main entry points: [`core-frontend/src/main.jsx`](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/main.jsx) (Routes and home), [`core-backend/config/db.js`](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/config/db.js) (MySQL), [`core-frontend/src/lib/api.js`](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/lib/api.js) (API client), [`core-backend/server.js`](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/server.js) (Express API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_frontend["Routes and home<br/>[main.jsx]"]
  node_catalog_ui["Catalog and finder<br/>[CatalogPages.jsx]"]
  node_auth_ui["Sign-in pages<br/>[LoginPage.jsx]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_commerce["Commerce"]
  node_commerce_ui["Cart and orders UI<br/>[CommercePages.jsx]"]
  node_account_ui["Account pages<br/>[AccountPages.jsx]"]
  node_guest_cart["Guest cart<br/>[guestCart.js]"]
  node_cart_controller["Cart operations<br/>[cartController.js]"]
  node_account_controller["Account services"]
  node_order_controller["Checkout and orders<br/>[orderController.js]"]
  node_return_controller["Returns"]
  node_review_controller["Reviews"]
end

subgraph group_backend["API and identity"]
  node_api_server["Express API<br/>[server.js]"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_auth_controller["Authentication<br/>[authController.js]"]
  node_auth_middleware["JWT authorization<br/>[authMiddleware.js]"]
  node_catalog_routes["Catalog routes<br/>[catalogRoutes.js]"]
  node_catalog_controller["Catalog and events"]
  node_order_routes["Order routes<br/>[orderRoutes.js]"]
end

subgraph group_operations["Store operations"]
  node_admin_ui["Admin pages<br/>[AdminPages.jsx]"]
  node_coupon_ui["Coupon admin"]
  node_admin_controller["Admin operations<br/>[adminController.js]"]
end

subgraph group_persistence["Persistence and matching"]
  node_user_model["User access<br/>[userModel.js]"]
  node_recommendations["Gift matching"]
  node_mysql[("MySQL<br/>[db.js]")]
  node_redis[("Redis<br/>[redis.js]")]
end

node_shopper(("Shopper"))

node_shopper -->|"browses"| node_frontend
node_frontend -->|"routes to"| node_catalog_ui
node_frontend -->|"routes to"| node_commerce_ui
node_frontend -->|"routes to"| node_account_ui
node_frontend -->|"routes to"| node_auth_ui
node_frontend -->|"routes to"| node_admin_ui
node_frontend -->|"routes to"| node_coupon_ui
node_catalog_ui -->|"requests data"| node_api_client
node_commerce_ui -->|"requests commerce"| node_api_client
node_account_ui -->|"requests account"| node_api_client
node_auth_ui -->|"authenticates via"| node_api_client
node_admin_ui -->|"manages via"| node_api_client
node_coupon_ui -->|"manages via"| node_api_client
node_catalog_ui -->|"updates"| node_guest_cart
node_commerce_ui -->|"reads and updates"| node_guest_cart
node_auth_ui -->|"merges after login"| node_guest_cart
node_api_client -->|"sends API requests"| node_api_server
node_api_server -->|"mounts"| node_auth_routes
node_api_server -->|"mounts"| node_catalog_routes
node_api_server -->|"mounts"| node_order_routes
node_api_server -->|"connects and checks"| node_redis
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"uses"| node_user_model
node_auth_middleware -->|"loads user"| node_user_model
node_catalog_routes -->|"dispatches"| node_catalog_controller
node_catalog_routes -->|"dispatches reviews"| node_review_controller
node_catalog_controller -->|"requests matches"| node_recommendations
node_catalog_controller -->|"reads and records"| node_mysql
node_recommendations -->|"queries catalog"| node_mysql
node_order_routes -->|"dispatches"| node_order_controller
node_order_routes -->|"dispatches returns"| node_return_controller
node_order_controller -->|"transacts orders"| node_mysql
node_review_controller -->|"reads and writes"| node_mysql
node_admin_controller -->|"manages records"| node_mysql
node_admin_controller -->|"uses order helpers"| node_order_controller
node_cart_controller -->|"stores cart rows"| node_mysql
node_account_controller -->|"stores account data"| node_mysql
node_return_controller -->|"stores return requests"| node_mysql

click node_frontend "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/main.jsx"
click node_catalog_ui "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/pages/store/CatalogPages.jsx"
click node_commerce_ui "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/pages/store/CommercePages.jsx"
click node_account_ui "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/pages/account/AccountPages.jsx"
click node_auth_ui "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/pages/auth/LoginPage.jsx"
click node_admin_ui "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/pages/admin/AdminPages.jsx"
click node_coupon_ui "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/pages/admin/CouponAdminPage.jsx"
click node_api_client "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/lib/api.js"
click node_guest_cart "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/lib/guestCart.js"
click node_api_server "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/server.js"
click node_auth_routes "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/routes/authRoutes.js"
click node_auth_controller "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/authController.js"
click node_auth_middleware "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/middleware/authMiddleware.js"
click node_user_model "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/models/userModel.js"
click node_catalog_routes "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/routes/catalogRoutes.js"
click node_catalog_controller "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/catalogController.js"
click node_recommendations "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/services/recommendationService.js"
click node_cart_controller "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/cartController.js"
click node_account_controller "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/accountController.js"
click node_order_routes "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/routes/orderRoutes.js"
click node_order_controller "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/orderController.js"
click node_return_controller "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/returnController.js"
click node_review_controller "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/reviewController.js"
click node_admin_controller "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/adminController.js"
click node_mysql "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/config/db.js"
click node_redis "https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/config/redis.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_frontend,node_catalog_ui,node_auth_ui,node_api_client toneBlue
class node_commerce_ui,node_account_ui,node_guest_cart,node_cart_controller,node_account_controller,node_order_controller,node_return_controller,node_review_controller toneAmber
class node_api_server,node_auth_routes,node_auth_controller,node_auth_middleware,node_catalog_routes,node_catalog_controller,node_order_routes toneMint
class node_admin_ui,node_coupon_ui,node_admin_controller toneRose
class node_user_model,node_recommendations,node_mysql,node_redis,node_shopper toneIndigo
```

## Components

### Storefront

- [Routes and home](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/main.jsx): `core-frontend/src/main.jsx`
- [Catalog and finder](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/pages/store/CatalogPages.jsx): `core-frontend/src/pages/store/CatalogPages.jsx`
- [Sign-in pages](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/pages/auth/LoginPage.jsx): `core-frontend/src/pages/auth/LoginPage.jsx`
- [API client](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/lib/api.js): `core-frontend/src/lib/api.js`

### Commerce

- [Cart and orders UI](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/pages/store/CommercePages.jsx): `core-frontend/src/pages/store/CommercePages.jsx`
- [Account pages](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/pages/account/AccountPages.jsx): `core-frontend/src/pages/account/AccountPages.jsx`
- [Guest cart](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/lib/guestCart.js): `core-frontend/src/lib/guestCart.js`
- [Cart operations](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/cartController.js): `core-backend/controllers/cartController.js`
- [Account services](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/accountController.js): `core-backend/controllers/accountController.js`
- [Checkout and orders](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/orderController.js): `core-backend/controllers/orderController.js`
- [Returns](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/returnController.js): `core-backend/controllers/returnController.js`
- [Reviews](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/reviewController.js): `core-backend/controllers/reviewController.js`

### API and identity

- [Express API](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/server.js): `core-backend/server.js`
- [Auth routes](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/routes/authRoutes.js): `core-backend/routes/authRoutes.js`
- [Authentication](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/authController.js): `core-backend/controllers/authController.js`
- [JWT authorization](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/middleware/authMiddleware.js): `core-backend/middleware/authMiddleware.js`
- [Catalog routes](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/routes/catalogRoutes.js): `core-backend/routes/catalogRoutes.js`
- [Catalog and events](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/catalogController.js): `core-backend/controllers/catalogController.js`
- [Order routes](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/routes/orderRoutes.js): `core-backend/routes/orderRoutes.js`

### Store operations

- [Admin pages](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/pages/admin/AdminPages.jsx): `core-frontend/src/pages/admin/AdminPages.jsx`
- [Coupon admin](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-frontend/src/pages/admin/CouponAdminPage.jsx): `core-frontend/src/pages/admin/CouponAdminPage.jsx`
- [Admin operations](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/controllers/adminController.js): `core-backend/controllers/adminController.js`

### Persistence and matching

- [User access](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/models/userModel.js): `core-backend/models/userModel.js`
- [Gift matching](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/services/recommendationService.js): `core-backend/services/recommendationService.js`
- [MySQL](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/config/db.js): `core-backend/config/db.js`
- [Redis](https://github.com/hgnhat1511/gift-recommender-system/blob/main/core-backend/config/redis.js): `core-backend/config/redis.js`

### Other components

- **Shopper**

## Connections

- Shopper → Routes and home: browses (evidence: `core-frontend/src/main.jsx`)
- Routes and home → Catalog and finder: routes to (evidence: `core-frontend/src/main.jsx`)
- Routes and home → Cart and orders UI: routes to (evidence: `core-frontend/src/main.jsx`)
- Routes and home → Account pages: routes to (evidence: `core-frontend/src/main.jsx`)
- Routes and home → Sign-in pages: routes to (evidence: `core-frontend/src/main.jsx`)
- Routes and home → Admin pages: routes to (evidence: `core-frontend/src/main.jsx`)
- Routes and home → Coupon admin: routes to (evidence: `core-frontend/src/main.jsx`)
- Catalog and finder → API client: requests data (evidence: `core-frontend/src/pages/store/CatalogPages.jsx`)
- Cart and orders UI → API client: requests commerce (evidence: `core-frontend/src/pages/store/CommercePages.jsx`)
- Account pages → API client: requests account (evidence: `core-frontend/src/pages/account/AccountPages.jsx`)
- Sign-in pages → API client: authenticates via (evidence: `core-frontend/src/pages/auth/LoginPage.jsx`)
- Admin pages → API client: manages via (evidence: `core-frontend/src/pages/admin/AdminPages.jsx`)
- Coupon admin → API client: manages via (evidence: `core-frontend/src/pages/admin/CouponAdminPage.jsx`)
- Catalog and finder → Guest cart: updates (evidence: `core-frontend/src/pages/store/CatalogPages.jsx`)
- Cart and orders UI → Guest cart: reads and updates (evidence: `core-frontend/src/pages/store/CommercePages.jsx`)
- Sign-in pages → Guest cart: merges after login (evidence: `core-frontend/src/pages/auth/LoginPage.jsx`)
- API client → Express API: sends API requests (evidence: `core-frontend/src/lib/api.js`)
- Express API → Auth routes: mounts (evidence: `core-backend/server.js`)
- Express API → Catalog routes: mounts (evidence: `core-backend/server.js`)
- Express API → Order routes: mounts (evidence: `core-backend/server.js`)
- Express API → Redis: connects and checks (evidence: `core-backend/server.js`)
- Auth routes → Authentication: dispatches (evidence: `core-backend/routes/authRoutes.js`)
- Authentication → User access: uses (evidence: `core-backend/controllers/authController.js`)
- JWT authorization → User access: loads user (evidence: `core-backend/middleware/authMiddleware.js`)
- Catalog routes → Catalog and events: dispatches (evidence: `core-backend/routes/catalogRoutes.js`)
- Catalog routes → Reviews: dispatches reviews (evidence: `core-backend/routes/catalogRoutes.js`)
- Catalog and events → Gift matching: requests matches (evidence: `core-backend/controllers/catalogController.js`)
- Catalog and events → MySQL: reads and records (evidence: `core-backend/controllers/catalogController.js`)
- Gift matching → MySQL: queries catalog (evidence: `core-backend/services/recommendationService.js`)
- Order routes → Checkout and orders: dispatches (evidence: `core-backend/routes/orderRoutes.js`)
- Order routes → Returns: dispatches returns (evidence: `core-backend/routes/orderRoutes.js`)
- Checkout and orders → MySQL: transacts orders (evidence: `core-backend/controllers/orderController.js`)
- Reviews → MySQL: reads and writes (evidence: `core-backend/controllers/reviewController.js`)
- Admin operations → MySQL: manages records (evidence: `core-backend/controllers/adminController.js`)
- Admin operations → Checkout and orders: uses order helpers (evidence: `core-backend/controllers/adminController.js`)
- Cart operations → MySQL: stores cart rows (evidence: `core-backend/controllers/cartController.js`)
- Account services → MySQL: stores account data (evidence: `core-backend/controllers/accountController.js`)
- Returns → MySQL: stores return requests (evidence: `core-backend/controllers/returnController.js`)
