# thanhvu134/cong_nghe_phan_mem architecture

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

- Interactive diagram: https://gitdiagram.com/thanhvu134/cong_nghe_phan_mem
- Repository: https://github.com/thanhvu134/cong_nghe_phan_mem

## Overview

This is a product-catalog and inventory-management web application with a React frontend, Express API, and MySQL persistence. Users browse and filter products, inspect details, and register or sign in; administrators can maintain products and manage user roles. Authentication also supports PDF-based token login, while the interface includes profile, statistics, and PDF-generation capabilities. The graph follows shown imports, route registrations, and SQL calls; frontend-to-backend endpoint matching is not asserted where excerpts do not establish the wiring.

Main entry points: [`quanLySP/frontend/src/App.jsx`](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/App.jsx) (Page routing), [`quanLySP/frontend/src/api/products.js`](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/api/products.js) (Product API client), [`quanLySP/frontend/src/context/AuthContext.jsx`](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/context/AuthContext.jsx) (Session state), [`quanLySP/backend/src/middleware/auth.middleware.js`](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/middleware/auth.middleware.js) (JWT authorization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_app["Page routing<br/>[App.jsx]"]
  node_authctx["Session state<br/>[AuthContext.jsx]"]
  node_authpage["Sign in and register<br/>[Login.jsx]"]
  node_profile["Account profile<br/>[Profile.jsx]"]
  node_home["Home and PDF export<br/>[Home.jsx]"]
  node_listing["Product browsing<br/>[Products.jsx]"]
  node_detail["Product detail<br/>[ProductDetail.jsx]"]
  node_statistics["Statistics<br/>[Statistics.jsx]"]
  node_pdfgen["PDF generator<br/>[pdfGenerator.js]"]
  node_font["Embedded font<br/>[roboto-regular.js]"]
end

subgraph group_api["API and authentication"]
  node_authapi["Authentication API client<br/>[auth.js]"]
  node_productapi["Product API client<br/>[products.js]"]
  node_backend["HTTP API service"]
  node_authroutes["Authentication routes<br/>[auth.routes.js]"]
  node_authcontroller["Authentication and PDF login<br/>[auth.controller.js]"]
  node_middleware["JWT authorization<br/>[auth.middleware.js]"]
  node_jwtconfig["JWT configuration<br/>[jwt.config.js]"]
  node_users["Admin user management<br/>[user.routes.js]"]
end

subgraph group_catalog["Catalog management"]
  node_productroutes["Product routes<br/>[product.routes.js]"]
  node_productcontroller["Product operations"]
end

subgraph group_data["Persistence"]
  node_dbconfig["MySQL connection pool<br/>[db.js]"]
  node_mysql[("MySQL product database")]
end

node_visitor(("Visitor or admin"))

node_visitor -->|"opens"| node_app
node_app -->|"provides session"| node_authctx
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_authpage
node_app -->|"routes to"| node_listing
node_app -->|"routes to"| node_detail
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_statistics
node_authctx -->|"calls"| node_authapi
node_authpage -->|"uses session"| node_authctx
node_profile -->|"uses session"| node_authctx
node_home -->|"fetches products"| node_productapi
node_home -->|"generates PDF"| node_pdfgen
node_pdfgen -->|"embeds font"| node_font
node_listing -->|"manages products"| node_productapi
node_detail -->|"loads product"| node_productapi
node_statistics -->|"loads statistics data"| node_productapi
node_authapi -->|"sends auth requests"| node_backend
node_productapi -->|"sends product requests"| node_backend
node_authroutes -->|"dispatches"| node_authcontroller
node_authroutes -->|"protects profile route"| node_middleware
node_authcontroller -->|"queries users"| node_dbconfig
node_authcontroller -->|"signs and verifies"| node_jwtconfig
node_middleware -->|"verifies tokens"| node_jwtconfig
node_productroutes -->|"dispatches"| node_productcontroller
node_productroutes -->|"guards admin routes"| node_middleware
node_productcontroller -->|"queries products"| node_dbconfig
node_users -->|"requires authentication"| node_middleware
node_users -->|"manages user records"| node_dbconfig
node_dbconfig -.->|"connects to"| node_mysql

click node_app "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/App.jsx"
click node_authctx "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/context/AuthContext.jsx"
click node_authpage "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/pages/Login.jsx"
click node_profile "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/pages/Profile.jsx"
click node_home "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/pages/Home.jsx"
click node_listing "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/pages/Products.jsx"
click node_detail "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/pages/ProductDetail.jsx"
click node_statistics "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/pages/Statistics.jsx"
click node_pdfgen "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/utils/pdfGenerator.js"
click node_font "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/utils/fonts/roboto-regular.js"
click node_authapi "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/api/auth.js"
click node_productapi "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/api/products.js"
click node_authroutes "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/routes/auth.routes.js"
click node_authcontroller "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/controllers/auth.controller.js"
click node_middleware "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/middleware/auth.middleware.js"
click node_jwtconfig "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/config/jwt.config.js"
click node_productroutes "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/routes/product.routes.js"
click node_productcontroller "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/controllers/product.controller.js"
click node_users "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/routes/user.routes.js"
click node_dbconfig "https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/config/db.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_app,node_authctx,node_authpage,node_profile,node_home,node_listing,node_detail,node_statistics,node_pdfgen,node_font toneBlue
class node_authapi,node_productapi,node_backend,node_authroutes,node_authcontroller,node_middleware,node_jwtconfig,node_users toneAmber
class node_productroutes,node_productcontroller toneMint
class node_dbconfig,node_mysql toneRose
class node_visitor toneIndigo
```

## Components

### Web interface

- [Page routing](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/App.jsx): `quanLySP/frontend/src/App.jsx`
- [Session state](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/context/AuthContext.jsx): `quanLySP/frontend/src/context/AuthContext.jsx`
- [Sign in and register](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/pages/Login.jsx): `quanLySP/frontend/src/pages/Login.jsx`
- [Account profile](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/pages/Profile.jsx): `quanLySP/frontend/src/pages/Profile.jsx`
- [Home and PDF export](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/pages/Home.jsx): `quanLySP/frontend/src/pages/Home.jsx`
- [Product browsing](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/pages/Products.jsx): `quanLySP/frontend/src/pages/Products.jsx`
- [Product detail](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/pages/ProductDetail.jsx): `quanLySP/frontend/src/pages/ProductDetail.jsx`
- [Statistics](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/pages/Statistics.jsx): `quanLySP/frontend/src/pages/Statistics.jsx`
- [PDF generator](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/utils/pdfGenerator.js): `quanLySP/frontend/src/utils/pdfGenerator.js`
- [Embedded font](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/utils/fonts/roboto-regular.js): `quanLySP/frontend/src/utils/fonts/roboto-regular.js`

### API and authentication

- [Authentication API client](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/api/auth.js): `quanLySP/frontend/src/api/auth.js`
- [Product API client](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/frontend/src/api/products.js): `quanLySP/frontend/src/api/products.js`
- **HTTP API service**
- [Authentication routes](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/routes/auth.routes.js): `quanLySP/backend/src/routes/auth.routes.js`
- [Authentication and PDF login](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/controllers/auth.controller.js): `quanLySP/backend/src/controllers/auth.controller.js`
- [JWT authorization](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/middleware/auth.middleware.js): `quanLySP/backend/src/middleware/auth.middleware.js`
- [JWT configuration](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/config/jwt.config.js): `quanLySP/backend/src/config/jwt.config.js`
- [Admin user management](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/routes/user.routes.js): `quanLySP/backend/src/routes/user.routes.js`

### Catalog management

- [Product routes](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/routes/product.routes.js): `quanLySP/backend/src/routes/product.routes.js`
- [Product operations](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/controllers/product.controller.js): `quanLySP/backend/src/controllers/product.controller.js`

### Persistence

- [MySQL connection pool](https://github.com/thanhvu134/cong_nghe_phan_mem/blob/main/quanLySP/backend/src/config/db.js): `quanLySP/backend/src/config/db.js`
- **MySQL product database**

### Other components

- **Visitor or admin**

## Connections

- Visitor or admin → Page routing: opens (evidence: `quanLySP/frontend/src/App.jsx`)
- Page routing → Session state: provides session (evidence: `quanLySP/frontend/src/App.jsx`)
- Page routing → Home and PDF export: routes to (evidence: `quanLySP/frontend/src/App.jsx`)
- Page routing → Sign in and register: routes to (evidence: `quanLySP/frontend/src/App.jsx`)
- Page routing → Product browsing: routes to (evidence: `quanLySP/frontend/src/App.jsx`)
- Page routing → Product detail: routes to (evidence: `quanLySP/frontend/src/App.jsx`)
- Page routing → Account profile: routes to (evidence: `quanLySP/frontend/src/App.jsx`)
- Page routing → Statistics: routes to (evidence: `quanLySP/frontend/src/App.jsx`)
- Session state → Authentication API client: calls (evidence: `quanLySP/frontend/src/context/AuthContext.jsx`)
- Sign in and register → Session state: uses session (evidence: `quanLySP/frontend/src/pages/Login.jsx`)
- Account profile → Session state: uses session (evidence: `quanLySP/frontend/src/pages/Profile.jsx`)
- Home and PDF export → Product API client: fetches products (evidence: `quanLySP/frontend/src/pages/Home.jsx`)
- Home and PDF export → PDF generator: generates PDF (evidence: `quanLySP/frontend/src/pages/Home.jsx`)
- PDF generator → Embedded font: embeds font (evidence: `quanLySP/frontend/src/utils/pdfGenerator.js`)
- Product browsing → Product API client: manages products (evidence: `quanLySP/frontend/src/pages/Products.jsx`)
- Product detail → Product API client: loads product (evidence: `quanLySP/frontend/src/pages/ProductDetail.jsx`)
- Statistics → Product API client: loads statistics data (evidence: `quanLySP/frontend/src/pages/Statistics.jsx`)
- Authentication API client → HTTP API service: sends auth requests (evidence: `quanLySP/frontend/src/api/auth.js`)
- Product API client → HTTP API service: sends product requests (evidence: `quanLySP/frontend/src/api/products.js`)
- Authentication routes → Authentication and PDF login: dispatches (evidence: `quanLySP/backend/src/routes/auth.routes.js`)
- Authentication routes → JWT authorization: protects profile route (evidence: `quanLySP/backend/src/routes/auth.routes.js`)
- Authentication and PDF login → MySQL connection pool: queries users (evidence: `quanLySP/backend/src/controllers/auth.controller.js`)
- Authentication and PDF login → JWT configuration: signs and verifies (evidence: `quanLySP/backend/src/controllers/auth.controller.js`)
- JWT authorization → JWT configuration: verifies tokens (evidence: `quanLySP/backend/src/middleware/auth.middleware.js`)
- Product routes → Product operations: dispatches (evidence: `quanLySP/backend/src/routes/product.routes.js`)
- Product routes → JWT authorization: guards admin routes (evidence: `quanLySP/backend/src/routes/product.routes.js`)
- Product operations → MySQL connection pool: queries products (evidence: `quanLySP/backend/src/controllers/product.controller.js`)
- Admin user management → JWT authorization: requires authentication (evidence: `quanLySP/backend/src/routes/user.routes.js`)
- Admin user management → MySQL connection pool: manages user records (evidence: `quanLySP/backend/src/routes/user.routes.js`)
- MySQL connection pool → MySQL product database: connects to
