# drusmanov/the_system_project architecture

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

- Interactive diagram: https://gitdiagram.com/drusmanov/the_system_project
- Repository: https://github.com/drusmanov/the_system_project

## Overview

This is an HTTP backend for managing refinery production departments, employees and working-time records. The main user workflow is an API request routed to login, shop or timesheet handling, translated through an application gateway, and handled by application/domain services backed by repositories. The README also describes user, training, safety-briefing, equipment and production-work modules, but the supplied tree does not show implementations for several of these; they are not represented as implemented runtime components. Some internal calls are left unverified because their implementation excerpts were not supplied.

Main entry points: [`src/infrastructure/handlers/request_handler/request_handler.cpp`](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/handlers/request_handler/request_handler.cpp) (Request router), [`src/application/application_manager/application_manager.cpp`](https://github.com/drusmanov/the_system_project/blob/main/src/application/application_manager/application_manager.cpp) (Application manager), [`src/application/application_gateway/application_gateway.cpp`](https://github.com/drusmanov/the_system_project/blob/main/src/application/application_gateway/application_gateway.cpp) (Application gateway), [`src/infrastructure/repositories_impl/timesheet_repository/timesheet_repository.cpp`](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/repositories_impl/timesheet_repository/timesheet_repository.cpp) (Timesheet repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP interface"]
  node_server["HTTP server<br/>[http_server.cpp]"]
  node_router["Request router"]
  node_login["Login handler"]
  node_shop["Shop handlers"]
  node_timesheet["Timesheet handlers"]
end

subgraph group_app["Application"]
  node_gateway["Application gateway"]
  node_manager["Application manager"]
  node_dto["DTO mappers"]
end

subgraph group_domain["Domain services"]
  node_user["User service<br/>[user_service.cpp]"]
  node_permission["Permission service"]
  node_shopservice["Shop service<br/>[shop_service.cpp]"]
  node_timeservice["Timesheet service"]
  node_entities["Domain records"]
end

subgraph group_infra["Persistence and security"]
  node_shoprepo["Shop repository"]
  node_timerepo["Timesheet repository"]
  node_userrepo["User repository"]
  node_permrepo["Permission repository"]
  node_uow["Unit of work<br/>[uow_impl.cpp]"]
  node_sql["SQL definitions<br/>[querys.h]"]
  node_tokens["Token manager<br/>[token_manager.cpp]"]
  node_json["JSON formatter<br/>[json_formater.cpp]"]
end

node_client(("API client"))
node_database[("Relational database")]

node_client -->|"sends HTTP"| node_server
node_server -->|"dispatches requests"| node_router
node_router -->|"routes login"| node_login
node_router -->|"routes shop"| node_shop
node_router -->|"routes timesheets"| node_timesheet
node_login -->|"calls API"| node_gateway
node_shop -->|"calls API"| node_gateway
node_timesheet -->|"calls API"| node_gateway
node_gateway -.->|"maps DTOs"| node_dto
node_gateway -.->|"delegates operations"| node_manager
node_manager -.->|"uses service"| node_user
node_manager -.->|"checks access"| node_permission
node_manager -.->|"uses service"| node_shopservice
node_manager -.->|"uses service"| node_timeservice
node_shopservice -.->|"loads shop data"| node_shoprepo
node_timeservice -.->|"reads and writes"| node_timerepo
node_user -.->|"loads users"| node_userrepo
node_permission -.->|"loads permissions"| node_permrepo
node_shoprepo -->|"uses queries"| node_sql
node_timerepo -->|"uses queries"| node_sql
node_shoprepo -.->|"persists data"| node_database
node_timerepo -.->|"persists records"| node_database
node_router -->|"validates token"| node_tokens
node_login -->|"creates token"| node_tokens
node_entities -.->|"domain types"| node_shopservice
node_entities -.->|"domain types"| node_timeservice
node_timerepo -->|"formats records"| node_json

click node_server "https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/http_server/http_server.cpp"
click node_router "https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/handlers/request_handler/request_handler.cpp"
click node_login "https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/handlers/login_request_handler/login_request_handler.cpp"
click node_shop "https://github.com/drusmanov/the_system_project/tree/main/src/infrastructure/handlers/shop_request_handler"
click node_timesheet "https://github.com/drusmanov/the_system_project/tree/main/src/infrastructure/handlers/timesheet_request_handler"
click node_gateway "https://github.com/drusmanov/the_system_project/blob/main/src/application/application_gateway/application_gateway.cpp"
click node_manager "https://github.com/drusmanov/the_system_project/blob/main/src/application/application_manager/application_manager.cpp"
click node_dto "https://github.com/drusmanov/the_system_project/tree/main/src/application/application_gateway/dto_mappers"
click node_user "https://github.com/drusmanov/the_system_project/blob/main/src/domain/services/user_service/user_service.cpp"
click node_permission "https://github.com/drusmanov/the_system_project/blob/main/src/domain/services/permission_service/permission_service.cpp"
click node_shopservice "https://github.com/drusmanov/the_system_project/blob/main/src/domain/services/shop_service/shop_service.cpp"
click node_timeservice "https://github.com/drusmanov/the_system_project/blob/main/src/domain/services/timesheet_service/timesheet_service.cpp"
click node_entities "https://github.com/drusmanov/the_system_project/tree/main/src/domain/entities"
click node_shoprepo "https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/repositories_impl/shop_repository/shop_repository.cpp"
click node_timerepo "https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/repositories_impl/timesheet_repository/timesheet_repository.cpp"
click node_userrepo "https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/repositories_impl/user_repository/user_repository.cpp"
click node_permrepo "https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/repositories_impl/permission_repository/permission_repository.cpp"
click node_uow "https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/uow_impl/uow_impl.cpp"
click node_sql "https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/connection_pool/querys.h"
click node_tokens "https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/token_manager/token_manager.cpp"
click node_json "https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/json_formater/json_formater.cpp"

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_server,node_router,node_login,node_shop,node_timesheet,node_client toneBlue
class node_gateway,node_manager,node_dto,node_database toneAmber
class node_user,node_permission,node_shopservice,node_timeservice,node_entities toneMint
class node_shoprepo,node_timerepo,node_userrepo,node_permrepo,node_uow,node_sql,node_tokens,node_json toneRose
```

## Components

### HTTP interface

- [HTTP server](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/http_server/http_server.cpp): `src/infrastructure/http_server/http_server.cpp`
- [Request router](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/handlers/request_handler/request_handler.cpp): `src/infrastructure/handlers/request_handler/request_handler.cpp`
- [Login handler](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/handlers/login_request_handler/login_request_handler.cpp): `src/infrastructure/handlers/login_request_handler/login_request_handler.cpp`
- [Shop handlers](https://github.com/drusmanov/the_system_project/tree/main/src/infrastructure/handlers/shop_request_handler): `src/infrastructure/handlers/shop_request_handler`
- [Timesheet handlers](https://github.com/drusmanov/the_system_project/tree/main/src/infrastructure/handlers/timesheet_request_handler): `src/infrastructure/handlers/timesheet_request_handler`

### Application

- [Application gateway](https://github.com/drusmanov/the_system_project/blob/main/src/application/application_gateway/application_gateway.cpp): `src/application/application_gateway/application_gateway.cpp`
- [Application manager](https://github.com/drusmanov/the_system_project/blob/main/src/application/application_manager/application_manager.cpp): `src/application/application_manager/application_manager.cpp`
- [DTO mappers](https://github.com/drusmanov/the_system_project/tree/main/src/application/application_gateway/dto_mappers): `src/application/application_gateway/dto_mappers`

### Domain services

- [User service](https://github.com/drusmanov/the_system_project/blob/main/src/domain/services/user_service/user_service.cpp): `src/domain/services/user_service/user_service.cpp`
- [Permission service](https://github.com/drusmanov/the_system_project/blob/main/src/domain/services/permission_service/permission_service.cpp): `src/domain/services/permission_service/permission_service.cpp`
- [Shop service](https://github.com/drusmanov/the_system_project/blob/main/src/domain/services/shop_service/shop_service.cpp): `src/domain/services/shop_service/shop_service.cpp`
- [Timesheet service](https://github.com/drusmanov/the_system_project/blob/main/src/domain/services/timesheet_service/timesheet_service.cpp): `src/domain/services/timesheet_service/timesheet_service.cpp`
- [Domain records](https://github.com/drusmanov/the_system_project/tree/main/src/domain/entities): `src/domain/entities`

### Persistence and security

- [Shop repository](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/repositories_impl/shop_repository/shop_repository.cpp): `src/infrastructure/repositories_impl/shop_repository/shop_repository.cpp`
- [Timesheet repository](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/repositories_impl/timesheet_repository/timesheet_repository.cpp): `src/infrastructure/repositories_impl/timesheet_repository/timesheet_repository.cpp`
- [User repository](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/repositories_impl/user_repository/user_repository.cpp): `src/infrastructure/repositories_impl/user_repository/user_repository.cpp`
- [Permission repository](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/repositories_impl/permission_repository/permission_repository.cpp): `src/infrastructure/repositories_impl/permission_repository/permission_repository.cpp`
- [Unit of work](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/uow_impl/uow_impl.cpp): `src/infrastructure/uow_impl/uow_impl.cpp`
- [SQL definitions](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/connection_pool/querys.h): `src/infrastructure/connection_pool/querys.h`
- [Token manager](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/token_manager/token_manager.cpp): `src/infrastructure/token_manager/token_manager.cpp`
- [JSON formatter](https://github.com/drusmanov/the_system_project/blob/main/src/infrastructure/json_formater/json_formater.cpp): `src/infrastructure/json_formater/json_formater.cpp`

### Other components

- **API client**
- **Relational database**

## Connections

- API client → HTTP server: sends HTTP
- HTTP server → Request router: dispatches requests
- Request router → Login handler: routes login
- Request router → Shop handlers: routes shop
- Request router → Timesheet handlers: routes timesheets
- Login handler → Application gateway: calls API
- Shop handlers → Application gateway: calls API (evidence: `src/infrastructure/handlers/shop_request_handler/shop_request_handler.h`)
- Timesheet handlers → Application gateway: calls API (evidence: `src/infrastructure/handlers/timesheet_request_handler/timesheet_request_handler.h`)
- Application gateway → DTO mappers: maps DTOs
- Application gateway → Application manager: delegates operations
- Application manager → User service: uses service
- Application manager → Permission service: checks access
- Application manager → Shop service: uses service
- Application manager → Timesheet service: uses service
- Shop service → Shop repository: loads shop data
- Timesheet service → Timesheet repository: reads and writes
- User service → User repository: loads users
- Permission service → Permission repository: loads permissions
- Shop repository → SQL definitions: uses queries (evidence: `src/infrastructure/repositories_impl/shop_repository/shop_repository.cpp`)
- Timesheet repository → SQL definitions: uses queries (evidence: `src/infrastructure/repositories_impl/timesheet_repository/timesheet_repository.cpp`)
- Shop repository → Relational database: persists data
- Timesheet repository → Relational database: persists records
- Request router → Token manager: validates token
- Login handler → Token manager: creates token
- Domain records → Shop service: domain types
- Domain records → Timesheet service: domain types (evidence: `src/domain/services/timesheet_service/timesheet_service.cpp`)
- Timesheet repository → JSON formatter: formats records (evidence: `src/infrastructure/repositories_impl/timesheet_repository/timesheet_repository.cpp`)
