# poxndering/book_library architecture

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

- Interactive diagram: https://gitdiagram.com/poxndering/book_library
- Repository: https://github.com/poxndering/book_library

## Overview

Book Library App is a full-stack personal book catalog with login, book management, and category statistics. Users enter through the login page; the login form delegates authentication state to the context, while the frontend services communicate with the Express API. API routes dispatch to authentication and book controllers, which access the configured database. The README documents PostgreSQL and SQLite options and describes the protected book dashboard. Some dashboard-to-component and context-to-service wiring is not shown in the sampled source, so those links are marked unverified.

Main entry points: [`frontend/app/(protected)/book-dashboard/page.js`](https://github.com/poxndering/book_library/blob/main/frontend/app/(protected)/book-dashboard/page.js) (Book dashboard), [`frontend/components/features/auth/LoginForm.js`](https://github.com/poxndering/book_library/blob/main/frontend/components/features/auth/LoginForm.js) (Login form), [`frontend/components/features/books/BookForm.js`](https://github.com/poxndering/book_library/blob/main/frontend/components/features/books/BookForm.js) (Book form), [`frontend/services/api.js`](https://github.com/poxndering/book_library/blob/main/frontend/services/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend app"]
  node_loginpage["Login page<br/>[page.js]"]
  node_loginform["Login form<br/>[LoginForm.js]"]
  node_authcontext["Auth context<br/>[AuthContext.js]"]
  node_dashboard["Book dashboard<br/>[page.js]"]
  node_bookform["Book form<br/>[BookForm.js]"]
  node_booklist["Book list<br/>[BookList.js]"]
  node_bookstats["Book statistics<br/>[BookStats.js]"]
  node_authservice["Auth service<br/>[authService.js]"]
  node_bookservice["Book service<br/>[bookService.js]"]
  node_api["API client<br/>[api.js]"]
  node_token["Token storage<br/>[auth.js]"]
end

subgraph group_backend["Backend API"]
  node_server["Express server<br/>[server.js]"]
  node_routes["API route index<br/>[index.js]"]
  node_authroutes["Auth routes<br/>[auth.routes.js]"]
  node_bookroutes["Book routes<br/>[book.routes.js]"]
  node_authcontroller["Login controller<br/>[auth.controller.js]"]
  node_bookcontroller["Book controller<br/>[book.controller.js]"]
  node_authmiddleware["Auth middleware<br/>[auth.middleware.js]"]
end

subgraph group_storage["Data storage"]
  node_dbconfig["Database config<br/>[db.js]"]
  node_knex["Knex configuration<br/>[knexfile.js]"]
  node_database[("PostgreSQL / SQLite")]
end

subgraph group_ui["UI components"]
  node_uiinput["Input control<br/>[Input.js]"]
  node_uibutton["Button control<br/>[Button.js]"]
  node_uiselect["Select control<br/>[Select.js]"]
end

node_visitor(("Library user"))

node_visitor -->|"opens"| node_loginpage
node_loginpage -->|"renders"| node_loginform
node_loginform -->|"uses login"| node_authcontext
node_loginform -->|"renders"| node_uiinput
node_loginform -->|"renders"| node_uibutton
node_authcontext -.->|"delegates"| node_authservice
node_authservice -->|"sends login"| node_api
node_authservice -->|"stores token"| node_token
node_api -->|"reads token"| node_token
node_api -.->|"calls API"| node_server
node_visitor -->|"manages books"| node_dashboard
node_dashboard -.->|"uses"| node_bookform
node_dashboard -.->|"uses"| node_booklist
node_dashboard -.->|"uses"| node_bookstats
node_bookform -->|"renders"| node_uiselect
node_bookform -->|"renders"| node_uiinput
node_bookform -->|"renders"| node_uibutton
node_dashboard -.->|"loads books"| node_bookservice
node_bookservice -->|"sends requests"| node_api
node_server -->|"mounts routes"| node_routes
node_routes -->|"registers"| node_authroutes
node_routes -->|"registers"| node_bookroutes
node_authroutes -->|"dispatches login"| node_authcontroller
node_bookroutes -->|"dispatches books"| node_bookcontroller
node_bookroutes -->|"protects writes"| node_authmiddleware
node_authcontroller -->|"queries users"| node_dbconfig
node_bookcontroller -->|"queries books"| node_dbconfig
node_dbconfig -->|"loads config"| node_knex
node_knex -->|"configures connection"| node_database
node_dbconfig -.->|"accesses records"| node_database

click node_loginpage "https://github.com/poxndering/book_library/blob/main/frontend/app/(auth)/login/page.js"
click node_loginform "https://github.com/poxndering/book_library/blob/main/frontend/components/features/auth/LoginForm.js"
click node_authcontext "https://github.com/poxndering/book_library/blob/main/frontend/context/AuthContext.js"
click node_dashboard "https://github.com/poxndering/book_library/blob/main/frontend/app/(protected)/book-dashboard/page.js"
click node_bookform "https://github.com/poxndering/book_library/blob/main/frontend/components/features/books/BookForm.js"
click node_booklist "https://github.com/poxndering/book_library/blob/main/frontend/components/features/books/BookList.js"
click node_bookstats "https://github.com/poxndering/book_library/blob/main/frontend/components/features/books/BookStats.js"
click node_authservice "https://github.com/poxndering/book_library/blob/main/frontend/services/authService.js"
click node_bookservice "https://github.com/poxndering/book_library/blob/main/frontend/services/bookService.js"
click node_api "https://github.com/poxndering/book_library/blob/main/frontend/services/api.js"
click node_token "https://github.com/poxndering/book_library/blob/main/frontend/utils/auth.js"
click node_uiinput "https://github.com/poxndering/book_library/blob/main/frontend/components/ui/Input.js"
click node_uibutton "https://github.com/poxndering/book_library/blob/main/frontend/components/ui/Button.js"
click node_uiselect "https://github.com/poxndering/book_library/blob/main/frontend/components/ui/Select.js"
click node_server "https://github.com/poxndering/book_library/blob/main/backend/src/server.js"
click node_routes "https://github.com/poxndering/book_library/blob/main/backend/src/routes/index.js"
click node_authroutes "https://github.com/poxndering/book_library/blob/main/backend/src/routes/auth.routes.js"
click node_bookroutes "https://github.com/poxndering/book_library/blob/main/backend/src/routes/book.routes.js"
click node_authcontroller "https://github.com/poxndering/book_library/blob/main/backend/src/controllers/auth.controller.js"
click node_bookcontroller "https://github.com/poxndering/book_library/blob/main/backend/src/controllers/book.controller.js"
click node_authmiddleware "https://github.com/poxndering/book_library/blob/main/backend/src/middlewares/auth.middleware.js"
click node_dbconfig "https://github.com/poxndering/book_library/blob/main/backend/src/config/db.js"
click node_knex "https://github.com/poxndering/book_library/blob/main/backend/knexfile.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_loginpage,node_loginform,node_authcontext,node_dashboard,node_bookform,node_booklist,node_bookstats,node_authservice,node_bookservice,node_api,node_token,node_visitor toneBlue
class node_server,node_routes,node_authroutes,node_bookroutes,node_authcontroller,node_bookcontroller,node_authmiddleware toneAmber
class node_dbconfig,node_knex,node_database toneMint
class node_uiinput,node_uibutton,node_uiselect toneRose
```

## Components

### Frontend app

- [Login page](https://github.com/poxndering/book_library/blob/main/frontend/app/(auth)/login/page.js): `frontend/app/(auth)/login/page.js`
- [Login form](https://github.com/poxndering/book_library/blob/main/frontend/components/features/auth/LoginForm.js): `frontend/components/features/auth/LoginForm.js`
- [Auth context](https://github.com/poxndering/book_library/blob/main/frontend/context/AuthContext.js): `frontend/context/AuthContext.js`
- [Book dashboard](https://github.com/poxndering/book_library/blob/main/frontend/app/(protected)/book-dashboard/page.js): `frontend/app/(protected)/book-dashboard/page.js`
- [Book form](https://github.com/poxndering/book_library/blob/main/frontend/components/features/books/BookForm.js): `frontend/components/features/books/BookForm.js`
- [Book list](https://github.com/poxndering/book_library/blob/main/frontend/components/features/books/BookList.js): `frontend/components/features/books/BookList.js`
- [Book statistics](https://github.com/poxndering/book_library/blob/main/frontend/components/features/books/BookStats.js): `frontend/components/features/books/BookStats.js`
- [Auth service](https://github.com/poxndering/book_library/blob/main/frontend/services/authService.js): `frontend/services/authService.js`
- [Book service](https://github.com/poxndering/book_library/blob/main/frontend/services/bookService.js): `frontend/services/bookService.js`
- [API client](https://github.com/poxndering/book_library/blob/main/frontend/services/api.js): `frontend/services/api.js`
- [Token storage](https://github.com/poxndering/book_library/blob/main/frontend/utils/auth.js): `frontend/utils/auth.js`

### Backend API

- [Express server](https://github.com/poxndering/book_library/blob/main/backend/src/server.js): `backend/src/server.js`
- [API route index](https://github.com/poxndering/book_library/blob/main/backend/src/routes/index.js): `backend/src/routes/index.js`
- [Auth routes](https://github.com/poxndering/book_library/blob/main/backend/src/routes/auth.routes.js): `backend/src/routes/auth.routes.js`
- [Book routes](https://github.com/poxndering/book_library/blob/main/backend/src/routes/book.routes.js): `backend/src/routes/book.routes.js`
- [Login controller](https://github.com/poxndering/book_library/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [Book controller](https://github.com/poxndering/book_library/blob/main/backend/src/controllers/book.controller.js): `backend/src/controllers/book.controller.js`
- [Auth middleware](https://github.com/poxndering/book_library/blob/main/backend/src/middlewares/auth.middleware.js): `backend/src/middlewares/auth.middleware.js`

### Data storage

- [Database config](https://github.com/poxndering/book_library/blob/main/backend/src/config/db.js): `backend/src/config/db.js`
- [Knex configuration](https://github.com/poxndering/book_library/blob/main/backend/knexfile.js): `backend/knexfile.js`
- **PostgreSQL / SQLite**

### UI components

- [Input control](https://github.com/poxndering/book_library/blob/main/frontend/components/ui/Input.js): `frontend/components/ui/Input.js`
- [Button control](https://github.com/poxndering/book_library/blob/main/frontend/components/ui/Button.js): `frontend/components/ui/Button.js`
- [Select control](https://github.com/poxndering/book_library/blob/main/frontend/components/ui/Select.js): `frontend/components/ui/Select.js`

### Other components

- **Library user**

## Connections

- Library user → Login page: opens (evidence: `README.md`)
- Login page → Login form: renders (evidence: `frontend/app/(auth)/login/page.js`)
- Login form → Auth context: uses login (evidence: `frontend/components/features/auth/LoginForm.js`)
- Login form → Input control: renders (evidence: `frontend/components/features/auth/LoginForm.js`)
- Login form → Button control: renders (evidence: `frontend/components/features/auth/LoginForm.js`)
- Auth context → Auth service: delegates
- Auth service → API client: sends login (evidence: `frontend/services/authService.js`)
- Auth service → Token storage: stores token (evidence: `frontend/services/authService.js`)
- API client → Token storage: reads token (evidence: `frontend/services/api.js`)
- API client → Express server: calls API
- Library user → Book dashboard: manages books (evidence: `README.md`)
- Book dashboard → Book form: uses
- Book dashboard → Book list: uses
- Book dashboard → Book statistics: uses
- Book form → Select control: renders (evidence: `frontend/components/features/books/BookForm.js`)
- Book form → Input control: renders (evidence: `frontend/components/features/books/BookForm.js`)
- Book form → Button control: renders (evidence: `frontend/components/features/books/BookForm.js`)
- Book dashboard → Book service: loads books
- Book service → API client: sends requests (evidence: `frontend/services/bookService.js`)
- Express server → API route index: mounts routes (evidence: `backend/src/server.js`)
- API route index → Auth routes: registers (evidence: `backend/src/routes/index.js`)
- API route index → Book routes: registers (evidence: `backend/src/routes/index.js`)
- Auth routes → Login controller: dispatches login (evidence: `backend/src/routes/auth.routes.js`)
- Book routes → Book controller: dispatches books (evidence: `backend/src/routes/book.routes.js`)
- Book routes → Auth middleware: protects writes (evidence: `backend/src/routes/book.routes.js`)
- Login controller → Database config: queries users (evidence: `backend/src/controllers/auth.controller.js`)
- Book controller → Database config: queries books (evidence: `backend/src/controllers/book.controller.js`)
- Database config → Knex configuration: loads config (evidence: `backend/src/config/db.js`)
- Knex configuration → PostgreSQL / SQLite: configures connection (evidence: `README.md`)
- Database config → PostgreSQL / SQLite: accesses records
