# hinatanie/light-brary architecture

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

- Interactive diagram: https://gitdiagram.com/hinatanie/light-brary
- Repository: https://github.com/hinatanie/light-brary

## Overview

LightBrary is a library-management system; the supplied tree covers its ASP.NET Core backend, not the React frontend. The intended user workflow is authentication and role-based access, book and copy discovery, then borrowing, return, renewal, and loss handling. The backend is organized around application services, repository interfaces, infrastructure, and domain entities. The README describes broader security and circulation behavior than the sampled implementation shows; several sampled service and repository classes are empty stubs, and no request-routing code appears in the tree, so those runtime links are not asserted.

Main entry points: [`back_end/light_brary/Program.cs`](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Program.cs) (API host), [`back_end/light_brary/Application/Interfaces/IServices`](https://github.com/hinatanie/light-brary/tree/main/back_end/light_brary/Application/Interfaces/IServices) (Service contracts), [`back_end/light_brary/Infrastructure/Persistence/AppDbContext.cs`](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Infrastructure/Persistence/AppDbContext.cs) (EF data context), [`back_end/light_brary/Application/Services/AuthService.cs`](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/AuthService.cs) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_api_host["API host<br/>[Program.cs]"]
  node_auth_service["Authentication<br/>[AuthService.cs]"]
  node_jwt["JWT tokens<br/>[JwtTokenService.cs]"]
  node_user_service["User management<br/>[UserService.cs]"]
  node_role_service["Role management<br/>[RoleService.cs]"]
end

subgraph group_catalog["Library catalog"]
  node_book_service["Book catalog<br/>[BookService.cs]"]
  node_category_service["Categories<br/>[CategoryService.cs]"]
  node_copy_service["Physical copies<br/>[BookCopyService.cs]"]
end

subgraph group_circulation["Circulation"]
  node_borrow_service["Borrow records"]
  node_detail_service["Borrow details"]
end

subgraph group_core["Application and storage"]
  node_app_interfaces["Service contracts"]
  node_repo_contracts["Repository contracts"]
  node_repositories["Repository implementations"]
  node_db_context["EF data context<br/>[AppDbContext.cs]"]
  node_postgres[("PostgreSQL")]
  node_domain["Library domain model"]
end

node_patron(("Patron or staff"))

node_patron -.->|"uses API"| node_api_host
node_api_host -->|"registers"| node_auth_service
node_api_host -->|"registers"| node_book_service
node_api_host -->|"registers"| node_category_service
node_api_host -->|"registers"| node_copy_service
node_api_host -->|"registers"| node_borrow_service
node_api_host -->|"registers"| node_detail_service
node_api_host -->|"registers"| node_user_service
node_api_host -->|"registers"| node_role_service
node_api_host -->|"configures"| node_db_context
node_api_host -->|"registers"| node_repositories
node_api_host -->|"registers"| node_jwt
node_auth_service -.->|"issues tokens"| node_jwt
node_app_interfaces -.->|"uses contracts"| node_repo_contracts
node_repositories -.->|"accesses data"| node_db_context
node_db_context -.->|"persists records"| node_postgres
node_db_context -->|"maps entities"| node_domain
node_book_service -.->|"implements contract"| node_app_interfaces
node_category_service -.->|"implements contract"| node_app_interfaces
node_copy_service -->|"implements contract"| node_app_interfaces
node_borrow_service -->|"implements contract"| node_app_interfaces
node_detail_service -->|"implements contract"| node_app_interfaces

click node_api_host "https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Program.cs"
click node_auth_service "https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/AuthService.cs"
click node_jwt "https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Infrastructure/Authentication/JwtTokenService.cs"
click node_user_service "https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/UserService.cs"
click node_role_service "https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/RoleService.cs"
click node_book_service "https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/BookService.cs"
click node_category_service "https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/CategoryService.cs"
click node_copy_service "https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/BookCopyService.cs"
click node_borrow_service "https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/BorrowRecordService.cs"
click node_detail_service "https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/BorrowDetailService.cs"
click node_app_interfaces "https://github.com/hinatanie/light-brary/tree/main/back_end/light_brary/Application/Interfaces/IServices"
click node_repo_contracts "https://github.com/hinatanie/light-brary/tree/main/back_end/light_brary/Application/Interfaces/IRepositories"
click node_repositories "https://github.com/hinatanie/light-brary/tree/main/back_end/light_brary/Infrastructure/Repositories"
click node_db_context "https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Infrastructure/Persistence/AppDbContext.cs"
click node_domain "https://github.com/hinatanie/light-brary/tree/main/back_end/light_brary/Domain/Entities"

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_api_host,node_auth_service,node_jwt,node_user_service,node_role_service toneBlue
class node_book_service,node_category_service,node_copy_service toneAmber
class node_borrow_service,node_detail_service toneMint
class node_app_interfaces,node_repo_contracts,node_repositories,node_db_context,node_postgres,node_domain toneRose
class node_patron toneIndigo
```

## Components

### API and identity

- [API host](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Program.cs): `back_end/light_brary/Program.cs`
- [Authentication](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/AuthService.cs): `back_end/light_brary/Application/Services/AuthService.cs`
- [JWT tokens](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Infrastructure/Authentication/JwtTokenService.cs): `back_end/light_brary/Infrastructure/Authentication/JwtTokenService.cs`
- [User management](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/UserService.cs): `back_end/light_brary/Application/Services/UserService.cs`
- [Role management](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/RoleService.cs): `back_end/light_brary/Application/Services/RoleService.cs`

### Library catalog

- [Book catalog](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/BookService.cs): `back_end/light_brary/Application/Services/BookService.cs`
- [Categories](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/CategoryService.cs): `back_end/light_brary/Application/Services/CategoryService.cs`
- [Physical copies](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/BookCopyService.cs): `back_end/light_brary/Application/Services/BookCopyService.cs`

### Circulation

- [Borrow records](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/BorrowRecordService.cs): `back_end/light_brary/Application/Services/BorrowRecordService.cs`
- [Borrow details](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Application/Services/BorrowDetailService.cs): `back_end/light_brary/Application/Services/BorrowDetailService.cs`

### Application and storage

- [Service contracts](https://github.com/hinatanie/light-brary/tree/main/back_end/light_brary/Application/Interfaces/IServices): `back_end/light_brary/Application/Interfaces/IServices`
- [Repository contracts](https://github.com/hinatanie/light-brary/tree/main/back_end/light_brary/Application/Interfaces/IRepositories): `back_end/light_brary/Application/Interfaces/IRepositories`
- [Repository implementations](https://github.com/hinatanie/light-brary/tree/main/back_end/light_brary/Infrastructure/Repositories): `back_end/light_brary/Infrastructure/Repositories`
- [EF data context](https://github.com/hinatanie/light-brary/blob/main/back_end/light_brary/Infrastructure/Persistence/AppDbContext.cs): `back_end/light_brary/Infrastructure/Persistence/AppDbContext.cs`
- **PostgreSQL**
- [Library domain model](https://github.com/hinatanie/light-brary/tree/main/back_end/light_brary/Domain/Entities): `back_end/light_brary/Domain/Entities`

### Other components

- **Patron or staff**

## Connections

- Patron or staff → API host: uses API
- API host → Authentication: registers (evidence: `back_end/light_brary/Program.cs`)
- API host → Book catalog: registers (evidence: `back_end/light_brary/Program.cs`)
- API host → Categories: registers (evidence: `back_end/light_brary/Program.cs`)
- API host → Physical copies: registers (evidence: `back_end/light_brary/Program.cs`)
- API host → Borrow records: registers (evidence: `back_end/light_brary/Program.cs`)
- API host → Borrow details: registers (evidence: `back_end/light_brary/Program.cs`)
- API host → User management: registers (evidence: `back_end/light_brary/Program.cs`)
- API host → Role management: registers (evidence: `back_end/light_brary/Program.cs`)
- API host → EF data context: configures (evidence: `back_end/light_brary/Program.cs`)
- API host → Repository implementations: registers (evidence: `back_end/light_brary/Program.cs`)
- API host → JWT tokens: registers (evidence: `back_end/light_brary/Program.cs`)
- Authentication → JWT tokens: issues tokens
- Service contracts → Repository contracts: uses contracts
- Repository implementations → EF data context: accesses data
- EF data context → PostgreSQL: persists records
- EF data context → Library domain model: maps entities (evidence: `back_end/light_brary/Infrastructure/Persistence/AppDbContext.cs`)
- Book catalog → Service contracts: implements contract (evidence: `back_end/light_brary/Application/Services/BookService.cs`)
- Categories → Service contracts: implements contract (evidence: `back_end/light_brary/Application/Services/CategoryService.cs`)
- Physical copies → Service contracts: implements contract (evidence: `back_end/light_brary/Application/Services/BookCopyService.cs`)
- Borrow records → Service contracts: implements contract (evidence: `back_end/light_brary/Application/Services/BorrowRecordService.cs`)
- Borrow details → Service contracts: implements contract (evidence: `back_end/light_brary/Application/Services/BorrowDetailService.cs`)
