# krimtsev/portal-backend architecture

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

- Interactive diagram: https://gitdiagram.com/krimtsev/portal-backend
- Repository: https://github.com/krimtsev/portal-backend

## Overview

This is a Laravel business portal for managing franchise partners, staff, tickets, shared files, reporting, and operational data synchronized from Yclients and Mango. The user-facing workflow is an API request handled by a domain controller, which reads or changes application data and returns JSON or resources. Background jobs also synchronize external records into local models. The map emphasizes documented API and sync flows; the README is empty, and unsampled subsystems are included only where their role is clear from the tree, without speculative links.

Main entry points: [`app/Http/Controllers/Cloud/CloudController.php`](https://github.com/krimtsev/portal-backend/blob/master/app/Http/Controllers/Cloud/CloudController.php) (Cloud API), [`app/Http/Controllers/Tickets/TicketsController.php`](https://github.com/krimtsev/portal-backend/blob/master/app/Http/Controllers/Tickets/TicketsController.php) (Ticket API), [`app/Services/Yclients/SyncYcStorageTransactionService.php`](https://github.com/krimtsev/portal-backend/blob/master/app/Services/Yclients/SyncYcStorageTransactionService.php) (Storage sync service), [`app/Responses/JsonResponse.php`](https://github.com/krimtsev/portal-backend/blob/master/app/Responses/JsonResponse.php) (JSON responses)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Portal API"]
  node_cloud_api["Cloud API"]
  node_cloud_data["Cloud repository"]
  node_cloud_models[("Cloud files and folders<br/>[CloudFolder.php]")]
  node_tickets_api["Ticket API"]
  node_users_api["User administration<br/>[UserController.php]"]
end

subgraph group_operations["Partner Operations"]
  node_ticket_data[("Ticket records<br/>[Ticket.php]")]
  node_ticket_notify["Ticket notifications"]
  node_user_data[("User accounts<br/>[User.php]")]
  node_partners[("Partner directory<br/>[Partner.php]")]
end

subgraph group_analytics["Analytics And Reports"]
  node_statistics_api["Staff statistics API"]
  node_statistics_service["Staff statistics"]
  node_client_reports["Client reports"]
  node_report_export["Excel export"]
end

subgraph group_sync["Data Synchronization"]
  node_sync_command["Storage sync command"]
  node_sync_job["Storage sync job"]
  node_sync_service["Storage sync service"]
  node_yclients_api["Yclients API client<br/>[YclientsApi.php]"]
  node_storage_resource["Storage transactions resource"]
  node_transaction_dto["Transaction response DTO"]
  node_transaction_data[("Stored transactions")]
end

subgraph group_platform["Shared Services"]
  node_telegram["Telegram transport"]
  node_telegram_manager["Telegram manager"]
  node_pagination["Pagination helper<br/>[Pagination.php]"]
  node_cache["Cache helper<br/>[Cache.php]"]
  node_json_response["JSON responses<br/>[JsonResponse.php]"]
end

node_user(("Portal user"))

node_user -.->|"requests files"| node_cloud_api
node_user -.->|"manages tickets"| node_tickets_api
node_user -.->|"manages accounts"| node_users_api
node_cloud_api -->|"queries folders"| node_cloud_data
node_cloud_data -->|"reads records"| node_cloud_models
node_cloud_api -->|"loads folders"| node_cloud_models
node_cloud_api -->|"caches results"| node_cache
node_cloud_api -->|"returns JSON"| node_json_response
node_tickets_api -->|"reads and updates"| node_ticket_data
node_tickets_api -->|"sends notifications"| node_ticket_notify
node_tickets_api -->|"returns JSON"| node_json_response
node_users_api -->|"updates accounts"| node_user_data
node_users_api -->|"returns JSON"| node_json_response
node_statistics_api -->|"requests statistics"| node_statistics_service
node_statistics_service -->|"reads partner data"| node_partners
node_statistics_api -->|"returns JSON"| node_json_response
node_sync_command -->|"dispatches jobs"| node_sync_job
node_sync_job -->|"invokes sync"| node_sync_service
node_sync_service -->|"requests transactions"| node_yclients_api
node_sync_service -->|"maps response"| node_transaction_dto
node_sync_service -->|"upserts records"| node_transaction_data
node_yclients_api -.->|"provides resource"| node_storage_resource
node_telegram_manager -->|"uses transport"| node_telegram
node_statistics_api -.->|"paginates results"| node_pagination

click node_cloud_api "https://github.com/krimtsev/portal-backend/blob/master/app/Http/Controllers/Cloud/CloudController.php"
click node_cloud_data "https://github.com/krimtsev/portal-backend/blob/master/app/Repositories/Cloud/CloudRepository.php"
click node_cloud_models "https://github.com/krimtsev/portal-backend/blob/master/app/Models/Cloud/CloudFolder.php"
click node_tickets_api "https://github.com/krimtsev/portal-backend/blob/master/app/Http/Controllers/Tickets/TicketsController.php"
click node_ticket_data "https://github.com/krimtsev/portal-backend/blob/master/app/Models/Ticket/Ticket.php"
click node_ticket_notify "https://github.com/krimtsev/portal-backend/blob/master/app/Notifications/Ticket/TicketCreatedNotification.php"
click node_users_api "https://github.com/krimtsev/portal-backend/blob/master/app/Http/Controllers/Users/UserController.php"
click node_user_data "https://github.com/krimtsev/portal-backend/blob/master/app/Models/User/User.php"
click node_partners "https://github.com/krimtsev/portal-backend/blob/master/app/Models/Partner/Partner.php"
click node_statistics_api "https://github.com/krimtsev/portal-backend/blob/master/app/Http/Controllers/Statistics/StatisticsStaffController.php"
click node_statistics_service "https://github.com/krimtsev/portal-backend/blob/master/app/Services/Statistics/StatisticsStaffService.php"
click node_client_reports "https://github.com/krimtsev/portal-backend/blob/master/app/Services/Reports/ClientReportService.php"
click node_report_export "https://github.com/krimtsev/portal-backend/blob/master/app/Exports/Reports/ClientReportExcelExport.php"
click node_sync_command "https://github.com/krimtsev/portal-backend/blob/master/app/Console/Commands/SyncYcStorageTransactionsCommand.php"
click node_sync_job "https://github.com/krimtsev/portal-backend/blob/master/app/Jobs/Yclients/SyncYcStorageTransactionsJob.php"
click node_sync_service "https://github.com/krimtsev/portal-backend/blob/master/app/Services/Yclients/SyncYcStorageTransactionService.php"
click node_yclients_api "https://github.com/krimtsev/portal-backend/blob/master/app/Integrations/Yclients/YclientsApi.php"
click node_storage_resource "https://github.com/krimtsev/portal-backend/blob/master/app/Integrations/Yclients/Resources/StorageTransactions/StorageTransactionsResource.php"
click node_transaction_dto "https://github.com/krimtsev/portal-backend/blob/master/app/Integrations/Yclients/Resources/StorageTransactions/DTO/StorageTransactionsResponse.php"
click node_transaction_data "https://github.com/krimtsev/portal-backend/blob/master/app/Models/Yclients/YcStorageTransaction.php"
click node_telegram "https://github.com/krimtsev/portal-backend/blob/master/app/Integrations/Telegram/Transport/TelegramTransport.php"
click node_telegram_manager "https://github.com/krimtsev/portal-backend/blob/master/app/Integrations/Telegram/TelegramManager.php"
click node_pagination "https://github.com/krimtsev/portal-backend/blob/master/app/Helpers/Pagination/Pagination.php"
click node_cache "https://github.com/krimtsev/portal-backend/blob/master/app/Helpers/Cache.php"
click node_json_response "https://github.com/krimtsev/portal-backend/blob/master/app/Responses/JsonResponse.php"

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_cloud_api,node_cloud_data,node_cloud_models,node_tickets_api,node_users_api,node_user toneBlue
class node_ticket_data,node_ticket_notify,node_user_data,node_partners toneAmber
class node_statistics_api,node_statistics_service,node_client_reports,node_report_export toneMint
class node_sync_command,node_sync_job,node_sync_service,node_yclients_api,node_storage_resource,node_transaction_dto,node_transaction_data toneRose
class node_telegram,node_telegram_manager,node_pagination,node_cache,node_json_response toneIndigo
```

## Components

### Portal API

- [Cloud API](https://github.com/krimtsev/portal-backend/blob/master/app/Http/Controllers/Cloud/CloudController.php): `app/Http/Controllers/Cloud/CloudController.php`
- [Cloud repository](https://github.com/krimtsev/portal-backend/blob/master/app/Repositories/Cloud/CloudRepository.php): `app/Repositories/Cloud/CloudRepository.php`
- [Cloud files and folders](https://github.com/krimtsev/portal-backend/blob/master/app/Models/Cloud/CloudFolder.php): `app/Models/Cloud/CloudFolder.php`
- [Ticket API](https://github.com/krimtsev/portal-backend/blob/master/app/Http/Controllers/Tickets/TicketsController.php): `app/Http/Controllers/Tickets/TicketsController.php`
- [User administration](https://github.com/krimtsev/portal-backend/blob/master/app/Http/Controllers/Users/UserController.php): `app/Http/Controllers/Users/UserController.php`

### Partner Operations

- [Ticket records](https://github.com/krimtsev/portal-backend/blob/master/app/Models/Ticket/Ticket.php): `app/Models/Ticket/Ticket.php`
- [Ticket notifications](https://github.com/krimtsev/portal-backend/blob/master/app/Notifications/Ticket/TicketCreatedNotification.php): `app/Notifications/Ticket/TicketCreatedNotification.php`
- [User accounts](https://github.com/krimtsev/portal-backend/blob/master/app/Models/User/User.php): `app/Models/User/User.php`
- [Partner directory](https://github.com/krimtsev/portal-backend/blob/master/app/Models/Partner/Partner.php): `app/Models/Partner/Partner.php`

### Analytics And Reports

- [Staff statistics API](https://github.com/krimtsev/portal-backend/blob/master/app/Http/Controllers/Statistics/StatisticsStaffController.php): `app/Http/Controllers/Statistics/StatisticsStaffController.php`
- [Staff statistics](https://github.com/krimtsev/portal-backend/blob/master/app/Services/Statistics/StatisticsStaffService.php): `app/Services/Statistics/StatisticsStaffService.php`
- [Client reports](https://github.com/krimtsev/portal-backend/blob/master/app/Services/Reports/ClientReportService.php): `app/Services/Reports/ClientReportService.php`
- [Excel export](https://github.com/krimtsev/portal-backend/blob/master/app/Exports/Reports/ClientReportExcelExport.php): `app/Exports/Reports/ClientReportExcelExport.php`

### Data Synchronization

- [Storage sync command](https://github.com/krimtsev/portal-backend/blob/master/app/Console/Commands/SyncYcStorageTransactionsCommand.php): `app/Console/Commands/SyncYcStorageTransactionsCommand.php`
- [Storage sync job](https://github.com/krimtsev/portal-backend/blob/master/app/Jobs/Yclients/SyncYcStorageTransactionsJob.php): `app/Jobs/Yclients/SyncYcStorageTransactionsJob.php`
- [Storage sync service](https://github.com/krimtsev/portal-backend/blob/master/app/Services/Yclients/SyncYcStorageTransactionService.php): `app/Services/Yclients/SyncYcStorageTransactionService.php`
- [Yclients API client](https://github.com/krimtsev/portal-backend/blob/master/app/Integrations/Yclients/YclientsApi.php): `app/Integrations/Yclients/YclientsApi.php`
- [Storage transactions resource](https://github.com/krimtsev/portal-backend/blob/master/app/Integrations/Yclients/Resources/StorageTransactions/StorageTransactionsResource.php): `app/Integrations/Yclients/Resources/StorageTransactions/StorageTransactionsResource.php`
- [Transaction response DTO](https://github.com/krimtsev/portal-backend/blob/master/app/Integrations/Yclients/Resources/StorageTransactions/DTO/StorageTransactionsResponse.php): `app/Integrations/Yclients/Resources/StorageTransactions/DTO/StorageTransactionsResponse.php`
- [Stored transactions](https://github.com/krimtsev/portal-backend/blob/master/app/Models/Yclients/YcStorageTransaction.php): `app/Models/Yclients/YcStorageTransaction.php`

### Shared Services

- [Telegram transport](https://github.com/krimtsev/portal-backend/blob/master/app/Integrations/Telegram/Transport/TelegramTransport.php): `app/Integrations/Telegram/Transport/TelegramTransport.php`
- [Telegram manager](https://github.com/krimtsev/portal-backend/blob/master/app/Integrations/Telegram/TelegramManager.php): `app/Integrations/Telegram/TelegramManager.php`
- [Pagination helper](https://github.com/krimtsev/portal-backend/blob/master/app/Helpers/Pagination/Pagination.php): `app/Helpers/Pagination/Pagination.php`
- [Cache helper](https://github.com/krimtsev/portal-backend/blob/master/app/Helpers/Cache.php): `app/Helpers/Cache.php`
- [JSON responses](https://github.com/krimtsev/portal-backend/blob/master/app/Responses/JsonResponse.php): `app/Responses/JsonResponse.php`

### Other components

- **Portal user**

## Connections

- Portal user → Cloud API: requests files
- Portal user → Ticket API: manages tickets
- Portal user → User administration: manages accounts
- Cloud API → Cloud repository: queries folders (evidence: `app/Http/Controllers/Cloud/CloudController.php`)
- Cloud repository → Cloud files and folders: reads records (evidence: `app/Repositories/Cloud/CloudRepository.php`)
- Cloud API → Cloud files and folders: loads folders (evidence: `app/Http/Controllers/Cloud/CloudController.php`)
- Cloud API → Cache helper: caches results (evidence: `app/Http/Controllers/Cloud/CloudController.php`)
- Cloud API → JSON responses: returns JSON (evidence: `app/Http/Controllers/Cloud/CloudController.php`)
- Ticket API → Ticket records: reads and updates (evidence: `app/Http/Controllers/Tickets/TicketsController.php`)
- Ticket API → Ticket notifications: sends notifications (evidence: `app/Http/Controllers/Tickets/TicketsController.php`)
- Ticket API → JSON responses: returns JSON (evidence: `app/Http/Controllers/Tickets/TicketsController.php`)
- User administration → User accounts: updates accounts (evidence: `app/Http/Controllers/Users/UserController.php`)
- User administration → JSON responses: returns JSON (evidence: `app/Http/Controllers/Users/UserController.php`)
- Staff statistics API → Staff statistics: requests statistics (evidence: `app/Http/Controllers/Statistics/StatisticsStaffController.php`)
- Staff statistics → Partner directory: reads partner data (evidence: `app/Services/Statistics/StatisticsStaffService.php`)
- Staff statistics API → JSON responses: returns JSON (evidence: `app/Http/Controllers/Statistics/StatisticsStaffController.php`)
- Storage sync command → Storage sync job: dispatches jobs (evidence: `app/Console/Commands/SyncYcStorageTransactionsCommand.php`)
- Storage sync job → Storage sync service: invokes sync (evidence: `app/Jobs/Yclients/SyncYcStorageTransactionsJob.php`)
- Storage sync service → Yclients API client: requests transactions (evidence: `app/Services/Yclients/SyncYcStorageTransactionService.php`)
- Storage sync service → Transaction response DTO: maps response (evidence: `app/Services/Yclients/SyncYcStorageTransactionService.php`)
- Storage sync service → Stored transactions: upserts records (evidence: `app/Services/Yclients/SyncYcStorageTransactionService.php`)
- Yclients API client → Storage transactions resource: provides resource (evidence: `app/Integrations/Yclients/YclientsApi.php`)
- Telegram manager → Telegram transport: uses transport (evidence: `app/Integrations/Telegram/TelegramManager.php`)
- Staff statistics API → Pagination helper: paginates results
