# nailrasulov/loginregisterapi architecture

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

- Interactive diagram: https://gitdiagram.com/nailrasulov/loginregisterapi
- Repository: https://github.com/nailrasulov/loginregisterapi

## Overview

LoReg is an ASP.NET API for user identity and role administration, with registration, login, token refresh/logout, and authenticated profile lookup as its principal workflow. Admins can also create doctor and admin accounts. The API dispatches requests to MediatR handlers; handlers use identity, token-generation, and refresh-token abstractions, implemented in the infrastructure layer. The source excerpts establish several calls directly, but not the logout handler, token-generation helper internals, or dependency-injection bindings, so those links are not inferred.

Main entry points: [`LoReg/LoReg.API/Controllers/AuthController.cs`](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.API/Controllers/AuthController.cs) (Auth controller), [`LoReg/LoReg.Application/Interfaces/IIdentityService.cs`](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Interfaces/IIdentityService.cs) (Identity contract), [`LoReg/LoReg.Application/Features/Auth/Refresh/RefreshTokenCommandHandler.cs`](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Refresh/RefreshTokenCommandHandler.cs) (Refresh handler), [`LoReg/LoReg.Application/Features/Auth/Login/LoginUserCommandHandler.cs`](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Login/LoginUserCommandHandler.cs) (Login handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_auth_controller["Auth controller<br/>[AuthController.cs]"]
  node_admin_controller["Admin controller<br/>[AdminController.cs]"]
end

subgraph group_application["Application workflows"]
  node_register["Register handler"]
  node_login["Login handler"]
  node_refresh["Refresh handler"]
  node_logout["Logout handler"]
  node_me["Profile handler"]
  node_create_doctor["Create doctor handler"]
  node_create_admin["Create admin handler"]
end

subgraph group_identity["Identity services"]
  node_identity_interface["Identity contract"]
  node_identity_service["Identity service<br/>[IdentityService.cs]"]
  node_app_user["Application user<br/>[AppUser.cs]"]
  node_token_helper["Token response helper"]
  node_token_interface["Token service contract<br/>[ITokenService.cs]"]
  node_jwt_service["JWT token service<br/>[JwtTokenService.cs]"]
end

subgraph group_persistence["Persistence and tokens"]
  node_refresh_entity[("Refresh token<br/>[RefreshToken.cs]")]
  node_refresh_interface["Refresh token contract"]
  node_refresh_repository["Refresh repository"]
  node_db_context[("Application database<br/>[AppDbContext.cs]")]
end

node_client(("API client"))
node_auth_result["Auth response<br/>[AuthResponseDto.cs]"]
node_user_result["User response<br/>[UserResponseDto.cs]"]

node_client -->|"sends auth requests"| node_auth_controller
node_client -->|"sends admin requests"| node_admin_controller
node_auth_controller -->|"dispatches registration"| node_register
node_auth_controller -->|"dispatches login"| node_login
node_auth_controller -->|"dispatches refresh"| node_refresh
node_auth_controller -->|"dispatches logout"| node_logout
node_auth_controller -->|"dispatches profile query"| node_me
node_admin_controller -->|"dispatches doctor creation"| node_create_doctor
node_admin_controller -->|"dispatches admin creation"| node_create_admin
node_register -->|"creates and finds user"| node_identity_interface
node_login -->|"checks and finds user"| node_identity_interface
node_me -->|"finds user"| node_identity_interface
node_create_doctor -->|"creates and finds user"| node_identity_interface
node_create_admin -->|"creates and finds user"| node_identity_interface
node_refresh -->|"finds user"| node_identity_interface
node_identity_service -->|"implements"| node_identity_interface
node_identity_service -->|"uses user records"| node_app_user
node_login -->|"generates auth response"| node_token_helper
node_refresh -->|"generates auth response"| node_token_helper
node_token_helper -->|"uses token service"| node_token_interface
node_jwt_service -->|"implements"| node_token_interface
node_refresh -->|"reads and revokes tokens"| node_refresh_interface
node_refresh_repository -->|"implements"| node_refresh_interface
node_refresh_repository -->|"reads and writes tokens"| node_db_context
node_refresh_repository -->|"stores token records"| node_refresh_entity
node_login -->|"returns"| node_auth_result
node_refresh -->|"returns"| node_auth_result
node_register -->|"returns"| node_user_result
node_me -->|"returns"| node_user_result
node_create_doctor -->|"returns"| node_user_result
node_create_admin -->|"returns"| node_user_result

click node_auth_controller "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.API/Controllers/AuthController.cs"
click node_admin_controller "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.API/Controllers/AdminController.cs"
click node_register "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Register/RegisterUserCommandHandler.cs"
click node_login "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Login/LoginUserCommandHandler.cs"
click node_refresh "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Refresh/RefreshTokenCommandHandler.cs"
click node_logout "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Logout/LogoutCommandHandler.cs"
click node_me "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Me/GetMeQueryHandler.cs"
click node_create_doctor "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Admin/CreateDoctor/CreateDoctorCommandHandler.cs"
click node_create_admin "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Admin/CreateAdmin/CreateAdminCommandHandler.cs"
click node_identity_interface "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Interfaces/IIdentityService.cs"
click node_identity_service "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Infrastructure/Identity/IdentityService.cs"
click node_app_user "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Infrastructure/Identity/AppUser.cs"
click node_token_helper "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Common/TokenGenerationHelper.cs"
click node_token_interface "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Interfaces/ITokenService.cs"
click node_jwt_service "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Infrastructure/Security/JwtTokenService.cs"
click node_refresh_entity "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Domain/Entities/RefreshToken.cs"
click node_refresh_interface "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Domain/Repositories/Interfaces/IRefreshTokenRepository.cs"
click node_refresh_repository "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Infrastructure/Persistence/RefreshTokenRepository.cs"
click node_db_context "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Infrastructure/Persistence/AppDbContext.cs"
click node_auth_result "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/DTO's/AuthResponseDto.cs"
click node_user_result "https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/DTO's/UserResponseDto.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_auth_controller,node_admin_controller,node_client,node_user_result toneBlue
class node_register,node_login,node_refresh,node_logout,node_me,node_create_doctor,node_create_admin toneAmber
class node_identity_interface,node_identity_service,node_app_user,node_token_helper,node_token_interface,node_jwt_service toneMint
class node_refresh_entity,node_refresh_interface,node_refresh_repository,node_db_context toneRose
class node_auth_result toneTeal
```

## Components

### API entry

- [Auth controller](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.API/Controllers/AuthController.cs): `LoReg/LoReg.API/Controllers/AuthController.cs`
- [Admin controller](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.API/Controllers/AdminController.cs): `LoReg/LoReg.API/Controllers/AdminController.cs`

### Application workflows

- [Register handler](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Register/RegisterUserCommandHandler.cs): `LoReg/LoReg.Application/Features/Auth/Register/RegisterUserCommandHandler.cs`
- [Login handler](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Login/LoginUserCommandHandler.cs): `LoReg/LoReg.Application/Features/Auth/Login/LoginUserCommandHandler.cs`
- [Refresh handler](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Refresh/RefreshTokenCommandHandler.cs): `LoReg/LoReg.Application/Features/Auth/Refresh/RefreshTokenCommandHandler.cs`
- [Logout handler](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Logout/LogoutCommandHandler.cs): `LoReg/LoReg.Application/Features/Auth/Logout/LogoutCommandHandler.cs`
- [Profile handler](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Me/GetMeQueryHandler.cs): `LoReg/LoReg.Application/Features/Auth/Me/GetMeQueryHandler.cs`
- [Create doctor handler](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Admin/CreateDoctor/CreateDoctorCommandHandler.cs): `LoReg/LoReg.Application/Features/Admin/CreateDoctor/CreateDoctorCommandHandler.cs`
- [Create admin handler](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Admin/CreateAdmin/CreateAdminCommandHandler.cs): `LoReg/LoReg.Application/Features/Admin/CreateAdmin/CreateAdminCommandHandler.cs`

### Identity services

- [Identity contract](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Interfaces/IIdentityService.cs): `LoReg/LoReg.Application/Interfaces/IIdentityService.cs`
- [Identity service](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Infrastructure/Identity/IdentityService.cs): `LoReg/LoReg.Infrastructure/Identity/IdentityService.cs`
- [Application user](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Infrastructure/Identity/AppUser.cs): `LoReg/LoReg.Infrastructure/Identity/AppUser.cs`
- [Token response helper](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Features/Auth/Common/TokenGenerationHelper.cs): `LoReg/LoReg.Application/Features/Auth/Common/TokenGenerationHelper.cs`
- [Token service contract](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/Interfaces/ITokenService.cs): `LoReg/LoReg.Application/Interfaces/ITokenService.cs`
- [JWT token service](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Infrastructure/Security/JwtTokenService.cs): `LoReg/LoReg.Infrastructure/Security/JwtTokenService.cs`

### Persistence and tokens

- [Refresh token](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Domain/Entities/RefreshToken.cs): `LoReg/LoReg.Domain/Entities/RefreshToken.cs`
- [Refresh token contract](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Domain/Repositories/Interfaces/IRefreshTokenRepository.cs): `LoReg/LoReg.Domain/Repositories/Interfaces/IRefreshTokenRepository.cs`
- [Refresh repository](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Infrastructure/Persistence/RefreshTokenRepository.cs): `LoReg/LoReg.Infrastructure/Persistence/RefreshTokenRepository.cs`
- [Application database](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Infrastructure/Persistence/AppDbContext.cs): `LoReg/LoReg.Infrastructure/Persistence/AppDbContext.cs`

### Other components

- **API client**
- [Auth response](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/DTO's/AuthResponseDto.cs): `LoReg/LoReg.Application/DTO's/AuthResponseDto.cs`
- [User response](https://github.com/nailrasulov/loginregisterapi/blob/main/LoReg/LoReg.Application/DTO's/UserResponseDto.cs): `LoReg/LoReg.Application/DTO's/UserResponseDto.cs`

## Connections

- API client → Auth controller: sends auth requests
- API client → Admin controller: sends admin requests
- Auth controller → Register handler: dispatches registration
- Auth controller → Login handler: dispatches login
- Auth controller → Refresh handler: dispatches refresh
- Auth controller → Logout handler: dispatches logout
- Auth controller → Profile handler: dispatches profile query
- Admin controller → Create doctor handler: dispatches doctor creation
- Admin controller → Create admin handler: dispatches admin creation
- Register handler → Identity contract: creates and finds user
- Login handler → Identity contract: checks and finds user
- Profile handler → Identity contract: finds user
- Create doctor handler → Identity contract: creates and finds user
- Create admin handler → Identity contract: creates and finds user
- Refresh handler → Identity contract: finds user
- Identity service → Identity contract: implements
- Identity service → Application user: uses user records
- Login handler → Token response helper: generates auth response
- Refresh handler → Token response helper: generates auth response
- Token response helper → Token service contract: uses token service
- JWT token service → Token service contract: implements
- Refresh handler → Refresh token contract: reads and revokes tokens
- Refresh repository → Refresh token contract: implements
- Refresh repository → Application database: reads and writes tokens
- Refresh repository → Refresh token: stores token records
- Login handler → Auth response: returns
- Refresh handler → Auth response: returns
- Register handler → User response: returns
- Profile handler → User response: returns
- Create doctor handler → User response: returns
- Create admin handler → User response: returns
