# verf1x/directoty-service architecture

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

- Interactive diagram: https://gitdiagram.com/verf1x/directoty-service
- Repository: https://github.com/verf1x/directoty-service

## Overview

DirectoryService is an HTTP CRUD service for shared organizational reference data: departments, positions and locations. Internal systems submit requests to the API; controllers dispatch commands and queries, application handlers validate and coordinate domain changes, and repositories persist or retrieve records in PostgreSQL. Department workflows include hierarchical parent changes and department–location associations, while location and department queries support searching, sorting and pagination. The tree and README establish the broader CRUD capabilities; sampled source confirms controller dispatch, transactional hierarchy updates and PostgreSQL access. Unsampled handler and position wiring is represented only at the module level.

Main entry points: [`backend/DirectoryService/src/DirectoryService.Application/Departments`](https://github.com/verf1x/directoty-service/tree/main/backend/DirectoryService/src/DirectoryService.Application/Departments) (Department workflows), [`backend/DirectoryService/src/DirectoryService.Application/Locations`](https://github.com/verf1x/directoty-service/tree/main/backend/DirectoryService/src/DirectoryService.Application/Locations) (Location workflows), [`backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/DirectoryServiceDbContext.cs`](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/DirectoryServiceDbContext.cs) (EF Core context), [`backend/DirectoryService/src/DirectoryService.Presentation/Controllers/LocationsController.cs`](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Presentation/Controllers/LocationsController.cs) (Locations API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_dept_api["Departments API"]
  node_loc_api["Locations API"]
  node_pos_api["Positions API"]
end

subgraph group_application["Application workflows"]
  node_dept_app["Department workflows<br/>[Departments]"]
  node_loc_app["Location workflows<br/>[Locations]"]
  node_pos_app["Position workflows<br/>[Positions]"]
  node_validation["Request validation<br/>[Validation]"]
  node_transactions["Transaction manager"]
end

subgraph group_domain["Directory domain"]
  node_dept_domain["Departments<br/>[Department.cs]"]
  node_location_domain["Locations<br/>[Location.cs]"]
  node_position_domain["Positions<br/>[Position.cs]"]
  node_associations["Department associations"]
end

subgraph group_persistence["PostgreSQL persistence"]
  node_dept_repo["Departments repository"]
  node_loc_repo["Locations repository"]
  node_pos_repo["Positions repository"]
  node_dbcontext["EF Core context"]
end

node_clients(("Internal services"))
node_postgres[("PostgreSQL")]

node_clients -->|"sends requests"| node_dept_api
node_clients -->|"sends requests"| node_loc_api
node_clients -->|"sends requests"| node_pos_api
node_dept_api -->|"dispatches commands"| node_dept_app
node_loc_api -->|"dispatches queries"| node_loc_app
node_loc_api -->|"dispatches commands"| node_loc_app
node_pos_api -->|"dispatches commands"| node_pos_app
node_dept_app -->|"validates requests"| node_validation
node_loc_app -->|"validates requests"| node_validation
node_pos_app -->|"validates requests"| node_validation
node_dept_app -->|"uses repository"| node_dept_repo
node_loc_app -->|"uses repository"| node_loc_repo
node_pos_app -->|"uses repository"| node_pos_repo
node_dept_app -->|"manages transactions"| node_transactions
node_dept_repo -->|"queries and saves"| node_dbcontext
node_loc_repo -->|"saves records"| node_dbcontext
node_pos_repo -->|"persists records"| node_dbcontext
node_dept_repo -->|"queries hierarchy"| node_postgres
node_loc_repo -->|"checks records"| node_postgres
node_dbcontext -->|"reads and writes"| node_postgres
node_dept_domain -->|"links locations"| node_associations

click node_dept_api "https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Presentation/Controllers/DepartmentsController.cs"
click node_loc_api "https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Presentation/Controllers/LocationsController.cs"
click node_pos_api "https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Presentation/Controllers/PositionsController.cs"
click node_dept_app "https://github.com/verf1x/directoty-service/tree/main/backend/DirectoryService/src/DirectoryService.Application/Departments"
click node_loc_app "https://github.com/verf1x/directoty-service/tree/main/backend/DirectoryService/src/DirectoryService.Application/Locations"
click node_pos_app "https://github.com/verf1x/directoty-service/tree/main/backend/DirectoryService/src/DirectoryService.Application/Positions"
click node_validation "https://github.com/verf1x/directoty-service/tree/main/backend/DirectoryService/src/DirectoryService.Application/Validation"
click node_transactions "https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Application/Database/ITransactionManager.cs"
click node_dept_domain "https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Domain/Departments/Department.cs"
click node_location_domain "https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Domain/Locations/Location.cs"
click node_position_domain "https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Domain/Positions/Position.cs"
click node_associations "https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Domain/DepartmentLocations/DepartmentLocation.cs"
click node_dept_repo "https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/Departments/DepartmentsRepository.cs"
click node_loc_repo "https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/Locations/LocationsRepository.cs"
click node_pos_repo "https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/Positions/PositionsRepository.cs"
click node_dbcontext "https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/DirectoryServiceDbContext.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_dept_api,node_loc_api,node_pos_api toneBlue
class node_dept_app,node_loc_app,node_pos_app,node_validation,node_transactions,node_postgres toneAmber
class node_dept_domain,node_location_domain,node_position_domain,node_associations toneMint
class node_dept_repo,node_loc_repo,node_pos_repo,node_dbcontext toneRose
class node_clients toneIndigo
```

## Components

### HTTP API

- [Departments API](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Presentation/Controllers/DepartmentsController.cs): `backend/DirectoryService/src/DirectoryService.Presentation/Controllers/DepartmentsController.cs`
- [Locations API](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Presentation/Controllers/LocationsController.cs): `backend/DirectoryService/src/DirectoryService.Presentation/Controllers/LocationsController.cs`
- [Positions API](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Presentation/Controllers/PositionsController.cs): `backend/DirectoryService/src/DirectoryService.Presentation/Controllers/PositionsController.cs`

### Application workflows

- [Department workflows](https://github.com/verf1x/directoty-service/tree/main/backend/DirectoryService/src/DirectoryService.Application/Departments): `backend/DirectoryService/src/DirectoryService.Application/Departments`
- [Location workflows](https://github.com/verf1x/directoty-service/tree/main/backend/DirectoryService/src/DirectoryService.Application/Locations): `backend/DirectoryService/src/DirectoryService.Application/Locations`
- [Position workflows](https://github.com/verf1x/directoty-service/tree/main/backend/DirectoryService/src/DirectoryService.Application/Positions): `backend/DirectoryService/src/DirectoryService.Application/Positions`
- [Request validation](https://github.com/verf1x/directoty-service/tree/main/backend/DirectoryService/src/DirectoryService.Application/Validation): `backend/DirectoryService/src/DirectoryService.Application/Validation`
- [Transaction manager](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Application/Database/ITransactionManager.cs): `backend/DirectoryService/src/DirectoryService.Application/Database/ITransactionManager.cs`

### Directory domain

- [Departments](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Domain/Departments/Department.cs): `backend/DirectoryService/src/DirectoryService.Domain/Departments/Department.cs`
- [Locations](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Domain/Locations/Location.cs): `backend/DirectoryService/src/DirectoryService.Domain/Locations/Location.cs`
- [Positions](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Domain/Positions/Position.cs): `backend/DirectoryService/src/DirectoryService.Domain/Positions/Position.cs`
- [Department associations](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Domain/DepartmentLocations/DepartmentLocation.cs): `backend/DirectoryService/src/DirectoryService.Domain/DepartmentLocations/DepartmentLocation.cs`

### PostgreSQL persistence

- [Departments repository](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/Departments/DepartmentsRepository.cs): `backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/Departments/DepartmentsRepository.cs`
- [Locations repository](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/Locations/LocationsRepository.cs): `backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/Locations/LocationsRepository.cs`
- [Positions repository](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/Positions/PositionsRepository.cs): `backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/Positions/PositionsRepository.cs`
- [EF Core context](https://github.com/verf1x/directoty-service/blob/main/backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/DirectoryServiceDbContext.cs): `backend/DirectoryService/src/DirectoryService.Infrastructure.Postgres/DirectoryServiceDbContext.cs`

### Other components

- **Internal services**
- **PostgreSQL**

## Connections

- Internal services → Departments API: sends requests
- Internal services → Locations API: sends requests
- Internal services → Positions API: sends requests
- Departments API → Department workflows: dispatches commands
- Locations API → Location workflows: dispatches queries
- Locations API → Location workflows: dispatches commands
- Positions API → Position workflows: dispatches commands
- Department workflows → Request validation: validates requests
- Location workflows → Request validation: validates requests
- Position workflows → Request validation: validates requests
- Department workflows → Departments repository: uses repository
- Location workflows → Locations repository: uses repository
- Position workflows → Positions repository: uses repository
- Department workflows → Transaction manager: manages transactions
- Departments repository → EF Core context: queries and saves
- Locations repository → EF Core context: saves records
- Positions repository → EF Core context: persists records
- Departments repository → PostgreSQL: queries hierarchy
- Locations repository → PostgreSQL: checks records
- EF Core context → PostgreSQL: reads and writes
- Departments → Department associations: links locations
