# builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep architecture

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

- Interactive diagram: https://gitdiagram.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep
- Repository: https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep

## Overview

LibriFlow is a library-circulation application: staff manage books and copies, create and return loans, while readers access account and borrowing history; administrators review statistics and forecasts. The React client sends requests to the Express API, which applies authentication and domain rules before accessing MySQL. Forecasting uses a reader’s daily loan counts and returns a seven-day prediction. The README documents the main user workflows and client/server connection; some feature modules were not sampled, so their internal call paths are not asserted here.

Main entry points: [`Frontend/src/ung-dung/App.jsx`](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/ung-dung/App.jsx) (App and routing), [`Frontend/src/thu-vien/api/ket-noi-http.js`](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/thu-vien/api/ket-noi-http.js) (HTTP API client), [`Backend/src/app-factory.js`](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/app-factory.js) (Express app and routes), [`Backend/src/services/sach.service.js`](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/services/sach.service.js) (Books and copies services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React application"]
  node_client_app["App and routing<br/>[App.jsx]"]
  node_http["HTTP API client<br/>[ket-noi-http.js]"]
end

subgraph group_identity["Identity and access"]
  node_client_auth["Sign-in and account<br/>[TrangDangNhap.jsx]"]
  node_auth_routes["Authentication routes<br/>[xac-thuc.routes.js]"]
  node_auth_controller["Authentication handlers"]
  node_auth_service["Authentication service"]
  node_auth_model["User and auth models<br/>[xac-thuc.model.js]"]
  node_auth_middleware["Token and permission checks<br/>[xac-thuc.js]"]
end

subgraph group_catalog["Catalog management"]
  node_client_catalog["Book management"]
  node_client_public["Public API query"]
  node_catalog_routes["Catalog routes<br/>[sach.routes.js]"]
  node_catalog_service["Books and copies services<br/>[sach.service.js]"]
  node_copy_controller["Copy handlers"]
  node_catalog_rules["Catalog validation<br/>[kiem-tra-sach.js]"]
  node_isbn["ISBN normalization<br/>[isbn.mjs]"]
end

subgraph group_circulation["Circulation"]
  node_client_circulation["Borrow and return<br/>[TrangMuonTra.jsx]"]
  node_client_reader["Reader history"]
  node_loan_routes["Loan routes"]
  node_loan_service["Loan and return rules"]
  node_history["Usage and loan history"]
end

subgraph group_insights["Analytics and platform"]
  node_client_analytics["Statistics and forecasts<br/>[TrangDuBao.jsx]"]
  node_insight_routes["Statistics and forecast routes<br/>[du-bao.routes.js]"]
  node_forecast_algorithm["Forecast algorithm"]
end

subgraph group_backend["API and persistence"]
  node_express["Express app and routes<br/>[app-factory.js]"]
  node_mysql[("MySQL database<br/>[co-so-du-lieu.js]")]
end

node_staff(("Library staff"))
node_reader(("Reader"))
node_admin(("Administrator"))
node_api_external(("Public API consumer"))

node_staff -->|"uses"| node_client_app
node_reader -->|"uses"| node_client_app
node_admin -->|"uses"| node_client_app
node_client_app -.->|"routes to"| node_client_auth
node_client_app -.->|"routes to"| node_client_catalog
node_client_app -.->|"routes to"| node_client_circulation
node_client_app -.->|"routes to"| node_client_analytics
node_client_auth -.->|"sends requests"| node_http
node_client_catalog -->|"sends requests"| node_http
node_client_circulation -.->|"sends requests"| node_http
node_client_reader -.->|"loads history"| node_http
node_client_analytics -.->|"requests insights"| node_http
node_api_external -.->|"queries"| node_client_public
node_client_public -.->|"sends requests"| node_http
node_http -->|"calls API"| node_express
node_express -->|"registers"| node_auth_routes
node_express -->|"registers"| node_catalog_routes
node_express -->|"registers"| node_loan_routes
node_express -->|"registers"| node_insight_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"calls"| node_auth_service
node_auth_service -->|"reads and writes"| node_auth_model
node_auth_routes -->|"guards routes"| node_auth_middleware
node_catalog_routes -.->|"dispatches"| node_catalog_service
node_copy_controller -->|"calls"| node_catalog_service
node_catalog_service -->|"uses rules"| node_catalog_rules
node_catalog_rules -->|"normalizes ISBN"| node_isbn
node_loan_routes -.->|"dispatches"| node_loan_service
node_loan_service -.->|"records activity"| node_history
node_insight_routes -->|"uses date rules"| node_forecast_algorithm
node_insight_routes -.->|"reads history"| node_mysql
node_auth_model -.->|"persists users"| node_mysql
node_catalog_service -.->|"reads and writes"| node_mysql
node_loan_service -.->|"reads and writes"| node_mysql

click node_client_app "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/ung-dung/App.jsx"
click node_client_auth "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/chuc-nang/xac-thuc/TrangDangNhap.jsx"
click node_client_catalog "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/chuc-nang/sach/TrangQuanLySach.jsx"
click node_client_circulation "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/chuc-nang/muon-tra/TrangMuonTra.jsx"
click node_client_reader "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/chuc-nang/doc-gia/TrangLichSuMuon.jsx"
click node_client_analytics "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/chuc-nang/phan-tich/TrangDuBao.jsx"
click node_client_public "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/chuc-nang/api-cong-khai/dich-vu-cong-khai.js"
click node_http "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/thu-vien/api/ket-noi-http.js"
click node_express "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/app-factory.js"
click node_auth_routes "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/routes/xac-thuc.routes.js"
click node_auth_controller "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/controllers/xac-thuc.controller.js"
click node_auth_service "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/services/xac-thuc.service.js"
click node_auth_model "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/models/xac-thuc.model.js"
click node_auth_middleware "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/middlewares/xac-thuc.js"
click node_catalog_routes "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/routes/sach.routes.js"
click node_catalog_service "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/services/sach.service.js"
click node_copy_controller "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/controllers/ban-sao-sach.controller.js"
click node_catalog_rules "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/utils/kiem-tra-sach.js"
click node_isbn "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/chung/isbn.mjs"
click node_loan_routes "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/routes/phieu-muon.routes.js"
click node_loan_service "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/services/phieu-muon.service.js"
click node_history "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/services/lich-su-su-dung.service.js"
click node_insight_routes "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/routes/du-bao.routes.js"
click node_forecast_algorithm "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/utils/thuat-toan-du-bao.js"
click node_mysql "https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/config/co-so-du-lieu.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_client_app,node_http toneBlue
class node_client_auth,node_auth_routes,node_auth_controller,node_auth_service,node_auth_model,node_auth_middleware toneAmber
class node_client_catalog,node_client_public,node_catalog_routes,node_catalog_service,node_copy_controller,node_catalog_rules,node_isbn,node_api_external toneMint
class node_client_circulation,node_client_reader,node_loan_routes,node_loan_service,node_history toneRose
class node_client_analytics,node_insight_routes,node_forecast_algorithm,node_staff,node_reader,node_admin toneIndigo
class node_express,node_mysql toneTeal
```

## Components

### React application

- [App and routing](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/ung-dung/App.jsx): `Frontend/src/ung-dung/App.jsx`
- [HTTP API client](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/thu-vien/api/ket-noi-http.js): `Frontend/src/thu-vien/api/ket-noi-http.js`

### Identity and access

- [Sign-in and account](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/chuc-nang/xac-thuc/TrangDangNhap.jsx): `Frontend/src/chuc-nang/xac-thuc/TrangDangNhap.jsx`
- [Authentication routes](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/routes/xac-thuc.routes.js): `Backend/src/routes/xac-thuc.routes.js`
- [Authentication handlers](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/controllers/xac-thuc.controller.js): `Backend/src/controllers/xac-thuc.controller.js`
- [Authentication service](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/services/xac-thuc.service.js): `Backend/src/services/xac-thuc.service.js`
- [User and auth models](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/models/xac-thuc.model.js): `Backend/src/models/xac-thuc.model.js`
- [Token and permission checks](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/middlewares/xac-thuc.js): `Backend/src/middlewares/xac-thuc.js`

### Catalog management

- [Book management](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/chuc-nang/sach/TrangQuanLySach.jsx): `Frontend/src/chuc-nang/sach/TrangQuanLySach.jsx`
- [Public API query](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/chuc-nang/api-cong-khai/dich-vu-cong-khai.js): `Frontend/src/chuc-nang/api-cong-khai/dich-vu-cong-khai.js`
- [Catalog routes](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/routes/sach.routes.js): `Backend/src/routes/sach.routes.js`
- [Books and copies services](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/services/sach.service.js): `Backend/src/services/sach.service.js`
- [Copy handlers](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/controllers/ban-sao-sach.controller.js): `Backend/src/controllers/ban-sao-sach.controller.js`
- [Catalog validation](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/utils/kiem-tra-sach.js): `Backend/src/utils/kiem-tra-sach.js`
- [ISBN normalization](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/chung/isbn.mjs): `chung/isbn.mjs`

### Circulation

- [Borrow and return](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/chuc-nang/muon-tra/TrangMuonTra.jsx): `Frontend/src/chuc-nang/muon-tra/TrangMuonTra.jsx`
- [Reader history](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/chuc-nang/doc-gia/TrangLichSuMuon.jsx): `Frontend/src/chuc-nang/doc-gia/TrangLichSuMuon.jsx`
- [Loan routes](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/routes/phieu-muon.routes.js): `Backend/src/routes/phieu-muon.routes.js`
- [Loan and return rules](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/services/phieu-muon.service.js): `Backend/src/services/phieu-muon.service.js`
- [Usage and loan history](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/services/lich-su-su-dung.service.js): `Backend/src/services/lich-su-su-dung.service.js`

### Analytics and platform

- [Statistics and forecasts](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Frontend/src/chuc-nang/phan-tich/TrangDuBao.jsx): `Frontend/src/chuc-nang/phan-tich/TrangDuBao.jsx`
- [Statistics and forecast routes](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/routes/du-bao.routes.js): `Backend/src/routes/du-bao.routes.js`
- [Forecast algorithm](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/utils/thuat-toan-du-bao.js): `Backend/src/utils/thuat-toan-du-bao.js`

### API and persistence

- [Express app and routes](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/app-factory.js): `Backend/src/app-factory.js`
- [MySQL database](https://github.com/builequochung2k5/builequochung2k5k23cnt3_builequochung_doantotnghiep/blob/main/Backend/src/config/co-so-du-lieu.js): `Backend/src/config/co-so-du-lieu.js`

### Other components

- **Library staff**
- **Reader**
- **Administrator**
- **Public API consumer**

## Connections

- Library staff → App and routing: uses (evidence: `README.md`)
- Reader → App and routing: uses (evidence: `README.md`)
- Administrator → App and routing: uses (evidence: `README.md`)
- App and routing → Sign-in and account: routes to
- App and routing → Book management: routes to
- App and routing → Borrow and return: routes to
- App and routing → Statistics and forecasts: routes to
- Sign-in and account → HTTP API client: sends requests
- Book management → HTTP API client: sends requests (evidence: `Frontend/src/chuc-nang/sach/TrangQuanLySach.jsx`)
- Borrow and return → HTTP API client: sends requests
- Reader history → HTTP API client: loads history
- Statistics and forecasts → HTTP API client: requests insights
- Public API consumer → Public API query: queries
- Public API query → HTTP API client: sends requests
- HTTP API client → Express app and routes: calls API (evidence: `README.md`)
- Express app and routes → Authentication routes: registers (evidence: `Backend/src/app-factory.js`)
- Express app and routes → Catalog routes: registers (evidence: `Backend/src/app-factory.js`)
- Express app and routes → Loan routes: registers (evidence: `Backend/src/app-factory.js`)
- Express app and routes → Statistics and forecast routes: registers (evidence: `Backend/src/app-factory.js`)
- Authentication routes → Authentication handlers: dispatches (evidence: `Backend/src/routes/xac-thuc.routes.js`)
- Authentication handlers → Authentication service: calls (evidence: `Backend/src/controllers/xac-thuc.controller.js`)
- Authentication service → User and auth models: reads and writes (evidence: `Backend/src/services/xac-thuc.service.js`)
- Authentication routes → Token and permission checks: guards routes (evidence: `Backend/src/routes/xac-thuc.routes.js`)
- Catalog routes → Books and copies services: dispatches
- Copy handlers → Books and copies services: calls (evidence: `Backend/src/controllers/ban-sao-sach.controller.js`)
- Books and copies services → Catalog validation: uses rules
- Catalog validation → ISBN normalization: normalizes ISBN (evidence: `Backend/src/utils/kiem-tra-sach.js`)
- Loan routes → Loan and return rules: dispatches
- Loan and return rules → Usage and loan history: records activity
- Statistics and forecast routes → Forecast algorithm: uses date rules (evidence: `Backend/src/routes/du-bao.routes.js`)
- Statistics and forecast routes → MySQL database: reads history
- User and auth models → MySQL database: persists users
- Books and copies services → MySQL database: reads and writes
- Loan and return rules → MySQL database: reads and writes
