# santbohara/helpdesk architecture

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

- Interactive diagram: https://gitdiagram.com/santbohara/helpdesk
- Repository: https://github.com/santbohara/helpdesk

## Overview

##### Project type and purpose
- This is a full-stack web application (“Helpdesk”) built on Laravel 10 (PHP) with Livewire (server-driven UI), Vite (asset bundling), and Tailwind CSS.
- It provides two main user flows: Public users can browse topics, raise tickets, receive notifications; Admin users log into a dashboard to manage tickets, topics, roles/permissions, site settings, and export data.

##### File structure
Top-level directories & roles:
- app/              → Core PHP code (Controllers, Models, Livewire components, Helpers, Exports, Notifications, Console commands, Providers)
- config/           → Laravel configuration files (database, cache, mail, permission, Livewire alert, etc.)
- routes/           → Route definition files split into admin (manage-menu, manage-roles, manage-users, site-settings, tickets, topics), public, web.php, api.php
- resources/        → Frontend assets (resources/js, resources/css), Blade views (layouts, components, admin, public, Livewire views), localization files
- database/         → Migrations, seeders, factories
- storage/          → File storage (sessions, cache, logs, debugbar)
- tests/            → PHPUnit/Pest feature and unit tests
- build tools       → composer.json/lock (PHP deps), package.json/lock & vite.config.js, tailwind.config.js (JS/CSS deps)

Architectural patterns & indicators:
- MVC: app/Http/Controllers, app/Models
- Livewire for reactive components (app/Http/Livewire + corresponding Blade templates)
- Modular route groups for admin vs public
- Event/Notification system (app/Notifications)
- Excel exports via Maatwebsite\Excel (app/Exports)

##### Extract README insights
- “Made with Laravel 10 + Livewire + Vite + Tailwind.”
- No external microservices are mentioned—standard monolith.
- Relies on database (MySQL/Postgres), mail server (SMTP/Mailgun), local filesystem (or S3 driver), possibly Redis for cache/queues (configured in .env).

a. Main components
1. Client browsers (Admin UI & Public UI)
2. Web server (Nginx/Apache)
3. Laravel application
- HTTP Kernel & Router
- Controllers (Admin, Auth, Public)
- Livewire components (real-time UI updates)
- Services: Exports, Notifications, Helpers
4. Database (MySQL/Postgres)
5. File storage (local or S3 driver)
6. Mail service (SMTP/Mailgun)
7. Cache/session store (Redis or file)
8. Queue system (Redis or database)
9. Asset pipeline (Vite dev/production builds)

b. Relationships & data flows
- Browser → HTTP(S) → Web server → Laravel’s public/index.php → HTTP Kernel → Routing → Controller or Livewire
- Controller ↔ Eloquent Models ↔ Database
- Livewire front-to-back calls over AJAX/WebSockets for partial updates
- Controllers trigger Notifications → Mail service
- Exports read data via Models → generate spreadsheets → streamed to browser
- Laravel uses Cache/Session store (Redis) for sessions, throttling
- Queue jobs for email sending, long-running exports
- Vite bundles JS/CSS, served as static assets via public/ directory

c. Architectural patterns & design principles
- Monolithic MVC with modular subdomains (admin vs public)
- Server-side reactive UI via Livewire (component-driven)
- SRP in Controllers and Livewire classes
- Event-driven notifications (Observer pattern)
- Dependency injection via Service Providers
- Layered separation: HTTP layer, business logic, persistence layer

d. Key technologies & frameworks
- Laravel 10 (PHP 8.x), Livewire, Eloquent ORM, Maatwebsite Excel
- Vite (JS bundler), Tailwind CSS
- MySQL/PostgreSQL, Redis (optional), SMTP/Mailgun

## Diagram (Mermaid)

```mermaid
graph TB
    %% Frontend Layer
    subgraph "Frontend" 
        direction TB
        BrowserAdmin["Admin UI (Browser)"] 
        BrowserPublic["Public UI (Browser)"] 
        Vite["Vite Bundler"] 
        CSSJS["CSS/JS Assets"] 
    end

    %% Backend Layer
    subgraph "Backend Monolith"
        direction TB
        WebServer["Web Server\n(Nginx/Apache)"] 
        PHPFPM["PHP-FPM / Laravel Kernel"] 
        HTTPKernel["HTTP Kernel"] 
        Router["Router Configuration"] 
        ServiceProviders["Service Providers"] 
        Middleware["Middleware"] 

        subgraph "Controllers"
            direction TB
            AuthControllers["Auth Controllers"] 
            AdminControllers["Admin Controllers"] 
            PublicControllers["Public Controllers"] 
        end

        subgraph "Livewire Components"
            direction TB
            LivewireAdmin["Livewire (Admin)"] 
            LivewirePublic["Livewire (Public)"] 
        end

        Helpers["Helper: GenerateTicketID"] 
        Exports["Excel Exports"] 
        NotificationsAdmin["Notifications (Admin)"] 
        NotificationsPublic["Notifications (Public)"] 
        ModelsCore["Models (Core)"] 
        ModelsAdmin["Models (Admin)"] 
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        Database["Database\n(MySQL/Postgres)"] 
        RedisStore["Cache/Session Store (Redis)"] 
    end

    %% External Services
    subgraph "External Services"
        direction TB
        MailService["Mail Service\n(SMTP/Mailgun)"] 
        FileStorage["File Storage\n(Local/S3)"] 
    end

    %% Connections: Frontend to Backend
    BrowserAdmin -->|HTTPS Request| WebServer
    BrowserPublic -->|HTTPS Request| WebServer
    Vite -->|Builds| CSSJS
    CSSJS -->|Served as Static| WebServer

    %% HTTP Flow
    WebServer -->|Pass to PHP-FPM| PHPFPM
    PHPFPM -->|Bootstrap| HTTPKernel
    HTTPKernel -->|Apply| ServiceProviders
    HTTPKernel -->|Apply| Middleware
    HTTPKernel -->|Route| Router

    %% Routing to Handlers
    Router -->|web.php/api.php/admin/public| AuthControllers
    Router -->|admin routes| AdminControllers
    Router -->|public routes| PublicControllers
    Router -->|livewire endpoints| LivewireAdmin
    Router -->|livewire endpoints| LivewirePublic

    %% Controllers & Livewire interactions
    AuthControllers -->|uses| ModelsCore
    AdminControllers -->|CRUD| ModelsCore
    AdminControllers -->|CRUD| ModelsAdmin
    PublicControllers -->|CRUD| ModelsCore
    LivewireAdmin -->|AJAX/WebSocket| BrowserAdmin
    LivewirePublic -->|AJAX/WebSocket| BrowserPublic
    LivewireAdmin -->|uses| ModelsCore
    LivewirePublic -->|uses| ModelsCore

    %% Services within backend
    AdminControllers -->|trigger| NotificationsAdmin
    PublicControllers -->|trigger| NotificationsPublic
    NotificationsAdmin -->|send via| MailService
    NotificationsPublic -->|send via| MailService

    ControllersSubgraph(("Controllers")) -.->|import| Helpers
    LivewireAdmin -->|helper| Helpers
    LivewirePublic -->|helper| Helpers

    AdminControllers -->|export data| Exports
    Exports -->|reads| ModelsCore
    Exports -->|stream to| BrowserAdmin

    %% Data Stores connections
    HTTPKernel -->|session/cache| RedisStore
    AuthControllers -->|sessions| RedisStore
    AdminControllers -->|caching| RedisStore
    PublicControllers -->|caching| RedisStore

    ControllersSubgraph -.->|database queries| Database
    LivewireAdmin -->|DB queries| Database
    LivewirePublic -->|DB queries| Database

    %% File Storage
    AdminControllers -->|store files| FileStorage
    PublicControllers -->|store files| FileStorage

    %% Click Events
    click HTTPKernel "https://github.com/santbohara/helpdesk/blob/master/app/Http/Kernel.php"
    click Middleware "https://github.com/santbohara/helpdesk/tree/master/app/Http/Middleware/"
    click Router "https://github.com/santbohara/helpdesk/blob/master/routes/web.php"
    click AuthControllers "https://github.com/santbohara/helpdesk/tree/master/app/Http/Controllers/Auth/"
    click AdminControllers "https://github.com/santbohara/helpdesk/tree/master/app/Http/Controllers/Admin/"
    click PublicControllers "https://github.com/santbohara/helpdesk/tree/master/app/Http/Controllers/Public/"
    click LivewireAdmin "https://github.com/santbohara/helpdesk/tree/master/app/Http/Livewire/Admin/"
    click LivewirePublic "https://github.com/santbohara/helpdesk/tree/master/app/Http/Livewire/Public/"
    click ModelsCore "https://github.com/santbohara/helpdesk/tree/master/app/Models/"
    click ModelsAdmin "https://github.com/santbohara/helpdesk/tree/master/app/Models/Admin/"
    click NotificationsAdmin "https://github.com/santbohara/helpdesk/tree/master/app/Notifications/Admin/"
    click NotificationsPublic "https://github.com/santbohara/helpdesk/tree/master/app/Notifications/Public/"
    click Exports "https://github.com/santbohara/helpdesk/tree/master/app/Exports/Admin/"
    click Helpers "https://github.com/santbohara/helpdesk/blob/master/app/Helpers/GenerateTicketID.php"
    click ServiceProviders "https://github.com/santbohara/helpdesk/tree/master/app/Providers/"

    %% Styles
    classDef frontend fill:#e0f7ea,stroke:#2d8f50
    classDef backend fill:#e3f6fd,stroke:#0b69a3
    classDef datastore fill:#ffe4b3,stroke:#d08500
    classDef external fill:#e0e0e0,stroke:#7a7a7a

    class BrowserAdmin,BrowserPublic,Vite,CSSJS frontend
    class WebServer,PHPFPM,HTTPKernel,Router,ServiceProviders,Middleware,AuthControllers,AdminControllers,PublicControllers,LivewireAdmin,LivewirePublic,Helpers,Exports,NotificationsAdmin,NotificationsPublic,ModelsCore,ModelsAdmin backend
    class Database,RedisStore datastore
    class MailService,FileStorage external
```
