# xianworksc/library architecture

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

- Interactive diagram: https://gitdiagram.com/xianworksc/library
- Repository: https://github.com/xianworksc/library

## Overview

This repository is a small Express library application: users browse and manage book records, and can register, log in, and access a session-gated dashboard. Requests enter through the server and route table, then controllers render Xian templates or use Sequelize models backed by MySQL. The sampled files show these paths, but not template contents or all runtime details; the unused home handler is therefore shown without an inferred route.

Main entry points: [`controllers/authController.js`](https://github.com/xianworksc/library/blob/main/controllers/authController.js) (Auth handlers), [`index.js`](https://github.com/xianworksc/library/blob/main/index.js) (Express server), [`routes/index.js`](https://github.com/xianworksc/library/blob/main/routes/index.js) (Route table), [`controllers/book.js`](https://github.com/xianworksc/library/blob/main/controllers/book.js) (Book handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["Web server"]
  node_app["Express server<br/>[index.js]"]
  node_routes["Route table<br/>[index.js]"]
  node_views["Xian views"]
end

subgraph group_books["Book catalog"]
  node_book_controller["Book handlers<br/>[book.js]"]
  node_home_controller["Home handler<br/>[homeController.js]"]
end

subgraph group_accounts["Accounts"]
  node_auth_controller["Auth handlers<br/>[authController.js]"]
  node_bcrypt["Password hashing<br/>[authController.js]"]
end

subgraph group_persistence["Persistence"]
  node_books_model["Book model<br/>[Books.js]"]
  node_user_model["User model<br/>[userModel.js]"]
  node_database_config["Sequelize config<br/>[db.js]"]
end

node_visitor(("Visitor"))
node_mysql[("MySQL database")]

node_visitor -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_routes
node_routes -->|"dispatches books"| node_book_controller
node_routes -->|"dispatches auth"| node_auth_controller
node_book_controller -->|"reads and writes"| node_books_model
node_auth_controller -->|"reads and writes"| node_user_model
node_books_model -->|"uses connection"| node_database_config
node_user_model -->|"uses connection"| node_database_config
node_database_config -.->|"connects to"| node_mysql
node_book_controller -->|"renders pages"| node_views
node_auth_controller -->|"renders pages"| node_views
node_app -->|"configures rendering"| node_views
node_auth_controller -->|"hashes passwords"| node_bcrypt

click node_app "https://github.com/xianworksc/library/blob/main/index.js"
click node_routes "https://github.com/xianworksc/library/blob/main/routes/index.js"
click node_views "https://github.com/xianworksc/library/tree/main/views"
click node_book_controller "https://github.com/xianworksc/library/blob/main/controllers/book.js"
click node_home_controller "https://github.com/xianworksc/library/blob/main/controllers/homeController.js"
click node_books_model "https://github.com/xianworksc/library/blob/main/models/Books.js"
click node_auth_controller "https://github.com/xianworksc/library/blob/main/controllers/authController.js"
click node_user_model "https://github.com/xianworksc/library/blob/main/models/userModel.js"
click node_database_config "https://github.com/xianworksc/library/blob/main/models/db.js"
click node_bcrypt "https://github.com/xianworksc/library/blob/main/controllers/authController.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_routes,node_views toneBlue
class node_book_controller,node_home_controller,node_mysql toneAmber
class node_auth_controller,node_bcrypt toneMint
class node_books_model,node_user_model,node_database_config toneRose
class node_visitor toneIndigo
```

## Components

### Web server

- [Express server](https://github.com/xianworksc/library/blob/main/index.js): `index.js`
- [Route table](https://github.com/xianworksc/library/blob/main/routes/index.js): `routes/index.js`
- [Xian views](https://github.com/xianworksc/library/tree/main/views): `views`

### Book catalog

- [Book handlers](https://github.com/xianworksc/library/blob/main/controllers/book.js): `controllers/book.js`
- [Home handler](https://github.com/xianworksc/library/blob/main/controllers/homeController.js): `controllers/homeController.js`

### Accounts

- [Auth handlers](https://github.com/xianworksc/library/blob/main/controllers/authController.js): `controllers/authController.js`
- [Password hashing](https://github.com/xianworksc/library/blob/main/controllers/authController.js): `controllers/authController.js`

### Persistence

- [Book model](https://github.com/xianworksc/library/blob/main/models/Books.js): `models/Books.js`
- [User model](https://github.com/xianworksc/library/blob/main/models/userModel.js): `models/userModel.js`
- [Sequelize config](https://github.com/xianworksc/library/blob/main/models/db.js): `models/db.js`

### Other components

- **Visitor**
- **MySQL database**

## Connections

- Visitor → Express server: sends requests
- Express server → Route table: mounts routes (evidence: `index.js`)
- Route table → Book handlers: dispatches books (evidence: `routes/index.js`)
- Route table → Auth handlers: dispatches auth (evidence: `routes/index.js`)
- Book handlers → Book model: reads and writes (evidence: `controllers/book.js`)
- Auth handlers → User model: reads and writes (evidence: `controllers/authController.js`)
- Book model → Sequelize config: uses connection (evidence: `models/Books.js`)
- User model → Sequelize config: uses connection (evidence: `models/userModel.js`)
- Sequelize config → MySQL database: connects to (evidence: `models/db.js`)
- Book handlers → Xian views: renders pages (evidence: `controllers/book.js`)
- Auth handlers → Xian views: renders pages (evidence: `controllers/authController.js`)
- Express server → Xian views: configures rendering (evidence: `index.js`)
- Auth handlers → Password hashing: hashes passwords (evidence: `controllers/authController.js`)
