# lugoz99/library-management architecture

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

- Interactive diagram: https://gitdiagram.com/lugoz99/library-management
- Repository: https://github.com/lugoz99/library-management

## Overview

This repository implements a category and subcategory management API: clients send HTTP requests, controllers delegate to services for validation and CRUD operations, and repositories persist entities through Entity Framework Core. Pagination and HTTP error conversion support that workflow. The README describes a broader library database—including users, books, sales, and promotions—but the supplied source tree only implements category and subcategory functionality; those other domains are not represented as runtime components here. Some relationships are shown only by the SOURCE INDEX or README, so unsampled subsystems are not inferred.

Main entry points: [`LibraryManagement/Services/Implementation/SubCategoryService.cs`](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Services/Implementation/SubCategoryService.cs) (Subcategory Service), [`LibraryManagement/Program.cs`](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Program.cs) (Application Startup), [`LibraryManagement/Services/Implementation/CategoryService.cs`](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Services/Implementation/CategoryService.cs) (Category Service), [`LibraryManagement/Data/ApplicationDbContext.cs`](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Data/ApplicationDbContext.cs) (EF Core Context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_startup["Application Startup<br/>[Program.cs]"]
  node_category_controller["Category Controller"]
  node_subcategory_controller["Subcategory Controller"]
  node_dtos["Catalog DTOs<br/>[CategoryDto.cs]"]
end

subgraph group_domain["Catalog Services"]
  node_category_service["Category Service<br/>[CategoryService.cs]"]
  node_subcategory_service["Subcategory Service"]
  node_category_entity["Category Entity<br/>[Category.cs]"]
  node_subcategory_entity["Subcategory Entity<br/>[SubCategory.cs]"]
end

subgraph group_persistence["Persistence"]
  node_category_repository["Category Repository"]
  node_subcategory_repository["Subcategory Repository"]
  node_db_context["EF Core Context"]
end

subgraph group_support["API Support"]
  node_pagination["Pagination Helpers"]
  node_error_profile["HTTP Error Mapping"]
end

node_client(("API Client"))
node_sql_server[("SQL Server")]

node_client -->|"sends requests"| node_category_controller
node_client -->|"sends requests"| node_subcategory_controller
node_startup -->|"maps controllers"| node_category_controller
node_startup -->|"maps controllers"| node_subcategory_controller
node_category_controller -->|"delegates to"| node_category_service
node_subcategory_controller -->|"delegates to"| node_subcategory_service
node_category_service -->|"queries and saves"| node_category_repository
node_subcategory_service -->|"queries and saves"| node_subcategory_repository
node_subcategory_service -->|"checks parent"| node_category_repository
node_category_repository -->|"uses context"| node_db_context
node_subcategory_repository -->|"uses context"| node_db_context
node_db_context -->|"maps entity"| node_category_entity
node_db_context -->|"maps entity"| node_subcategory_entity
node_category_entity -->|"has many"| node_subcategory_entity
node_startup -->|"configures provider"| node_sql_server
node_category_service -->|"pages results"| node_pagination
node_subcategory_service -->|"pages results"| node_pagination
node_startup -->|"registers profile"| node_error_profile
node_category_service -->|"maps responses"| node_dtos
node_subcategory_service -->|"maps responses"| node_dtos

click node_startup "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Program.cs"
click node_category_controller "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Controllers/CategoryController.cs"
click node_subcategory_controller "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Controllers/SubCategoryController.cs"
click node_category_service "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Services/Implementation/CategoryService.cs"
click node_subcategory_service "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Services/Implementation/SubCategoryService.cs"
click node_category_repository "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Repository/CategoryRepository.cs"
click node_subcategory_repository "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Repository/SubCategoryRepository.cs"
click node_db_context "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Data/ApplicationDbContext.cs"
click node_category_entity "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Models/Category.cs"
click node_subcategory_entity "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Models/SubCategory.cs"
click node_dtos "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Models/DTOs/Categories/CategoryDto.cs"
click node_pagination "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Common/Pagination/QueryableExtensions.cs"
click node_error_profile "https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Common/FluentResultsEndpointProfile.cs"

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_startup,node_category_controller,node_subcategory_controller,node_dtos,node_client toneBlue
class node_category_service,node_subcategory_service,node_category_entity,node_subcategory_entity,node_sql_server toneAmber
class node_category_repository,node_subcategory_repository,node_db_context toneMint
class node_pagination,node_error_profile toneRose
```

## Components

### HTTP API

- [Application Startup](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Program.cs): `LibraryManagement/Program.cs`
- [Category Controller](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Controllers/CategoryController.cs): `LibraryManagement/Controllers/CategoryController.cs`
- [Subcategory Controller](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Controllers/SubCategoryController.cs): `LibraryManagement/Controllers/SubCategoryController.cs`
- [Catalog DTOs](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Models/DTOs/Categories/CategoryDto.cs): `LibraryManagement/Models/DTOs/Categories/CategoryDto.cs`

### Catalog Services

- [Category Service](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Services/Implementation/CategoryService.cs): `LibraryManagement/Services/Implementation/CategoryService.cs`
- [Subcategory Service](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Services/Implementation/SubCategoryService.cs): `LibraryManagement/Services/Implementation/SubCategoryService.cs`
- [Category Entity](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Models/Category.cs): `LibraryManagement/Models/Category.cs`
- [Subcategory Entity](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Models/SubCategory.cs): `LibraryManagement/Models/SubCategory.cs`

### Persistence

- [Category Repository](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Repository/CategoryRepository.cs): `LibraryManagement/Repository/CategoryRepository.cs`
- [Subcategory Repository](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Repository/SubCategoryRepository.cs): `LibraryManagement/Repository/SubCategoryRepository.cs`
- [EF Core Context](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Data/ApplicationDbContext.cs): `LibraryManagement/Data/ApplicationDbContext.cs`

### API Support

- [Pagination Helpers](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Common/Pagination/QueryableExtensions.cs): `LibraryManagement/Common/Pagination/QueryableExtensions.cs`
- [HTTP Error Mapping](https://github.com/lugoz99/library-management/blob/main/LibraryManagement/Common/FluentResultsEndpointProfile.cs): `LibraryManagement/Common/FluentResultsEndpointProfile.cs`

### Other components

- **API Client**
- **SQL Server**

## Connections

- API Client → Category Controller: sends requests (evidence: `LibraryManagement/Controllers/CategoryController.cs`)
- API Client → Subcategory Controller: sends requests (evidence: `LibraryManagement/Controllers/SubCategoryController.cs`)
- Application Startup → Category Controller: maps controllers (evidence: `LibraryManagement/Program.cs`)
- Application Startup → Subcategory Controller: maps controllers (evidence: `LibraryManagement/Program.cs`)
- Category Controller → Category Service: delegates to (evidence: `LibraryManagement/Controllers/CategoryController.cs`)
- Subcategory Controller → Subcategory Service: delegates to (evidence: `LibraryManagement/Controllers/SubCategoryController.cs`)
- Category Service → Category Repository: queries and saves (evidence: `LibraryManagement/Services/Implementation/CategoryService.cs`)
- Subcategory Service → Subcategory Repository: queries and saves (evidence: `LibraryManagement/Services/Implementation/SubCategoryService.cs`)
- Subcategory Service → Category Repository: checks parent (evidence: `LibraryManagement/Services/Implementation/SubCategoryService.cs`)
- Category Repository → EF Core Context: uses context (evidence: `LibraryManagement/Repository/CategoryRepository.cs`)
- Subcategory Repository → EF Core Context: uses context (evidence: `LibraryManagement/Repository/SubCategoryRepository.cs`)
- EF Core Context → Category Entity: maps entity (evidence: `LibraryManagement/Data/ApplicationDbContext.cs`)
- EF Core Context → Subcategory Entity: maps entity (evidence: `LibraryManagement/Data/ApplicationDbContext.cs`)
- Category Entity → Subcategory Entity: has many (evidence: `LibraryManagement/Data/ApplicationDbContext.cs`)
- Application Startup → SQL Server: configures provider (evidence: `LibraryManagement/Program.cs`)
- Category Service → Pagination Helpers: pages results (evidence: `LibraryManagement/Services/Implementation/CategoryService.cs`)
- Subcategory Service → Pagination Helpers: pages results (evidence: `LibraryManagement/Services/Implementation/SubCategoryService.cs`)
- Application Startup → HTTP Error Mapping: registers profile (evidence: `LibraryManagement/Program.cs`)
- Category Service → Catalog DTOs: maps responses (evidence: `LibraryManagement/Services/Implementation/CategoryService.cs`)
- Subcategory Service → Catalog DTOs: maps responses (evidence: `LibraryManagement/Services/Implementation/SubCategoryService.cs`)
