# gquantic/skytec-backend architecture

> Architecture diagram of the GitHub repository gquantic/skytec-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gquantic/skytec-backend
- Repository: https://github.com/gquantic/skytec-backend

## Overview

##### Project type and purpose
- This is a full-stack monolithic web application built on the Laravel framework.
- It provides:
- A RESTful API (app/Http/Controllers/Api) secured via personal access tokens (Laravel Sanctum).
- A server-rendered web front-end (Blade templates in resources/views).
- An administrative back-office built with the Orchid platform (app/Orchid).
- Background tasks and CLI commands (app/Console, queues, events/listeners).
- Data management for entities such as users, applications (vacation, education, business trip), news, articles, emoji, help-desk requests, business ideas, etc.

##### File structure
- Top-level directories:
- app/ → core application code (Models, Controllers, Services, Repositories, Events, Listeners, Console commands).
- resources/ → front-end assets and Blade templates.
- public/ → webroot, index.php, static assets.
- routes/ → route definitions (api.php, web.php, platform.php).
- config/ → framework and custom configuration.
- database/ → migrations, seeders, factories.
- orchid → admin panel customizations.
- tests/ → automated tests.
- Key technologies:
- Laravel (routing, controllers, Eloquent ORM).
- Sanctum (API authentication).
- Orchid (admin UI).
- Vite (JS/CSS bundling).
- Blade templating.
- Eloquent repositories and a service layer.
- Queues, events & listeners for async processes (mail, emoji updates, token cleanup).

##### README
- Confirms the use of Laravel and links to docs.

##### Components & relationships
A. External Clients
1. Web Browser – requests web routes (Blade views).
2. SPA / Mobile App – consumes REST API endpoints.
3. Admin User – accesses Orchid back-office via platform routes.
B. Entry Point & HTTP Layer
– NGINX/Apache (public/index.php) → Laravel HTTP Kernel → Middleware (e.g., ApiAccessToken).
C. Application Layer
1. Controllers
- API Controllers (app/Http/Controllers/Api/*)
- Web Controllers (routes/web.php → controllers rendering Blade)
- Orchid Screens & Layouts (app/Orchid)
2. Requests & Validation (app/Http/Requests)
D. Business Logic & Services
– Service Layer (app/Services/*) orchestrates use cases.
– Repositories (app/Repositories/*) abstract data access on Models.
E. Data Layer
– Eloquent Models (app/Models)
– Migrations & Seeders (database/)
– Database (MySQL/PostgreSQL)
– Cache & Queues (Redis or database)
– File storage for emojis, attachments (storage/, public/emojis)
F. Asynchronous & CLI
– Jobs & Queues (config/queue.php, app/Console)
– Events & Listeners (app/Events, app/Listeners) for sending emails, notifications
– Artisan Commands (app/Console/Commands) for scheduled operations
G. External Services
– SMTP Mail Server (app/Mail)
– LDAP (config/ldap.php)
– Third-party APIs (app/Services/ApiService)

##### Architectural patterns & design principles
- MVC + Service Layer + Repository Pattern
- Layered architecture:
- Presentation (Controllers, Views, Orchid Screens)
- Application Services
- Domain (Models)
- Infrastructure (Database, Cache, Mail, LDAP)
- Separation of concerns: validation, business logic, data access

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    subgraph "Clients" 
        direction TB
        WebBrowser["Web Browser"]:::external
        SPAMobile["SPA / Mobile App"]:::external
        AdminUser["Admin User"]:::external
    end

    %% HTTP Layer
    subgraph "HTTP Layer"
        direction TB
        FrontController["public/index.php\n(Front Controller)"]:::http
        Middleware["ApiAccessToken Middleware"]:::http
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        APIControllers["RESTful API Controllers"]:::core
        WebControllers["Web Controllers"]:::core
        OrchidScreens["Orchid Screens & Layouts"]:::core
        FormRequests["Form Requests & Validation"]:::core
        Services["Service Layer"]:::core
        Repositories["Repository Layer"]:::core
    end

    %% Domain & Infra
    subgraph "Domain & Infrastructure"
        direction TB
        Models["Eloquent Models"]:::data
        Migrations["Database Migrations"]:::data
        Seeders["Seeders & Factories"]:::data
        DB["Database (MySQL/PostgreSQL)"]:::data
        Cache["Cache & Sessions"]:::data
        FileStorage["File Storage"]:::data
        SMTP["SMTP Mail Server"]:::external
        LDAP["LDAP Service"]:::external
        ThirdAPI["Third-party APIs"]:::external
    end

    %% Async & CLI
    subgraph "Async & CLI"
        direction TB
        Queues["Jobs & Queues"]:::async
        Events["Events & Listeners"]:::async
        CLICommands["Artisan Commands"]:::async
    end

    %% Connections
    WebBrowser -->|"HTTP Request\nBlade Views"| FrontController
    SPAMobile -->|"REST API Request"| FrontController
    AdminUser -->|"Admin Routes"| FrontController

    FrontController -->|bootstrap| Middleware
    Middleware -->|dispatch| APIControllers
    FrontController -->|dispatch| WebControllers
    FrontController -->|dispatch| OrchidScreens

    APIControllers -->|validate via| FormRequests
    WebControllers -->|validate via| FormRequests
    OrchidScreens -->|validate via| FormRequests

    APIControllers -->|use| Services
    WebControllers -->|use| Services
    OrchidScreens -->|use| Services

    Services -->|access| Repositories
    Repositories -->|query| Models
    Models -->|migrate| Migrations
    Models -->|seed| Seeders
    Repositories -->|persist| DB
    Repositories -->|cache| Cache
    Repositories -->|store files| FileStorage

    Services -->|dispatch| Queues
    APIControllers -->|raise| Events
    Events -->|trigger| Events
    Events -->|send mail| SMTP
    Queues -->|process| CLICommands

    Services -->|call| ThirdAPI
    Services -->|authenticate| LDAP

    %% Click Events
    click APIControllers "https://github.com/gquantic/skytec-backend/tree/master/app/Http/Controllers/Api"
    click Middleware "https://github.com/gquantic/skytec-backend/blob/master/app/Http/Middleware/ApiAccessToken.php"
    click WebControllers "https://github.com/gquantic/skytec-backend/tree/master/app/Http/Controllers"
    click OrchidScreens "https://github.com/gquantic/skytec-backend/tree/master/app/Orchid/Screens"
    click FormRequests "https://github.com/gquantic/skytec-backend/tree/master/app/Http/Requests"
    click Services "https://github.com/gquantic/skytec-backend/tree/master/app/Services"
    click Repositories "https://github.com/gquantic/skytec-backend/tree/master/app/Repositories"
    click Models "https://github.com/gquantic/skytec-backend/tree/master/app/Models"
    click Migrations "https://github.com/gquantic/skytec-backend/tree/master/database/migrations"
    click Seeders "https://github.com/gquantic/skytec-backend/tree/master/database/seeders"
    click Seeders "https://github.com/gquantic/skytec-backend/tree/master/database/factories"
    click CLICommands "https://github.com/gquantic/skytec-backend/tree/master/app/Console/Commands"
    click SMTP "https://github.com/gquantic/skytec-backend/tree/master/app/Mail"
    click LDAP "https://github.com/gquantic/skytec-backend/blob/master/config/ldap.php"
    click ThirdAPI "https://github.com/gquantic/skytec-backend/blob/master/app/Services/ApiService.php"
    click FrontController "https://github.com/gquantic/skytec-backend/blob/master/public/index.php"
    click Cache "https://github.com/gquantic/skytec-backend/tree/master/storage/framework/cache"
    click Cache "https://github.com/gquantic/skytec-backend/tree/master/storage/framework/sessions"

    %% Styles
    classDef external fill:#c6f6d5,stroke:#2f855a,color:#2f855a
    classDef http fill:#bee3f8,stroke:#2b6cb0,color:#2b6cb0
    classDef core fill:#faf089,stroke:#d69e2e,color:#975a16
    classDef data fill:#fdd7e4,stroke:#c05621,color:#822727
    classDef async fill:#e9d8fd,stroke:#6b46c1,color:#44337a
```
