# tranquangthanh902-source/tranquangthanh_24ct1_cnpm architecture

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

- Interactive diagram: https://gitdiagram.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm
- Repository: https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm

## Overview

Thư Viện Số is an Express/EJS library-management web application backed by SQLite. Users browse public book search, while authenticated staff manage accounts, books, readers, loans and returns, and view dashboard and statistical reports. The graph separates route handlers, rendered screens, and persistent state. Source excerpts support the listed dispatches, database operations, and rendering; some README capabilities, such as responsive styling and print reporting, are represented through their existing UI paths rather than detailed implementation links.

Main entry points: [`server.js`](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/server.js) (Express server), [`database/init.js`](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/database/init.js) (Library database), [`routes/index.js`](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/index.js) (Landing and dashboard), [`routes/auth.js`](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/auth.js) (Login and registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Web runtime"]
  node_server["Express server<br/>[server.js]"]
  node_home["Landing and dashboard<br/>[index.js]"]
  node_homeui["Landing and dashboard screens"]
  node_sqlite[("Library database<br/>[init.js]")]
end

subgraph group_identity["Access and accounts"]
  node_authgate["Authentication gate<br/>[auth.js]"]
  node_accounts["Login and registration<br/>[auth.js]"]
  node_accountui["Account screens"]
end

subgraph group_catalog["Library catalog"]
  node_bookroutes["Book management<br/>[books.js]"]
  node_bookui["Book screens"]
  node_readerroutes["Reader management<br/>[readers.js]"]
  node_readerui["Reader screens"]
end

subgraph group_circulation["Circulation"]
  node_loans["Borrow and return<br/>[borrow.js]"]
  node_loanui["Loan screens"]
end

subgraph group_insight["Discovery and reporting"]
  node_search["Public book search<br/>[search.js]"]
  node_searchui["Search screen<br/>[search.ejs]"]
  node_reports["Statistics and reports<br/>[reports.js]"]
  node_reportui["Report screen"]
end

node_visitor(("Visitor or staff"))

node_visitor -->|"sends requests"| node_server
node_server -->|"dispatches"| node_accounts
node_server -->|"dispatches"| node_home
node_server -->|"dispatches"| node_search
node_server -->|"guards admin routes"| node_authgate
node_server -->|"dispatches"| node_bookroutes
node_server -->|"dispatches"| node_readerroutes
node_server -->|"dispatches"| node_loans
node_server -->|"dispatches"| node_reports
node_server -->|"initializes"| node_sqlite
node_accounts -->|"reads and writes"| node_sqlite
node_accounts -->|"renders"| node_accountui
node_home -->|"reads statistics"| node_sqlite
node_home -->|"renders"| node_homeui
node_bookroutes -->|"reads and writes"| node_sqlite
node_bookroutes -->|"renders"| node_bookui
node_readerroutes -->|"reads and writes"| node_sqlite
node_readerroutes -->|"renders"| node_readerui
node_loans -->|"updates loan state"| node_sqlite
node_loans -->|"renders"| node_loanui
node_search -->|"queries books"| node_sqlite
node_search -->|"renders"| node_searchui
node_reports -->|"queries statistics"| node_sqlite
node_reports -->|"renders"| node_reportui

click node_server "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/server.js"
click node_authgate "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/middleware/auth.js"
click node_accounts "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/auth.js"
click node_accountui "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/tree/main/views"
click node_home "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/index.js"
click node_homeui "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/tree/main/views"
click node_bookroutes "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/books.js"
click node_bookui "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/tree/main/views/books"
click node_readerroutes "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/readers.js"
click node_readerui "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/tree/main/views/readers"
click node_loans "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/borrow.js"
click node_loanui "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/tree/main/views/borrow"
click node_search "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/search.js"
click node_searchui "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/views/search.ejs"
click node_reports "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/reports.js"
click node_reportui "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/tree/main/views/reports"
click node_sqlite "https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/database/init.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_server,node_home,node_homeui,node_sqlite toneBlue
class node_authgate,node_accounts,node_accountui toneAmber
class node_bookroutes,node_bookui,node_readerroutes,node_readerui toneMint
class node_loans,node_loanui toneRose
class node_search,node_searchui,node_reports,node_reportui,node_visitor toneIndigo
```

## Components

### Web runtime

- [Express server](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/server.js): `server.js`
- [Landing and dashboard](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/index.js): `routes/index.js`
- [Landing and dashboard screens](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/tree/main/views): `views`
- [Library database](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/database/init.js): `database/init.js`

### Access and accounts

- [Authentication gate](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/middleware/auth.js): `middleware/auth.js`
- [Login and registration](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/auth.js): `routes/auth.js`
- [Account screens](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/tree/main/views): `views`

### Library catalog

- [Book management](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/books.js): `routes/books.js`
- [Book screens](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/tree/main/views/books): `views/books`
- [Reader management](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/readers.js): `routes/readers.js`
- [Reader screens](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/tree/main/views/readers): `views/readers`

### Circulation

- [Borrow and return](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/borrow.js): `routes/borrow.js`
- [Loan screens](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/tree/main/views/borrow): `views/borrow`

### Discovery and reporting

- [Public book search](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/search.js): `routes/search.js`
- [Search screen](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/views/search.ejs): `views/search.ejs`
- [Statistics and reports](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/blob/main/routes/reports.js): `routes/reports.js`
- [Report screen](https://github.com/tranquangthanh902-source/tranquangthanh_24ct1_cnpm/tree/main/views/reports): `views/reports`

### Other components

- **Visitor or staff**

## Connections

- Visitor or staff → Express server: sends requests
- Express server → Login and registration: dispatches
- Express server → Landing and dashboard: dispatches
- Express server → Public book search: dispatches
- Express server → Authentication gate: guards admin routes
- Express server → Book management: dispatches
- Express server → Reader management: dispatches
- Express server → Borrow and return: dispatches
- Express server → Statistics and reports: dispatches
- Express server → Library database: initializes
- Login and registration → Library database: reads and writes
- Login and registration → Account screens: renders
- Landing and dashboard → Library database: reads statistics
- Landing and dashboard → Landing and dashboard screens: renders
- Book management → Library database: reads and writes
- Book management → Book screens: renders
- Reader management → Library database: reads and writes
- Reader management → Reader screens: renders
- Borrow and return → Library database: updates loan state
- Borrow and return → Loan screens: renders
- Public book search → Library database: queries books
- Public book search → Search screen: renders
- Statistics and reports → Library database: queries statistics
- Statistics and reports → Report screen: renders
