# nhatlong12112005/htttdn-crm architecture

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

- Interactive diagram: https://gitdiagram.com/nhatlong12112005/htttdn-crm
- Repository: https://github.com/nhatlong12112005/htttdn-crm

## Overview

This repository implements an e-commerce platform with a customer storefront, a separate administration/CRM portal, and a NestJS API. Customer routes cover discovery, accounts, cart, checkout, orders, favorites, and surveys; admins manage catalog, orders, reviews, surveys, and analytics. The backend separates these domains into API modules and uses Prisma for persistence. Dataset generation is a supporting data-preparation capability. Some API and realtime connections are not visible in the sampled evidence, so those links are marked unverified.

Main entry points: [`client/src/services`](https://github.com/nhatlong12112005/htttdn-crm/tree/main/client/src/services) (Storefront API services), [`admin/src/App.jsx`](https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/App.jsx) (Admin portal routes), [`client/src/routes/AppRoutes.jsx`](https://github.com/nhatlong12112005/htttdn-crm/blob/main/client/src/routes/AppRoutes.jsx) (Storefront routes), [`admin/src/api/axiosClient.js`](https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/api/axiosClient.js) (Admin API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Customer storefront"]
  node_client_routes["Storefront routes<br/>[AppRoutes.jsx]"]
  node_catalog_ui["Product discovery"]
  node_cart_checkout["Cart and checkout"]
  node_account_ui["Customer accounts"]
  node_survey_ui["Survey participation<br/>[SurveyPage.jsx]"]
  node_client_services["Storefront API services"]
end

subgraph group_admin["Admin and CRM"]
  node_admin_routes["Admin portal routes<br/>[App.jsx]"]
  node_admin_auth["Admin authentication<br/>[AuthContext.jsx]"]
  node_admin_api["Admin API client<br/>[axiosClient.js]"]
  node_admin_accounts["Account management"]
  node_admin_reviews["Review moderation"]
  node_admin_surveys["Survey management"]
  node_admin_analytics["Analytics and reconciliation"]
end

subgraph group_backend["Backend services"]
  node_api_auth["Authentication API"]
  node_api_catalog["Catalog API"]
  node_api_orders["Cart and orders API"]
  node_api_reviews["Reviews API"]
  node_api_surveys["Surveys API"]
  node_api_reports["Reports API"]
  node_prisma[("Prisma persistence<br/>[prisma.service.ts]")]
end

subgraph group_data["Data generation"]
  node_data_generators["Dataset generators"]
  node_data_faker["Fake data utilities<br/>[faker.ts]"]
  node_data_sql["SQL builder<br/>[sqlBuilder.ts]"]
end

node_customer(("Customer"))
node_admin_user(("Administrator"))

node_customer -->|"uses"| node_client_routes
node_client_routes -->|"routes to"| node_catalog_ui
node_client_routes -->|"routes to"| node_cart_checkout
node_client_routes -->|"routes to"| node_account_ui
node_client_routes -->|"routes to"| node_survey_ui
node_catalog_ui -.->|"uses"| node_client_services
node_cart_checkout -.->|"uses"| node_client_services
node_account_ui -.->|"uses"| node_client_services
node_survey_ui -.->|"uses"| node_client_services
node_client_services -.->|"HTTP requests"| node_api_catalog
node_client_services -.->|"HTTP requests"| node_api_orders
node_client_services -.->|"HTTP requests"| node_api_auth
node_client_services -.->|"HTTP requests"| node_api_surveys
node_admin_user -->|"uses"| node_admin_routes
node_admin_routes -->|"provides auth"| node_admin_auth
node_admin_routes -->|"routes to"| node_admin_accounts
node_admin_routes -->|"routes to"| node_admin_reviews
node_admin_routes -->|"routes to"| node_admin_surveys
node_admin_routes -->|"routes to"| node_admin_analytics
node_admin_auth -->|"calls"| node_admin_api
node_admin_accounts -->|"calls"| node_admin_api
node_admin_reviews -->|"calls"| node_admin_api
node_admin_api -.->|"HTTP requests"| node_api_auth
node_admin_api -.->|"HTTP requests"| node_api_reviews
node_api_auth -->|"reads and writes"| node_prisma
node_api_reviews -->|"reads and writes"| node_prisma
node_api_surveys -.->|"persists responses"| node_prisma
node_data_generators -->|"imports"| node_data_faker
node_data_generators -->|"imports"| node_data_sql

click node_client_routes "https://github.com/nhatlong12112005/htttdn-crm/blob/main/client/src/routes/AppRoutes.jsx"
click node_catalog_ui "https://github.com/nhatlong12112005/htttdn-crm/tree/main/client/src/pages/Product"
click node_cart_checkout "https://github.com/nhatlong12112005/htttdn-crm/tree/main/client/src/pages/Cart"
click node_account_ui "https://github.com/nhatlong12112005/htttdn-crm/tree/main/client/src/pages/Account"
click node_survey_ui "https://github.com/nhatlong12112005/htttdn-crm/blob/main/client/src/pages/Survey/SurveyPage.jsx"
click node_client_services "https://github.com/nhatlong12112005/htttdn-crm/tree/main/client/src/services"
click node_admin_routes "https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/App.jsx"
click node_admin_auth "https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/contexts/AuthContext.jsx"
click node_admin_api "https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/api/axiosClient.js"
click node_admin_accounts "https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/pages/accounts/AccountManagement.jsx"
click node_admin_reviews "https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/pages/reviews/ReviewManagement.jsx"
click node_admin_surveys "https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/pages/surveys/SurveyManagement.jsx"
click node_admin_analytics "https://github.com/nhatlong12112005/htttdn-crm/tree/main/admin/src/pages/analytics"
click node_api_auth "https://github.com/nhatlong12112005/htttdn-crm/tree/main/backend/src/app/auth"
click node_api_catalog "https://github.com/nhatlong12112005/htttdn-crm/tree/main/backend/src/app/products"
click node_api_orders "https://github.com/nhatlong12112005/htttdn-crm/tree/main/backend/src/app/orders"
click node_api_reviews "https://github.com/nhatlong12112005/htttdn-crm/tree/main/backend/src/app/reviews"
click node_api_surveys "https://github.com/nhatlong12112005/htttdn-crm/tree/main/backend/src/app/surveys"
click node_api_reports "https://github.com/nhatlong12112005/htttdn-crm/tree/main/backend/src/app/reports"
click node_prisma "https://github.com/nhatlong12112005/htttdn-crm/blob/main/backend/src/common/prisma/prisma.service.ts"
click node_data_generators "https://github.com/nhatlong12112005/htttdn-crm/tree/main/dataset/generators"
click node_data_faker "https://github.com/nhatlong12112005/htttdn-crm/blob/main/dataset/utils/faker.ts"
click node_data_sql "https://github.com/nhatlong12112005/htttdn-crm/blob/main/dataset/utils/sqlBuilder.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_client_routes,node_catalog_ui,node_cart_checkout,node_account_ui,node_survey_ui,node_client_services toneBlue
class node_admin_routes,node_admin_auth,node_admin_api,node_admin_accounts,node_admin_reviews,node_admin_surveys,node_admin_analytics toneAmber
class node_api_auth,node_api_catalog,node_api_orders,node_api_reviews,node_api_surveys,node_api_reports,node_prisma toneMint
class node_data_generators,node_data_faker,node_data_sql toneRose
class node_customer,node_admin_user toneIndigo
```

## Components

### Customer storefront

- [Storefront routes](https://github.com/nhatlong12112005/htttdn-crm/blob/main/client/src/routes/AppRoutes.jsx): `client/src/routes/AppRoutes.jsx`
- [Product discovery](https://github.com/nhatlong12112005/htttdn-crm/tree/main/client/src/pages/Product): `client/src/pages/Product`
- [Cart and checkout](https://github.com/nhatlong12112005/htttdn-crm/tree/main/client/src/pages/Cart): `client/src/pages/Cart`
- [Customer accounts](https://github.com/nhatlong12112005/htttdn-crm/tree/main/client/src/pages/Account): `client/src/pages/Account`
- [Survey participation](https://github.com/nhatlong12112005/htttdn-crm/blob/main/client/src/pages/Survey/SurveyPage.jsx): `client/src/pages/Survey/SurveyPage.jsx`
- [Storefront API services](https://github.com/nhatlong12112005/htttdn-crm/tree/main/client/src/services): `client/src/services`

### Admin and CRM

- [Admin portal routes](https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/App.jsx): `admin/src/App.jsx`
- [Admin authentication](https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/contexts/AuthContext.jsx): `admin/src/contexts/AuthContext.jsx`
- [Admin API client](https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/api/axiosClient.js): `admin/src/api/axiosClient.js`
- [Account management](https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/pages/accounts/AccountManagement.jsx): `admin/src/pages/accounts/AccountManagement.jsx`
- [Review moderation](https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/pages/reviews/ReviewManagement.jsx): `admin/src/pages/reviews/ReviewManagement.jsx`
- [Survey management](https://github.com/nhatlong12112005/htttdn-crm/blob/main/admin/src/pages/surveys/SurveyManagement.jsx): `admin/src/pages/surveys/SurveyManagement.jsx`
- [Analytics and reconciliation](https://github.com/nhatlong12112005/htttdn-crm/tree/main/admin/src/pages/analytics): `admin/src/pages/analytics`

### Backend services

- [Authentication API](https://github.com/nhatlong12112005/htttdn-crm/tree/main/backend/src/app/auth): `backend/src/app/auth`
- [Catalog API](https://github.com/nhatlong12112005/htttdn-crm/tree/main/backend/src/app/products): `backend/src/app/products`
- [Cart and orders API](https://github.com/nhatlong12112005/htttdn-crm/tree/main/backend/src/app/orders): `backend/src/app/orders`
- [Reviews API](https://github.com/nhatlong12112005/htttdn-crm/tree/main/backend/src/app/reviews): `backend/src/app/reviews`
- [Surveys API](https://github.com/nhatlong12112005/htttdn-crm/tree/main/backend/src/app/surveys): `backend/src/app/surveys`
- [Reports API](https://github.com/nhatlong12112005/htttdn-crm/tree/main/backend/src/app/reports): `backend/src/app/reports`
- [Prisma persistence](https://github.com/nhatlong12112005/htttdn-crm/blob/main/backend/src/common/prisma/prisma.service.ts): `backend/src/common/prisma/prisma.service.ts`

### Data generation

- [Dataset generators](https://github.com/nhatlong12112005/htttdn-crm/tree/main/dataset/generators): `dataset/generators`
- [Fake data utilities](https://github.com/nhatlong12112005/htttdn-crm/blob/main/dataset/utils/faker.ts): `dataset/utils/faker.ts`
- [SQL builder](https://github.com/nhatlong12112005/htttdn-crm/blob/main/dataset/utils/sqlBuilder.ts): `dataset/utils/sqlBuilder.ts`

### Other components

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

## Connections

- Customer → Storefront routes: uses (evidence: `client/src/routes/AppRoutes.jsx`)
- Storefront routes → Product discovery: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- Storefront routes → Cart and checkout: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- Storefront routes → Customer accounts: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- Storefront routes → Survey participation: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- Product discovery → Storefront API services: uses
- Cart and checkout → Storefront API services: uses
- Customer accounts → Storefront API services: uses
- Survey participation → Storefront API services: uses
- Storefront API services → Catalog API: HTTP requests
- Storefront API services → Cart and orders API: HTTP requests
- Storefront API services → Authentication API: HTTP requests
- Storefront API services → Surveys API: HTTP requests
- Administrator → Admin portal routes: uses (evidence: `admin/src/App.jsx`)
- Admin portal routes → Admin authentication: provides auth (evidence: `admin/src/App.jsx`)
- Admin portal routes → Account management: routes to (evidence: `admin/src/App.jsx`)
- Admin portal routes → Review moderation: routes to (evidence: `admin/src/App.jsx`)
- Admin portal routes → Survey management: routes to (evidence: `admin/src/App.jsx`)
- Admin portal routes → Analytics and reconciliation: routes to (evidence: `admin/src/App.jsx`)
- Admin authentication → Admin API client: calls (evidence: `admin/src/contexts/AuthContext.jsx`)
- Account management → Admin API client: calls (evidence: `admin/src/pages/accounts/AccountManagement.jsx`)
- Review moderation → Admin API client: calls (evidence: `admin/src/pages/reviews/ReviewManagement.jsx`)
- Admin API client → Authentication API: HTTP requests
- Admin API client → Reviews API: HTTP requests
- Authentication API → Prisma persistence: reads and writes (evidence: `backend/src/app/auth/auth.service.ts`)
- Reviews API → Prisma persistence: reads and writes (evidence: `backend/src/app/reviews/reviews.service.ts`)
- Surveys API → Prisma persistence: persists responses
- Dataset generators → Fake data utilities: imports (evidence: `dataset/generators/reviews.generator.ts`)
- Dataset generators → SQL builder: imports (evidence: `dataset/generators/reviews.generator.ts`)
