# quoc139/cnpm architecture

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

- Interactive diagram: https://gitdiagram.com/quoc139/cnpm
- Repository: https://github.com/quoc139/cnpm

## Overview

This repository is a Vietnamese sneaker storefront with a Vue frontend and Django REST backend. The main customer journey is browsing products, managing a cart and address, placing an order, and tracking it; separate branches cover account access, recommendations and engagement, exchanges, and staff administration. Backend services own transactional domain changes, while models represent persisted state. The source excerpts establish only some calls, so unsampled routes and subsystem wiring are represented cautiously or omitted.

Main entry points: [`PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/services.py`](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/services.py) (Cart & checkout), [`PHAMTRONGQUOC_24CT2/frontend/src/lib/http/client.ts`](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/lib/http/client.ts) (HTTP client), [`PHAMTRONGQUOC_24CT2/Base_dijango/apps/catalog/models.py`](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/catalog/models.py) (Products & stock), [`PHAMTRONGQUOC_24CT2/Base_dijango/apps/engagement/services.py`](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/engagement/services.py) (Engagement services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Storefront UI"]
  node_auth_ui["Auth flow<br/>[useAuth.ts]"]
  node_auth_store["Session state<br/>[auth.ts]"]
  node_http["HTTP client<br/>[client.ts]"]
  node_catalog_ui["Product browsing<br/>[ProductsPage.vue]"]
  node_cart_ui["Cart<br/>[CartPage.vue]"]
  node_orders_ui["Order tracking<br/>[OrdersPage.vue]"]
  node_exchange_ui["Exchange screens<br/>[ExchangesPage.vue]"]
end

subgraph group_identity["Accounts"]
  node_account_service["Account services<br/>[services.py]"]
  node_user_manager["User manager<br/>[managers.py]"]
  node_account_models[("Users &amp; addresses<br/>[models.py]")]
end

subgraph group_commerce["Commerce"]
  node_order_service["Cart &amp; checkout<br/>[services.py]"]
  node_order_models[("Orders &amp; carts<br/>[models.py]")]
  node_payments["Payment handling<br/>[payments.py]"]
  node_fulfillment["Fulfillment<br/>[fulfillment.py]"]
end

subgraph group_product["Catalog &amp; Engagement"]
  node_catalog_service["Catalog services<br/>[services.py]"]
  node_catalog_models[("Products &amp; stock<br/>[models.py]")]
  node_recommendations["Recommendations<br/>[recommendations.py]"]
  node_engagement_service["Engagement services<br/>[services.py]"]
  node_engagement_models[("Reviews &amp; loyalty<br/>[models.py]")]
end

subgraph group_operations["Operations"]
  node_exchange_service["Exchange lifecycle<br/>[services.py]"]
  node_exchange_models[("Exchange records<br/>[models.py]")]
  node_admin_ui["Admin tools"]
end

node_shopper(("Shopper"))
node_staff(("Store staff"))

node_shopper -->|"signs in"| node_auth_ui
node_auth_ui -->|"sets session"| node_auth_store
node_auth_ui -.->|"sends requests"| node_http
node_shopper -->|"browses"| node_catalog_ui
node_catalog_ui -.->|"loads products"| node_http
node_shopper -->|"manages cart"| node_cart_ui
node_cart_ui -.->|"submits changes"| node_http
node_shopper -->|"checks orders"| node_orders_ui
node_orders_ui -.->|"loads orders"| node_http
node_shopper -->|"requests exchange"| node_exchange_ui
node_exchange_ui -.->|"sends request"| node_http
node_user_manager -->|"creates users"| node_account_models
node_account_service -->|"updates accounts"| node_account_models
node_catalog_service -->|"updates catalog"| node_catalog_models
node_order_service -->|"writes cart and orders"| node_order_models
node_order_service -->|"checks inventory"| node_catalog_models
node_order_service -->|"locks user"| node_account_models
node_order_service -->|"uses voucher logic"| node_engagement_service
node_engagement_service -->|"records engagement"| node_engagement_models
node_engagement_service -->|"records product events"| node_catalog_models
node_engagement_service -->|"checks order items"| node_order_models
node_recommendations -.->|"uses product data"| node_catalog_models
node_payments -.->|"tracks payment state"| node_order_models
node_fulfillment -->|"coordinates fulfillment"| node_order_service
node_fulfillment -->|"uses account services"| node_account_service
node_exchange_service -->|"updates exchanges"| node_exchange_models
node_exchange_service -->|"validates order"| node_order_models
node_exchange_service -->|"reserves stock"| node_catalog_models
node_staff -->|"manages store"| node_admin_ui

click node_auth_ui "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/auth/composables/useAuth.ts"
click node_auth_store "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/auth/stores/auth.ts"
click node_http "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/lib/http/client.ts"
click node_catalog_ui "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/catalog/pages/ProductsPage.vue"
click node_cart_ui "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/cart/pages/CartPage.vue"
click node_orders_ui "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/orders/pages/OrdersPage.vue"
click node_exchange_ui "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/exchanges/pages/ExchangesPage.vue"
click node_account_service "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/accounts/services.py"
click node_user_manager "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/accounts/managers.py"
click node_account_models "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/accounts/models.py"
click node_catalog_service "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/catalog/services.py"
click node_catalog_models "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/catalog/models.py"
click node_recommendations "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/catalog/recommendations.py"
click node_engagement_service "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/engagement/services.py"
click node_engagement_models "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/engagement/models.py"
click node_order_service "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/services.py"
click node_order_models "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/models.py"
click node_payments "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/payments.py"
click node_fulfillment "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/fulfillment.py"
click node_exchange_service "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/exchanges/services.py"
click node_exchange_models "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/exchanges/models.py"
click node_admin_ui "https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/admin/pages/AdminProductsPage.vue"

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_auth_ui,node_auth_store,node_http,node_catalog_ui,node_cart_ui,node_orders_ui,node_exchange_ui toneBlue
class node_account_service,node_user_manager,node_account_models toneAmber
class node_order_service,node_order_models,node_payments,node_fulfillment toneMint
class node_catalog_service,node_catalog_models,node_recommendations,node_engagement_service,node_engagement_models toneRose
class node_exchange_service,node_exchange_models,node_admin_ui,node_shopper,node_staff toneIndigo
```

## Components

### Storefront UI

- [Auth flow](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/auth/composables/useAuth.ts): `PHAMTRONGQUOC_24CT2/frontend/src/modules/auth/composables/useAuth.ts`
- [Session state](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/auth/stores/auth.ts): `PHAMTRONGQUOC_24CT2/frontend/src/modules/auth/stores/auth.ts`
- [HTTP client](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/lib/http/client.ts): `PHAMTRONGQUOC_24CT2/frontend/src/lib/http/client.ts`
- [Product browsing](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/catalog/pages/ProductsPage.vue): `PHAMTRONGQUOC_24CT2/frontend/src/modules/catalog/pages/ProductsPage.vue`
- [Cart](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/cart/pages/CartPage.vue): `PHAMTRONGQUOC_24CT2/frontend/src/modules/cart/pages/CartPage.vue`
- [Order tracking](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/orders/pages/OrdersPage.vue): `PHAMTRONGQUOC_24CT2/frontend/src/modules/orders/pages/OrdersPage.vue`
- [Exchange screens](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/exchanges/pages/ExchangesPage.vue): `PHAMTRONGQUOC_24CT2/frontend/src/modules/exchanges/pages/ExchangesPage.vue`

### Accounts

- [Account services](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/accounts/services.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/accounts/services.py`
- [User manager](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/accounts/managers.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/accounts/managers.py`
- [Users & addresses](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/accounts/models.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/accounts/models.py`

### Commerce

- [Cart & checkout](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/services.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/services.py`
- [Orders & carts](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/models.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/models.py`
- [Payment handling](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/payments.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/payments.py`
- [Fulfillment](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/fulfillment.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/fulfillment.py`

### Catalog & Engagement

- [Catalog services](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/catalog/services.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/catalog/services.py`
- [Products & stock](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/catalog/models.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/catalog/models.py`
- [Recommendations](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/catalog/recommendations.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/catalog/recommendations.py`
- [Engagement services](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/engagement/services.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/engagement/services.py`
- [Reviews & loyalty](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/engagement/models.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/engagement/models.py`

### Operations

- [Exchange lifecycle](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/exchanges/services.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/exchanges/services.py`
- [Exchange records](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/Base_dijango/apps/exchanges/models.py): `PHAMTRONGQUOC_24CT2/Base_dijango/apps/exchanges/models.py`
- [Admin tools](https://github.com/quoc139/cnpm/blob/main/PHAMTRONGQUOC_24CT2/frontend/src/modules/admin/pages/AdminProductsPage.vue): `PHAMTRONGQUOC_24CT2/frontend/src/modules/admin/pages/AdminProductsPage.vue`

### Other components

- **Shopper**
- **Store staff**

## Connections

- Shopper → Auth flow: signs in (evidence: `PHAMTRONGQUOC_24CT2/frontend/src/modules/auth/composables/useAuth.ts`)
- Auth flow → Session state: sets session (evidence: `PHAMTRONGQUOC_24CT2/frontend/src/modules/auth/composables/useAuth.ts`)
- Auth flow → HTTP client: sends requests
- Shopper → Product browsing: browses
- Product browsing → HTTP client: loads products
- Shopper → Cart: manages cart
- Cart → HTTP client: submits changes
- Shopper → Order tracking: checks orders
- Order tracking → HTTP client: loads orders
- Shopper → Exchange screens: requests exchange
- Exchange screens → HTTP client: sends request
- User manager → Users & addresses: creates users (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/accounts/models.py`)
- Account services → Users & addresses: updates accounts (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/accounts/services.py`)
- Catalog services → Products & stock: updates catalog (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/catalog/services.py`)
- Cart & checkout → Orders & carts: writes cart and orders (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/services.py`)
- Cart & checkout → Products & stock: checks inventory (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/services.py`)
- Cart & checkout → Users & addresses: locks user (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/services.py`)
- Cart & checkout → Engagement services: uses voucher logic (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/services.py`)
- Engagement services → Reviews & loyalty: records engagement (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/engagement/services.py`)
- Engagement services → Products & stock: records product events (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/engagement/services.py`)
- Engagement services → Orders & carts: checks order items (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/engagement/services.py`)
- Recommendations → Products & stock: uses product data
- Payment handling → Orders & carts: tracks payment state
- Fulfillment → Cart & checkout: coordinates fulfillment (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/fulfillment.py`)
- Fulfillment → Account services: uses account services (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/orders/fulfillment.py`)
- Exchange lifecycle → Exchange records: updates exchanges (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/exchanges/services.py`)
- Exchange lifecycle → Orders & carts: validates order (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/exchanges/services.py`)
- Exchange lifecycle → Products & stock: reserves stock (evidence: `PHAMTRONGQUOC_24CT2/Base_dijango/apps/exchanges/services.py`)
- Store staff → Admin tools: manages store
