# muhammadhuzaifashah/library_management-system architecture

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

- Interactive diagram: https://gitdiagram.com/muhammadhuzaifashah/library_management-system
- Repository: https://github.com/muhammadhuzaifashah/library_management-system

## Overview

This is a FastAPI library-management service. Members register or log in, then use authenticated catalog and lending endpoints; administrators manage books, members, and borrowing activity. The main domain stages are identity/access, catalog inventory, and loan/return processing, backed by relational models and configured persistence. The Leaf frontend is served by the same application and uses the existing API. The README documents these capabilities; edges below are limited to relationships shown in sampled source or explicitly documented, so unsampled frontend request wiring is not asserted.

Main entry points: [`app/routers/users.py`](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/routers/users.py) (Account endpoints), [`app/routers/borrowings.py`](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/routers/borrowings.py) (Borrow and return), [`app/database.py`](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/database.py) (Database sessions), [`app/routers/auth.py`](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/routers/auth.py) (Login endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application interface"]
  node_leaf["Leaf interface"]
  node_api["API application<br/>[main.py]"]
end

subgraph group_identity["Identity and access"]
  node_auth_routes["Login endpoint<br/>[auth.py]"]
  node_accounts["Account endpoints<br/>[users.py]"]
  node_jwt["JWT authorization<br/>[outh2.py]"]
  node_passwords["Password and commit helpers<br/>[utils.py]"]
end

subgraph group_catalog["Catalog management"]
  node_books["Catalog endpoints<br/>[books.py]"]
end

subgraph group_lending["Lending operations"]
  node_loans["Borrow and return<br/>[borrowings.py]"]
  node_loan_policy["Loan limits and fines<br/>[config.py]"]
end

subgraph group_foundation["Persistence and contracts"]
  node_settings["Service settings<br/>[config.py]"]
  node_db_session["Database sessions<br/>[database.py]"]
  node_records["Library records<br/>[models.py]"]
  node_contracts["API schemas<br/>[schemas.py]"]
  node_postgres[("Relational database")]
end

node_members(("Members"))
node_admins(("Administrators"))

node_api -->|"registers"| node_auth_routes
node_api -->|"registers"| node_accounts
node_api -->|"registers"| node_books
node_api -->|"registers"| node_loans
node_api -->|"serves"| node_leaf
node_api -->|"health-checks"| node_db_session
node_members -->|"uses"| node_leaf
node_admins -->|"uses"| node_leaf
node_members -->|"logs in"| node_auth_routes
node_members -->|"manages account"| node_accounts
node_admins -->|"manages accounts"| node_accounts
node_auth_routes -->|"verifies password"| node_passwords
node_auth_routes -->|"creates token"| node_jwt
node_accounts -->|"hashes password"| node_passwords
node_accounts -->|"checks access"| node_jwt
node_books -->|"checks access"| node_jwt
node_loans -->|"checks access"| node_jwt
node_admins -->|"manages catalog"| node_books
node_members -->|"searches catalog"| node_books
node_members -->|"borrows and returns"| node_loans
node_admins -->|"reviews activity"| node_loans
node_loans -->|"reads limits"| node_loan_policy
node_auth_routes -->|"queries users"| node_db_session
node_accounts -->|"persists accounts"| node_db_session
node_books -->|"queries inventory"| node_db_session
node_loans -->|"persists loans"| node_db_session
node_jwt -->|"loads user"| node_db_session
node_db_session -->|"configures connection"| node_settings
node_db_session -->|"connects"| node_postgres
node_books -->|"queries books"| node_records
node_loans -->|"updates loan records"| node_records
node_accounts -->|"updates users"| node_records
node_auth_routes -->|"loads user"| node_records
node_auth_routes -->|"validates token response"| node_contracts
node_books -->|"validates payloads"| node_contracts
node_loans -->|"validates payloads"| node_contracts
node_accounts -->|"validates payloads"| node_contracts

click node_leaf "https://github.com/muhammadhuzaifashah/library_management-system/tree/main/app/frontend"
click node_api "https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/main.py"
click node_auth_routes "https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/routers/auth.py"
click node_accounts "https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/routers/users.py"
click node_jwt "https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/outh2.py"
click node_passwords "https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/utils.py"
click node_books "https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/routers/books.py"
click node_loans "https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/routers/borrowings.py"
click node_loan_policy "https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/config.py"
click node_settings "https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/config.py"
click node_db_session "https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/database.py"
click node_records "https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/models.py"
click node_contracts "https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/schemas.py"

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_leaf,node_api toneBlue
class node_auth_routes,node_accounts,node_jwt,node_passwords toneAmber
class node_books toneMint
class node_loans,node_loan_policy toneRose
class node_settings,node_db_session,node_records,node_contracts,node_postgres,node_members,node_admins toneIndigo
```

## Components

### Application interface

- [Leaf interface](https://github.com/muhammadhuzaifashah/library_management-system/tree/main/app/frontend): `app/frontend`
- [API application](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/main.py): `app/main.py`

### Identity and access

- [Login endpoint](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/routers/auth.py): `app/routers/auth.py`
- [Account endpoints](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/routers/users.py): `app/routers/users.py`
- [JWT authorization](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/outh2.py): `app/outh2.py`
- [Password and commit helpers](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/utils.py): `app/utils.py`

### Catalog management

- [Catalog endpoints](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/routers/books.py): `app/routers/books.py`

### Lending operations

- [Borrow and return](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/routers/borrowings.py): `app/routers/borrowings.py`
- [Loan limits and fines](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/config.py): `app/config.py`

### Persistence and contracts

- [Service settings](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/config.py): `app/config.py`
- [Database sessions](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/database.py): `app/database.py`
- [Library records](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/models.py): `app/models.py`
- [API schemas](https://github.com/muhammadhuzaifashah/library_management-system/blob/main/app/schemas.py): `app/schemas.py`
- **Relational database**

### Other components

- **Members**
- **Administrators**

## Connections

- API application → Login endpoint: registers (evidence: `app/main.py`)
- API application → Account endpoints: registers (evidence: `app/main.py`)
- API application → Catalog endpoints: registers (evidence: `app/main.py`)
- API application → Borrow and return: registers (evidence: `app/main.py`)
- API application → Leaf interface: serves (evidence: `app/main.py`)
- API application → Database sessions: health-checks (evidence: `app/main.py`)
- Members → Leaf interface: uses (evidence: `README.md`)
- Administrators → Leaf interface: uses (evidence: `README.md`)
- Members → Login endpoint: logs in (evidence: `README.md`)
- Members → Account endpoints: manages account (evidence: `README.md`)
- Administrators → Account endpoints: manages accounts (evidence: `README.md`)
- Login endpoint → Password and commit helpers: verifies password (evidence: `app/routers/auth.py`)
- Login endpoint → JWT authorization: creates token (evidence: `app/routers/auth.py`)
- Account endpoints → Password and commit helpers: hashes password (evidence: `app/routers/users.py`)
- Account endpoints → JWT authorization: checks access (evidence: `app/routers/users.py`)
- Catalog endpoints → JWT authorization: checks access (evidence: `app/routers/books.py`)
- Borrow and return → JWT authorization: checks access (evidence: `app/routers/borrowings.py`)
- Administrators → Catalog endpoints: manages catalog (evidence: `README.md`)
- Members → Catalog endpoints: searches catalog (evidence: `README.md`)
- Members → Borrow and return: borrows and returns (evidence: `README.md`)
- Administrators → Borrow and return: reviews activity (evidence: `README.md`)
- Borrow and return → Loan limits and fines: reads limits (evidence: `app/routers/borrowings.py`)
- Login endpoint → Database sessions: queries users (evidence: `app/routers/auth.py`)
- Account endpoints → Database sessions: persists accounts (evidence: `app/routers/users.py`)
- Catalog endpoints → Database sessions: queries inventory (evidence: `app/routers/books.py`)
- Borrow and return → Database sessions: persists loans (evidence: `app/routers/borrowings.py`)
- JWT authorization → Database sessions: loads user (evidence: `app/outh2.py`)
- Database sessions → Service settings: configures connection (evidence: `app/database.py`)
- Database sessions → Relational database: connects (evidence: `README.md`)
- Catalog endpoints → Library records: queries books (evidence: `app/routers/books.py`)
- Borrow and return → Library records: updates loan records (evidence: `app/routers/borrowings.py`)
- Account endpoints → Library records: updates users (evidence: `app/routers/users.py`)
- Login endpoint → Library records: loads user (evidence: `app/routers/auth.py`)
- Login endpoint → API schemas: validates token response (evidence: `app/routers/auth.py`)
- Catalog endpoints → API schemas: validates payloads (evidence: `app/routers/books.py`)
- Borrow and return → API schemas: validates payloads (evidence: `app/routers/borrowings.py`)
- Account endpoints → API schemas: validates payloads (evidence: `app/routers/users.py`)
