# nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2 architecture

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

- Interactive diagram: https://gitdiagram.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2
- Repository: https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2

## Overview

RestaurantManagement is an ASP.NET Core restaurant-management API. Its principal workflow is an HTTP request entering a controller, being dispatched through MediatR to a category or user operation, and using the unit of work and SQL repositories for persistence before returning a response. The source index also shows authentication, refresh-token handling, user-context support, and background user deletion. Some handlers and integrations were not excerpted, so uncertain dispatch links are marked unverified or omitted.

Main entry points: [`DAL.SqlServer/UnitOfWork/SqlUnitOfWork.cs`](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/DAL.SqlServer/UnitOfWork/SqlUnitOfWork.cs) (Unit of work), [`DAL.SqlServer/Context/AppDbContext.cs`](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/DAL.SqlServer/Context/AppDbContext.cs) (EF database context), [`RestaurantManagement/Program.cs`](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/RestaurantManagement/Program.cs) (API runtime), [`RestaurantManagement/Controllers/CategoryController.cs`](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/RestaurantManagement/Controllers/CategoryController.cs) (Category API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_category_api["Category API"]
  node_user_api["User API<br/>[UserController.cs]"]
  node_api_runtime["API runtime<br/>[Program.cs]"]
  node_exception_middleware["Exception handling"]
end

subgraph group_application["Application workflows"]
  node_category_workflows["Category workflows"]
  node_user_workflows["User workflows"]
  node_validation["Request validation"]
  node_user_context["Current user context<br/>[HttpUserContext.cs]"]
  node_token_service["Token service<br/>[TokenService.cs]"]
  node_user_cleanup["User cleanup"]
  node_mapping["Object mapping<br/>[MappingProfile.cs]"]
end

subgraph group_domain["Domain"]
  node_category["Category<br/>[Category.cs]"]
  node_user["User<br/>[User.cs]"]
  node_refresh_token["Refresh token<br/>[RefreshToken.cs]"]
end

subgraph group_persistence["SQL persistence"]
  node_unit_of_work["Unit of work<br/>[SqlUnitOfWork.cs]"]
  node_category_repository["Category repository"]
  node_user_repository["User repository"]
  node_token_repository["Refresh-token repository"]
  node_db_context["EF database context<br/>[AppDbContext.cs]"]
end

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

node_client -->|"sends request"| node_category_api
node_client -->|"sends request"| node_user_api
node_category_api -.->|"dispatches commands"| node_category_workflows
node_user_api -->|"dispatches requests"| node_user_workflows
node_api_runtime -->|"registers middleware"| node_exception_middleware
node_api_runtime -->|"registers context"| node_user_context
node_category_workflows -->|"uses"| node_unit_of_work
node_user_workflows -->|"uses"| node_unit_of_work
node_user_cleanup -->|"uses"| node_unit_of_work
node_unit_of_work -->|"provides repository"| node_category_repository
node_unit_of_work -->|"provides repository"| node_user_repository
node_unit_of_work -->|"provides repository"| node_token_repository
node_category_repository -->|"queries categories"| node_db_context
node_user_repository -->|"uses context"| node_db_context
node_token_repository -->|"uses context"| node_db_context
node_db_context -.->|"persists entities"| node_sql_server

click node_category_api "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/RestaurantManagement/Controllers/CategoryController.cs"
click node_user_api "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/RestaurantManagement/Controllers/UserController.cs"
click node_api_runtime "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/RestaurantManagement/Program.cs"
click node_exception_middleware "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/RestaurantManagement/Middlewares/ExceptionHandlerMiddleware.cs"
click node_category_workflows "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/tree/master/Application/CQRS/Categories/Handlers"
click node_user_workflows "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/tree/master/Application/CQRS/Users/Handlers"
click node_validation "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Application/PipelineBehaviors/ValidationPipelineBehavior.cs"
click node_user_context "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/RestaurantManagement/Infrastructure/HttpUserContext.cs"
click node_token_service "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Application/Services/TokenService.cs"
click node_user_cleanup "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Application/Services/BackgroundServices/DeleteUserBackgroundService.cs"
click node_mapping "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Application/AutoMapper/MappingProfile.cs"
click node_category "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Domain/Entites/Category.cs"
click node_user "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Domain/Entites/User.cs"
click node_refresh_token "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Domain/Entites/RefreshToken.cs"
click node_unit_of_work "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/DAL.SqlServer/UnitOfWork/SqlUnitOfWork.cs"
click node_category_repository "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/DAL.SqlServer/Infrastructure/SqlCategoryRepository.cs"
click node_user_repository "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/DAL.SqlServer/Infrastructure/SqlUserRepository.cs"
click node_token_repository "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/DAL.SqlServer/Infrastructure/SqlRefreshTokenRepository.cs"
click node_db_context "https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/DAL.SqlServer/Context/AppDbContext.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_category_api,node_user_api,node_api_runtime,node_exception_middleware,node_client toneBlue
class node_category_workflows,node_user_workflows,node_validation,node_user_context,node_token_service,node_user_cleanup,node_mapping,node_sql_server toneAmber
class node_category,node_user,node_refresh_token toneMint
class node_unit_of_work,node_category_repository,node_user_repository,node_token_repository,node_db_context toneRose
```

## Components

### HTTP API

- [Category API](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/RestaurantManagement/Controllers/CategoryController.cs): `RestaurantManagement/Controllers/CategoryController.cs`
- [User API](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/RestaurantManagement/Controllers/UserController.cs): `RestaurantManagement/Controllers/UserController.cs`
- [API runtime](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/RestaurantManagement/Program.cs): `RestaurantManagement/Program.cs`
- [Exception handling](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/RestaurantManagement/Middlewares/ExceptionHandlerMiddleware.cs): `RestaurantManagement/Middlewares/ExceptionHandlerMiddleware.cs`

### Application workflows

- [Category workflows](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/tree/master/Application/CQRS/Categories/Handlers): `Application/CQRS/Categories/Handlers`
- [User workflows](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/tree/master/Application/CQRS/Users/Handlers): `Application/CQRS/Users/Handlers`
- [Request validation](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Application/PipelineBehaviors/ValidationPipelineBehavior.cs): `Application/PipelineBehaviors/ValidationPipelineBehavior.cs`
- [Current user context](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/RestaurantManagement/Infrastructure/HttpUserContext.cs): `RestaurantManagement/Infrastructure/HttpUserContext.cs`
- [Token service](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Application/Services/TokenService.cs): `Application/Services/TokenService.cs`
- [User cleanup](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Application/Services/BackgroundServices/DeleteUserBackgroundService.cs): `Application/Services/BackgroundServices/DeleteUserBackgroundService.cs`
- [Object mapping](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Application/AutoMapper/MappingProfile.cs): `Application/AutoMapper/MappingProfile.cs`

### Domain

- [Category](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Domain/Entites/Category.cs): `Domain/Entites/Category.cs`
- [User](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Domain/Entites/User.cs): `Domain/Entites/User.cs`
- [Refresh token](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/Domain/Entites/RefreshToken.cs): `Domain/Entites/RefreshToken.cs`

### SQL persistence

- [Unit of work](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/DAL.SqlServer/UnitOfWork/SqlUnitOfWork.cs): `DAL.SqlServer/UnitOfWork/SqlUnitOfWork.cs`
- [Category repository](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/DAL.SqlServer/Infrastructure/SqlCategoryRepository.cs): `DAL.SqlServer/Infrastructure/SqlCategoryRepository.cs`
- [User repository](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/DAL.SqlServer/Infrastructure/SqlUserRepository.cs): `DAL.SqlServer/Infrastructure/SqlUserRepository.cs`
- [Refresh-token repository](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/DAL.SqlServer/Infrastructure/SqlRefreshTokenRepository.cs): `DAL.SqlServer/Infrastructure/SqlRefreshTokenRepository.cs`
- [EF database context](https://github.com/nurlan-shirinov/restaurantmanagement_fbms_1_23_4_az_v2/blob/master/DAL.SqlServer/Context/AppDbContext.cs): `DAL.SqlServer/Context/AppDbContext.cs`

### Other components

- **API client**
- **SQL Server**

## Connections

- API client → Category API: sends request (evidence: `RestaurantManagement/Controllers/CategoryController.cs`)
- API client → User API: sends request (evidence: `RestaurantManagement/Controllers/UserController.cs`)
- Category API → Category workflows: dispatches commands
- User API → User workflows: dispatches requests (evidence: `RestaurantManagement/Controllers/UserController.cs`)
- API runtime → Exception handling: registers middleware (evidence: `RestaurantManagement/Program.cs`)
- API runtime → Current user context: registers context (evidence: `RestaurantManagement/Program.cs`)
- Category workflows → Unit of work: uses (evidence: `Application/CQRS/Categories/Handlers/CommandHandlers/CreateCategoryHandler.cs`)
- User workflows → Unit of work: uses (evidence: `Application/CQRS/Users/Handlers/Update.cs`)
- User cleanup → Unit of work: uses (evidence: `Application/Services/BackgroundServices/DeleteUserBackgroundService.cs`)
- Unit of work → Category repository: provides repository (evidence: `DAL.SqlServer/UnitOfWork/SqlUnitOfWork.cs`)
- Unit of work → User repository: provides repository (evidence: `DAL.SqlServer/UnitOfWork/SqlUnitOfWork.cs`)
- Unit of work → Refresh-token repository: provides repository (evidence: `DAL.SqlServer/UnitOfWork/SqlUnitOfWork.cs`)
- Category repository → EF database context: queries categories (evidence: `DAL.SqlServer/Infrastructure/SqlCategoryRepository.cs`)
- User repository → EF database context: uses context (evidence: `DAL.SqlServer/Infrastructure/SqlUserRepository.cs`)
- Refresh-token repository → EF database context: uses context (evidence: `DAL.SqlServer/Infrastructure/SqlRefreshTokenRepository.cs`)
- EF database context → SQL Server: persists entities
