# flexcha/library-app architecture

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

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

## Overview

LibraryOS is a full-stack library-management system: readers and staff use a React SPA to manage accounts, discover books, circulate copies, handle reservations and fines, and view reports. The SPA sends REST/JSON requests to an Express API, whose routes dispatch to domain services backed by Prisma and a relational database. The README documents the overall API and persistence architecture; source excerpts and index references support several specific frontend and route-to-service links, while some domain internals were not sampled.

Main entry points: [`src/routes/index.ts`](https://github.com/flexcha/library-app/blob/main/src/routes/index.ts) (API router), [`src/App.tsx`](https://github.com/flexcha/library-app/blob/main/src/App.tsx) (SPA shell), [`src/api/client.ts`](https://github.com/flexcha/library-app/blob/main/src/api/client.ts) (REST client), [`src/context/AuthContext.tsx`](https://github.com/flexcha/library-app/blob/main/src/context/AuthContext.tsx) (Sign-in state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React application"]
  node_spa["SPA shell<br/>[App.tsx]"]
  node_authui["Sign-in state<br/>[AuthContext.tsx]"]
  node_catalogui["Catalog browsing<br/>[CatalogBrowse.tsx]"]
  node_circulationui["Circulation desk"]
  node_reservationui["Reservations view"]
  node_finesui["Fines view<br/>[FinesView.tsx]"]
  node_reportsui["Reports dashboard"]
  node_usersui["User management<br/>[UserManagement.tsx]"]
  node_apiclient["REST client<br/>[client.ts]"]
end

subgraph group_api["API and access"]
  node_server["Express server<br/>[server.ts]"]
  node_router["API router<br/>[index.ts]"]
  node_access["Auth and validation<br/>[authenticate.ts]"]
end

subgraph group_library["Library operations"]
  node_authdomain["Accounts and identity<br/>[auth.service.ts]"]
  node_catalog["Book catalog<br/>[book.service.ts]"]
  node_circulation["Loans and returns<br/>[loan.service.ts]"]
  node_reservations["Book reservations"]
  node_fines["Fines and penalties<br/>[fine.service.ts]"]
  node_reports["Library reporting<br/>[report.service.ts]"]
  node_notifications["Notifications"]
  node_users["User administration<br/>[user.service.ts]"]
end

subgraph group_platform["Persistence"]
  node_database[("Relational database")]
end

node_patrons(("Readers and staff"))

node_patrons -->|"use"| node_spa
node_spa -->|"provides state"| node_authui
node_spa -->|"renders"| node_catalogui
node_spa -->|"renders"| node_circulationui
node_spa -->|"renders"| node_reservationui
node_spa -->|"renders"| node_finesui
node_spa -->|"renders"| node_reportsui
node_spa -->|"renders"| node_usersui
node_authui -->|"calls"| node_apiclient
node_catalogui -->|"calls"| node_apiclient
node_circulationui -->|"calls"| node_apiclient
node_apiclient -->|"sends REST requests"| node_router
node_server -->|"mounts routes"| node_router
node_router -->|"applies middleware"| node_access
node_router -->|"dispatches"| node_authdomain
node_router -->|"dispatches"| node_catalog
node_router -->|"dispatches"| node_circulation
node_router -->|"dispatches"| node_reservations
node_router -->|"dispatches"| node_fines
node_router -->|"dispatches"| node_reports
node_router -->|"dispatches"| node_notifications
node_router -->|"dispatches"| node_users
node_catalog -->|"reads and writes"| node_database
node_circulation -->|"reads and writes"| node_database
node_reservations -->|"reads and writes"| node_database
node_fines -->|"reads and writes"| node_database
node_reports -->|"reads"| node_database
node_authdomain -->|"reads and writes"| node_database
node_users -->|"reads and writes"| node_database

click node_spa "https://github.com/flexcha/library-app/blob/main/src/App.tsx"
click node_authui "https://github.com/flexcha/library-app/blob/main/src/context/AuthContext.tsx"
click node_catalogui "https://github.com/flexcha/library-app/blob/main/src/components/CatalogBrowse.tsx"
click node_circulationui "https://github.com/flexcha/library-app/blob/main/src/components/CirculationDesk.tsx"
click node_reservationui "https://github.com/flexcha/library-app/blob/main/src/components/ReservationsView.tsx"
click node_finesui "https://github.com/flexcha/library-app/blob/main/src/components/FinesView.tsx"
click node_reportsui "https://github.com/flexcha/library-app/blob/main/src/components/ReportsDashboard.tsx"
click node_usersui "https://github.com/flexcha/library-app/blob/main/src/components/UserManagement.tsx"
click node_apiclient "https://github.com/flexcha/library-app/blob/main/src/api/client.ts"
click node_server "https://github.com/flexcha/library-app/blob/main/server.ts"
click node_router "https://github.com/flexcha/library-app/blob/main/src/routes/index.ts"
click node_access "https://github.com/flexcha/library-app/blob/main/src/middleware/authenticate.ts"
click node_authdomain "https://github.com/flexcha/library-app/blob/main/src/modules/auth/auth.service.ts"
click node_catalog "https://github.com/flexcha/library-app/blob/main/src/modules/catalog/book.service.ts"
click node_circulation "https://github.com/flexcha/library-app/blob/main/src/modules/circulation/loan.service.ts"
click node_reservations "https://github.com/flexcha/library-app/blob/main/src/modules/reservation/reservation.service.ts"
click node_fines "https://github.com/flexcha/library-app/blob/main/src/modules/fine/fine.service.ts"
click node_reports "https://github.com/flexcha/library-app/blob/main/src/modules/report/report.service.ts"
click node_notifications "https://github.com/flexcha/library-app/blob/main/src/modules/notification/notification.service.ts"
click node_users "https://github.com/flexcha/library-app/blob/main/src/modules/user/user.service.ts"

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_spa,node_authui,node_catalogui,node_circulationui,node_reservationui,node_finesui,node_reportsui,node_usersui,node_apiclient toneBlue
class node_server,node_router,node_access toneAmber
class node_authdomain,node_catalog,node_circulation,node_reservations,node_fines,node_reports,node_notifications,node_users toneMint
class node_database toneRose
class node_patrons toneIndigo
```

## Components

### React application

- [SPA shell](https://github.com/flexcha/library-app/blob/main/src/App.tsx): `src/App.tsx`
- [Sign-in state](https://github.com/flexcha/library-app/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Catalog browsing](https://github.com/flexcha/library-app/blob/main/src/components/CatalogBrowse.tsx): `src/components/CatalogBrowse.tsx`
- [Circulation desk](https://github.com/flexcha/library-app/blob/main/src/components/CirculationDesk.tsx): `src/components/CirculationDesk.tsx`
- [Reservations view](https://github.com/flexcha/library-app/blob/main/src/components/ReservationsView.tsx): `src/components/ReservationsView.tsx`
- [Fines view](https://github.com/flexcha/library-app/blob/main/src/components/FinesView.tsx): `src/components/FinesView.tsx`
- [Reports dashboard](https://github.com/flexcha/library-app/blob/main/src/components/ReportsDashboard.tsx): `src/components/ReportsDashboard.tsx`
- [User management](https://github.com/flexcha/library-app/blob/main/src/components/UserManagement.tsx): `src/components/UserManagement.tsx`
- [REST client](https://github.com/flexcha/library-app/blob/main/src/api/client.ts): `src/api/client.ts`

### API and access

- [Express server](https://github.com/flexcha/library-app/blob/main/server.ts): `server.ts`
- [API router](https://github.com/flexcha/library-app/blob/main/src/routes/index.ts): `src/routes/index.ts`
- [Auth and validation](https://github.com/flexcha/library-app/blob/main/src/middleware/authenticate.ts): `src/middleware/authenticate.ts`

### Library operations

- [Accounts and identity](https://github.com/flexcha/library-app/blob/main/src/modules/auth/auth.service.ts): `src/modules/auth/auth.service.ts`
- [Book catalog](https://github.com/flexcha/library-app/blob/main/src/modules/catalog/book.service.ts): `src/modules/catalog/book.service.ts`
- [Loans and returns](https://github.com/flexcha/library-app/blob/main/src/modules/circulation/loan.service.ts): `src/modules/circulation/loan.service.ts`
- [Book reservations](https://github.com/flexcha/library-app/blob/main/src/modules/reservation/reservation.service.ts): `src/modules/reservation/reservation.service.ts`
- [Fines and penalties](https://github.com/flexcha/library-app/blob/main/src/modules/fine/fine.service.ts): `src/modules/fine/fine.service.ts`
- [Library reporting](https://github.com/flexcha/library-app/blob/main/src/modules/report/report.service.ts): `src/modules/report/report.service.ts`
- [Notifications](https://github.com/flexcha/library-app/blob/main/src/modules/notification/notification.service.ts): `src/modules/notification/notification.service.ts`
- [User administration](https://github.com/flexcha/library-app/blob/main/src/modules/user/user.service.ts): `src/modules/user/user.service.ts`

### Persistence

- **Relational database**

### Other components

- **Readers and staff**

## Connections

- Readers and staff → SPA shell: use (evidence: `README.md`)
- SPA shell → Sign-in state: provides state (evidence: `src/App.tsx`)
- SPA shell → Catalog browsing: renders (evidence: `src/App.tsx`)
- SPA shell → Circulation desk: renders (evidence: `src/App.tsx`)
- SPA shell → Reservations view: renders (evidence: `src/App.tsx`)
- SPA shell → Fines view: renders (evidence: `src/App.tsx`)
- SPA shell → Reports dashboard: renders (evidence: `src/App.tsx`)
- SPA shell → User management: renders (evidence: `src/App.tsx`)
- Sign-in state → REST client: calls (evidence: `src/context/AuthContext.tsx`)
- Catalog browsing → REST client: calls (evidence: `src/components/CatalogBrowse.tsx`)
- Circulation desk → REST client: calls (evidence: `src/components/CirculationDesk.tsx`)
- REST client → API router: sends REST requests (evidence: `README.md`)
- Express server → API router: mounts routes
- API router → Auth and validation: applies middleware (evidence: `src/routes/index.ts`)
- API router → Accounts and identity: dispatches (evidence: `src/routes/index.ts`)
- API router → Book catalog: dispatches (evidence: `src/routes/index.ts`)
- API router → Loans and returns: dispatches (evidence: `src/routes/index.ts`)
- API router → Book reservations: dispatches (evidence: `src/routes/index.ts`)
- API router → Fines and penalties: dispatches (evidence: `src/routes/index.ts`)
- API router → Library reporting: dispatches (evidence: `src/routes/index.ts`)
- API router → Notifications: dispatches (evidence: `src/routes/index.ts`)
- API router → User administration: dispatches (evidence: `src/routes/index.ts`)
- Book catalog → Relational database: reads and writes (evidence: `README.md`)
- Loans and returns → Relational database: reads and writes (evidence: `README.md`)
- Book reservations → Relational database: reads and writes (evidence: `README.md`)
- Fines and penalties → Relational database: reads and writes (evidence: `README.md`)
- Library reporting → Relational database: reads (evidence: `README.md`)
- Accounts and identity → Relational database: reads and writes (evidence: `README.md`)
- User administration → Relational database: reads and writes (evidence: `README.md`)
