# laiquanghai2k6/shopee architecture

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

- Interactive diagram: https://gitdiagram.com/laiquanghai2k6/shopee
- Repository: https://github.com/laiquanghai2k6/shopee

## Overview

Shopee Clone is a full-stack storefront and administration app. A shopper browses or searches products, manages a cart, checks out through payment, and can review order history; administrators manage catalog, vouchers, users, banners, and revenue. The client is a Next.js app with query/state layers, while NestJS exposes domain controllers and services backed by PostgreSQL entities. The README documents Stripe; the tree also includes VNPay and Cloudinary integrations. Some client-to-API wiring and backend service internals were not sampled, so those links are omitted unless directly evidenced.

Main entry points: [`server/src/auth/auth.service.ts`](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/auth/auth.service.ts) (Auth service), [`client/src/app/search/[title]/page.tsx`](https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/search/%5Btitle%5D/page.tsx) (Product search), [`server/src/admin/admin.controller.ts`](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/admin/admin.controller.ts) (Admin endpoints), [`server/src/admin/admin.service.ts`](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/admin/admin.service.ts) (Admin service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront client"]
  node_home["Storefront<br/>[page.tsx]"]
  node_product_detail["Product details<br/>[page.tsx]"]
  node_search_page["Product search<br/>[page.tsx]"]
  node_search_results["Search results UI<br/>[SearchClient.tsx]"]
  node_cart_page["Shopping cart<br/>[page.tsx]"]
  node_checkout_ui["Checkout UI<br/>[ModalPayment.tsx]"]
  node_history_page["Order history<br/>[page.tsx]"]
  node_admin_page["Admin dashboard<br/>[page.tsx]"]
  node_history_query["History query<br/>[useHistoryQuery.ts]"]
end

subgraph group_commerce["Commerce API"]
  node_product_api["Product endpoints"]
  node_category_api["Category endpoints"]
  node_cart_history_api["Cart and history"]
  node_stripe_api["Stripe endpoints"]
  node_vnpay_api["VNPay endpoints"]
end

subgraph group_identity_admin["Identity and admin"]
  node_auth_api["Authentication<br/>[auth.controller.ts]"]
  node_auth_service["Auth service<br/>[auth.service.ts]"]
  node_admin_api["Admin endpoints"]
  node_admin_service["Admin service<br/>[admin.service.ts]"]
end

subgraph group_data_integrations["Data and integrations"]
  node_postgres[("PostgreSQL entities")]
  node_stripe["Stripe"]
  node_vnpay["VNPay gateway"]
  node_cloudinary["Cloudinary"]
end

node_shopper(("Shopper"))
node_admin_actor(("Administrator"))

node_shopper -->|"browses"| node_home
node_shopper -->|"views"| node_product_detail
node_shopper -->|"searches"| node_search_page
node_search_page -->|"renders"| node_search_results
node_shopper -->|"manages cart"| node_cart_page
node_shopper -->|"checks out"| node_checkout_ui
node_shopper -->|"reviews orders"| node_history_page
node_admin_actor -->|"manages store"| node_admin_page
node_product_api --> node_category_api
node_history_query -->|"requests history"| node_admin_api
node_admin_api -->|"dispatches"| node_admin_service
node_admin_service -->|"reads/writes"| node_postgres
node_auth_api -->|"dispatches"| node_auth_service
node_auth_service -->|"reads/writes"| node_postgres
node_stripe_api -.->|"uses"| node_stripe
node_vnpay_api -->|"creates payment URL"| node_vnpay
node_auth_service -.->|"uploads image"| node_cloudinary

click node_home "https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/page.tsx"
click node_product_detail "https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/%5Bslug%5D/page.tsx"
click node_search_page "https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/search/%5Btitle%5D/page.tsx"
click node_search_results "https://github.com/laiquanghai2k6/shopee/blob/main/client/src/components/Product/SearchClient.tsx"
click node_cart_page "https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/cart/page.tsx"
click node_checkout_ui "https://github.com/laiquanghai2k6/shopee/blob/main/client/src/components/Modal/ModalPayment.tsx"
click node_history_page "https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/history/page.tsx"
click node_admin_page "https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/admin/page.tsx"
click node_history_query "https://github.com/laiquanghai2k6/shopee/blob/main/client/src/hooks/useHistoryQuery.ts"
click node_product_api "https://github.com/laiquanghai2k6/shopee/blob/main/server/src/product/product.controller.ts"
click node_category_api "https://github.com/laiquanghai2k6/shopee/blob/main/server/src/category/category.controller.ts"
click node_cart_history_api "https://github.com/laiquanghai2k6/shopee/blob/main/server/src/history_cart/history_cart.controller.ts"
click node_stripe_api "https://github.com/laiquanghai2k6/shopee/blob/main/server/src/stripe/stripe.controller.ts"
click node_vnpay_api "https://github.com/laiquanghai2k6/shopee/blob/main/server/src/vnpay/vnpay.controller.ts"
click node_auth_api "https://github.com/laiquanghai2k6/shopee/blob/main/server/src/auth/auth.controller.ts"
click node_auth_service "https://github.com/laiquanghai2k6/shopee/blob/main/server/src/auth/auth.service.ts"
click node_admin_api "https://github.com/laiquanghai2k6/shopee/blob/main/server/src/admin/admin.controller.ts"
click node_admin_service "https://github.com/laiquanghai2k6/shopee/blob/main/server/src/admin/admin.service.ts"
click node_postgres "https://github.com/laiquanghai2k6/shopee/tree/main/server/src/entities"
click node_cloudinary "https://github.com/laiquanghai2k6/shopee/blob/main/server/src/cloudinary/cloudinary.service.ts"

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_home,node_product_detail,node_search_page,node_search_results,node_cart_page,node_checkout_ui,node_history_page,node_admin_page,node_history_query toneBlue
class node_product_api,node_category_api,node_cart_history_api,node_stripe_api,node_vnpay_api toneAmber
class node_auth_api,node_auth_service,node_admin_api,node_admin_service toneMint
class node_postgres,node_stripe,node_vnpay,node_cloudinary toneRose
class node_shopper,node_admin_actor toneIndigo
```

## Components

### Storefront client

- [Storefront](https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/page.tsx): `client/src/app/page.tsx`
- [Product details](https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/%5Bslug%5D/page.tsx): `client/src/app/[slug]/page.tsx`
- [Product search](https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/search/%5Btitle%5D/page.tsx): `client/src/app/search/[title]/page.tsx`
- [Search results UI](https://github.com/laiquanghai2k6/shopee/blob/main/client/src/components/Product/SearchClient.tsx): `client/src/components/Product/SearchClient.tsx`
- [Shopping cart](https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/cart/page.tsx): `client/src/app/cart/page.tsx`
- [Checkout UI](https://github.com/laiquanghai2k6/shopee/blob/main/client/src/components/Modal/ModalPayment.tsx): `client/src/components/Modal/ModalPayment.tsx`
- [Order history](https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/history/page.tsx): `client/src/app/history/page.tsx`
- [Admin dashboard](https://github.com/laiquanghai2k6/shopee/blob/main/client/src/app/admin/page.tsx): `client/src/app/admin/page.tsx`
- [History query](https://github.com/laiquanghai2k6/shopee/blob/main/client/src/hooks/useHistoryQuery.ts): `client/src/hooks/useHistoryQuery.ts`

### Commerce API

- [Product endpoints](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/product/product.controller.ts): `server/src/product/product.controller.ts`
- [Category endpoints](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/category/category.controller.ts): `server/src/category/category.controller.ts`
- [Cart and history](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/history_cart/history_cart.controller.ts): `server/src/history_cart/history_cart.controller.ts`
- [Stripe endpoints](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/stripe/stripe.controller.ts): `server/src/stripe/stripe.controller.ts`
- [VNPay endpoints](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/vnpay/vnpay.controller.ts): `server/src/vnpay/vnpay.controller.ts`

### Identity and admin

- [Authentication](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/auth/auth.controller.ts): `server/src/auth/auth.controller.ts`
- [Auth service](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/auth/auth.service.ts): `server/src/auth/auth.service.ts`
- [Admin endpoints](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/admin/admin.controller.ts): `server/src/admin/admin.controller.ts`
- [Admin service](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/admin/admin.service.ts): `server/src/admin/admin.service.ts`

### Data and integrations

- [PostgreSQL entities](https://github.com/laiquanghai2k6/shopee/tree/main/server/src/entities): `server/src/entities`
- **Stripe**
- **VNPay gateway**
- [Cloudinary](https://github.com/laiquanghai2k6/shopee/blob/main/server/src/cloudinary/cloudinary.service.ts): `server/src/cloudinary/cloudinary.service.ts`

### Other components

- **Shopper**
- **Administrator**

## Connections

- Shopper → Storefront: browses
- Shopper → Product details: views
- Shopper → Product search: searches
- Product search → Search results UI: renders
- Shopper → Shopping cart: manages cart
- Shopper → Checkout UI: checks out
- Shopper → Order history: reviews orders
- Administrator → Admin dashboard: manages store
- Product endpoints → Category endpoints
- History query → Admin endpoints: requests history
- Admin endpoints → Admin service: dispatches
- Admin service → PostgreSQL entities: reads/writes
- Authentication → Auth service: dispatches
- Auth service → PostgreSQL entities: reads/writes
- Stripe endpoints → Stripe: uses
- VNPay endpoints → VNPay gateway: creates payment URL
- Auth service → Cloudinary: uploads image
