# thiagops5/jwt-api architecture

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

- Interactive diagram: https://gitdiagram.com/thiagops5/jwt-api
- Repository: https://github.com/thiagops5/jwt-api

## Overview

This is a Node.js REST API for library operations. The main workflow is an attendant or administrator sending requests to the API: authentication and role checks gate resource operations; catalog and reader records support loan creation and returns; the API persists state in SQLite and exposes administrator dashboard totals. The README documents the domain capabilities and module layering. Relationships below are limited to README statements and source-index references or excerpts; unsampled implementation details are not inferred.

Main entry points: [`index.js`](https://github.com/thiagops5/jwt-api/blob/main/index.js) (HTTP Server), [`models/index.js`](https://github.com/thiagops5/jwt-api/blob/main/models/index.js) (Model Associations), [`auth/auth.service.js`](https://github.com/thiagops5/jwt-api/blob/main/auth/auth.service.js) (Token Service), [`auth/auth.router.js`](https://github.com/thiagops5/jwt-api/blob/main/auth/auth.router.js) (Auth Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and Auth"]
  node_entry["HTTP Server<br/>[index.js]"]
  node_auth_routes["Auth Routes<br/>[auth.router.js]"]
  node_auth_controller["Auth Controller<br/>[auth.controller.js]"]
  node_auth_service["Token Service<br/>[auth.service.js]"]
  node_auth_middleware["Auth Guards<br/>[auth.middleware.js]"]
  node_refresh_tokens[("Refresh Tokens")]
  node_logout_list[("Logout Blacklist")]
end

subgraph group_catalog["People and Catalog"]
  node_user_routes["User Routes<br/>[user.router.js]"]
  node_user_controller["User Controller<br/>[user.controller.js]"]
  node_user_service["User Service<br/>[user.service.js]"]
  node_user_model[("User Model<br/>[user.model.js]")]
  node_category["Category API"]
  node_category_service["Category Service"]
  node_author["Author API"]
  node_author_service["Author Service<br/>[author.service.js]"]
  node_books["Book API<br/>[book.controller.js]"]
  node_book_service["Book Service<br/>[book.service.js]"]
end

subgraph group_circulation["Circulation"]
  node_reader["Reader API"]
  node_reader_service["Reader Service<br/>[reader.service.js]"]
  node_loans["Loan API<br/>[loan.controller.js]"]
  node_loan_service["Loan Service<br/>[loan.service.js]"]
end

subgraph group_reporting["Reporting"]
  node_reports["Dashboard API"]
  node_report_service["Report Service<br/>[report.service.js]"]
end

subgraph group_persistence["Persistence"]
  node_model_registry["Model Associations<br/>[index.js]"]
  node_sqlite_config["SQLite Connection<br/>[db.js]"]
  node_sqlite[("SQLite Store<br/>[database.sqlite]")]
end

node_client(("API Client"))

node_client -->|"sends requests"| node_entry
node_entry -->|"mounts routes"| node_auth_routes
node_entry -->|"mounts routes"| node_user_routes
node_entry -->|"mounts routes"| node_category
node_entry -->|"mounts routes"| node_author
node_entry -->|"mounts routes"| node_books
node_entry -->|"mounts routes"| node_reader
node_entry -->|"mounts routes"| node_loans
node_entry -->|"mounts routes"| node_reports
node_entry -->|"connects database"| node_sqlite_config
node_entry -->|"initializes models"| node_model_registry
node_entry -.->|"loads seed"| node_auth_routes
node_auth_routes -->|"routes requests"| node_auth_controller
node_auth_routes -->|"guards routes"| node_auth_middleware
node_auth_controller -->|"calls"| node_auth_service
node_auth_middleware -->|"verifies tokens"| node_auth_service
node_auth_service -->|"looks up users"| node_user_service
node_auth_service -->|"rotates tokens"| node_refresh_tokens
node_auth_service -->|"blacklists tokens"| node_logout_list
node_user_routes -->|"routes requests"| node_user_controller
node_user_routes -->|"guards routes"| node_auth_middleware
node_user_controller -->|"calls"| node_user_service
node_user_service -->|"queries users"| node_user_model
node_category -->|"calls"| node_category_service
node_category_service -->|"uses models"| node_model_registry
node_author -->|"calls"| node_author_service
node_author_service -->|"uses models"| node_model_registry
node_books -->|"calls"| node_book_service
node_book_service -->|"uses models"| node_model_registry
node_reader -->|"calls"| node_reader_service
node_reader_service -->|"uses models"| node_model_registry
node_loans -->|"calls"| node_loan_service
node_loan_service -->|"uses models"| node_model_registry
node_reports -->|"calls"| node_report_service
node_report_service -->|"uses models"| node_model_registry
node_model_registry -->|"uses connection"| node_sqlite_config
node_sqlite_config -->|"stores data"| node_sqlite

click node_entry "https://github.com/thiagops5/jwt-api/blob/main/index.js"
click node_auth_routes "https://github.com/thiagops5/jwt-api/blob/main/auth/auth.router.js"
click node_auth_controller "https://github.com/thiagops5/jwt-api/blob/main/auth/auth.controller.js"
click node_auth_service "https://github.com/thiagops5/jwt-api/blob/main/auth/auth.service.js"
click node_auth_middleware "https://github.com/thiagops5/jwt-api/blob/main/auth/auth.middleware.js"
click node_refresh_tokens "https://github.com/thiagops5/jwt-api/blob/main/auth/refreshToken.model.js"
click node_logout_list "https://github.com/thiagops5/jwt-api/blob/main/auth/logoutList.model.js"
click node_user_routes "https://github.com/thiagops5/jwt-api/blob/main/user/user.router.js"
click node_user_controller "https://github.com/thiagops5/jwt-api/blob/main/user/user.controller.js"
click node_user_service "https://github.com/thiagops5/jwt-api/blob/main/user/user.service.js"
click node_user_model "https://github.com/thiagops5/jwt-api/blob/main/user/user.model.js"
click node_category "https://github.com/thiagops5/jwt-api/blob/main/category/category.controller.js"
click node_category_service "https://github.com/thiagops5/jwt-api/blob/main/category/category.service.js"
click node_author "https://github.com/thiagops5/jwt-api/blob/main/author/author.controller.js"
click node_author_service "https://github.com/thiagops5/jwt-api/blob/main/author/author.service.js"
click node_books "https://github.com/thiagops5/jwt-api/blob/main/book/book.controller.js"
click node_book_service "https://github.com/thiagops5/jwt-api/blob/main/book/book.service.js"
click node_reader "https://github.com/thiagops5/jwt-api/blob/main/reader/reader.controller.js"
click node_reader_service "https://github.com/thiagops5/jwt-api/blob/main/reader/reader.service.js"
click node_loans "https://github.com/thiagops5/jwt-api/blob/main/loan/loan.controller.js"
click node_loan_service "https://github.com/thiagops5/jwt-api/blob/main/loan/loan.service.js"
click node_reports "https://github.com/thiagops5/jwt-api/blob/main/report/report.controller.js"
click node_report_service "https://github.com/thiagops5/jwt-api/blob/main/report/report.service.js"
click node_model_registry "https://github.com/thiagops5/jwt-api/blob/main/models/index.js"
click node_sqlite_config "https://github.com/thiagops5/jwt-api/blob/main/config/db.js"
click node_sqlite "https://github.com/thiagops5/jwt-api/blob/main/database.sqlite"

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_entry,node_auth_routes,node_auth_controller,node_auth_service,node_auth_middleware,node_refresh_tokens,node_logout_list,node_client toneBlue
class node_user_routes,node_user_controller,node_user_service,node_user_model,node_category,node_category_service,node_author,node_author_service,node_books,node_book_service toneAmber
class node_reader,node_reader_service,node_loans,node_loan_service toneMint
class node_reports,node_report_service toneRose
class node_model_registry,node_sqlite_config,node_sqlite toneIndigo
```

## Components

### API and Auth

- [HTTP Server](https://github.com/thiagops5/jwt-api/blob/main/index.js): `index.js`
- [Auth Routes](https://github.com/thiagops5/jwt-api/blob/main/auth/auth.router.js): `auth/auth.router.js`
- [Auth Controller](https://github.com/thiagops5/jwt-api/blob/main/auth/auth.controller.js): `auth/auth.controller.js`
- [Token Service](https://github.com/thiagops5/jwt-api/blob/main/auth/auth.service.js): `auth/auth.service.js`
- [Auth Guards](https://github.com/thiagops5/jwt-api/blob/main/auth/auth.middleware.js): `auth/auth.middleware.js`
- [Refresh Tokens](https://github.com/thiagops5/jwt-api/blob/main/auth/refreshToken.model.js): `auth/refreshToken.model.js`
- [Logout Blacklist](https://github.com/thiagops5/jwt-api/blob/main/auth/logoutList.model.js): `auth/logoutList.model.js`

### People and Catalog

- [User Routes](https://github.com/thiagops5/jwt-api/blob/main/user/user.router.js): `user/user.router.js`
- [User Controller](https://github.com/thiagops5/jwt-api/blob/main/user/user.controller.js): `user/user.controller.js`
- [User Service](https://github.com/thiagops5/jwt-api/blob/main/user/user.service.js): `user/user.service.js`
- [User Model](https://github.com/thiagops5/jwt-api/blob/main/user/user.model.js): `user/user.model.js`
- [Category API](https://github.com/thiagops5/jwt-api/blob/main/category/category.controller.js): `category/category.controller.js`
- [Category Service](https://github.com/thiagops5/jwt-api/blob/main/category/category.service.js): `category/category.service.js`
- [Author API](https://github.com/thiagops5/jwt-api/blob/main/author/author.controller.js): `author/author.controller.js`
- [Author Service](https://github.com/thiagops5/jwt-api/blob/main/author/author.service.js): `author/author.service.js`
- [Book API](https://github.com/thiagops5/jwt-api/blob/main/book/book.controller.js): `book/book.controller.js`
- [Book Service](https://github.com/thiagops5/jwt-api/blob/main/book/book.service.js): `book/book.service.js`

### Circulation

- [Reader API](https://github.com/thiagops5/jwt-api/blob/main/reader/reader.controller.js): `reader/reader.controller.js`
- [Reader Service](https://github.com/thiagops5/jwt-api/blob/main/reader/reader.service.js): `reader/reader.service.js`
- [Loan API](https://github.com/thiagops5/jwt-api/blob/main/loan/loan.controller.js): `loan/loan.controller.js`
- [Loan Service](https://github.com/thiagops5/jwt-api/blob/main/loan/loan.service.js): `loan/loan.service.js`

### Reporting

- [Dashboard API](https://github.com/thiagops5/jwt-api/blob/main/report/report.controller.js): `report/report.controller.js`
- [Report Service](https://github.com/thiagops5/jwt-api/blob/main/report/report.service.js): `report/report.service.js`

### Persistence

- [Model Associations](https://github.com/thiagops5/jwt-api/blob/main/models/index.js): `models/index.js`
- [SQLite Connection](https://github.com/thiagops5/jwt-api/blob/main/config/db.js): `config/db.js`
- [SQLite Store](https://github.com/thiagops5/jwt-api/blob/main/database.sqlite): `database.sqlite`

### Other components

- **API Client**

## Connections

- API Client → HTTP Server: sends requests (evidence: `README.md`)
- HTTP Server → Auth Routes: mounts routes (evidence: `index.js`)
- HTTP Server → User Routes: mounts routes (evidence: `index.js`)
- HTTP Server → Category API: mounts routes (evidence: `index.js`)
- HTTP Server → Author API: mounts routes (evidence: `index.js`)
- HTTP Server → Book API: mounts routes (evidence: `index.js`)
- HTTP Server → Reader API: mounts routes (evidence: `index.js`)
- HTTP Server → Loan API: mounts routes (evidence: `index.js`)
- HTTP Server → Dashboard API: mounts routes (evidence: `index.js`)
- HTTP Server → SQLite Connection: connects database (evidence: `index.js`)
- HTTP Server → Model Associations: initializes models (evidence: `index.js`)
- HTTP Server → Auth Routes: loads seed (evidence: `index.js`)
- Auth Routes → Auth Controller: routes requests (evidence: `auth/auth.router.js`)
- Auth Routes → Auth Guards: guards routes (evidence: `auth/auth.router.js`)
- Auth Controller → Token Service: calls (evidence: `auth/auth.controller.js`)
- Auth Guards → Token Service: verifies tokens (evidence: `auth/auth.middleware.js`)
- Token Service → User Service: looks up users (evidence: `auth/auth.service.js`)
- Token Service → Refresh Tokens: rotates tokens (evidence: `auth/auth.service.js`)
- Token Service → Logout Blacklist: blacklists tokens (evidence: `auth/auth.service.js`)
- User Routes → User Controller: routes requests (evidence: `user/user.router.js`)
- User Routes → Auth Guards: guards routes (evidence: `user/user.router.js`)
- User Controller → User Service: calls (evidence: `user/user.controller.js`)
- User Service → User Model: queries users (evidence: `user/user.service.js`)
- Category API → Category Service: calls (evidence: `category/category.controller.js`)
- Category Service → Model Associations: uses models (evidence: `category/category.service.js`)
- Author API → Author Service: calls (evidence: `author/author.controller.js`)
- Author Service → Model Associations: uses models (evidence: `author/author.service.js`)
- Book API → Book Service: calls (evidence: `book/book.controller.js`)
- Book Service → Model Associations: uses models (evidence: `book/book.service.js`)
- Reader API → Reader Service: calls (evidence: `reader/reader.controller.js`)
- Reader Service → Model Associations: uses models (evidence: `reader/reader.service.js`)
- Loan API → Loan Service: calls (evidence: `loan/loan.controller.js`)
- Loan Service → Model Associations: uses models (evidence: `loan/loan.service.js`)
- Dashboard API → Report Service: calls (evidence: `report/report.controller.js`)
- Report Service → Model Associations: uses models (evidence: `report/report.service.js`)
- Model Associations → SQLite Connection: uses connection (evidence: `models/index.js`)
- SQLite Connection → SQLite Store: stores data (evidence: `config/db.js`)
