# hasnayeen/booked architecture

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

- Interactive diagram: https://gitdiagram.com/hasnayeen/booked
- Repository: https://github.com/hasnayeen/booked

## Overview

##### Project type and purpose
- This is a monolithic, full-stack web application built on Laravel (PHP).
- It provides a bus-booking system (“Booked”) with three user panels: Admin, Operator, and Guest. Operators manage buses, routes, schedules, and bookings; Admin oversees operators and roles; Guests can search and view available routes.

##### File structure
- Top-level folders:
- public – web root serving index.php, static assets (CSS, JS, fonts).
- app – core application code (Models, Controllers, Policies, Notifications, Filament resources for panels).
- resources – Blade views, localized text, CSS/JS sources.
- routes – web.php and console.php define HTTP and CLI entry points.
- database – migrations, seeders, factories.
- config – Laravel configuration for auth, database, cache, queue, services.
- Filament panels under app/Filament: separate namespaces for Admin, Operator, and Guest.
- Middleware, Requests, Policies enforce business rules and access control.
- Queued notifications and jobs indicated by Notifications and queue.php config.

##### README
- Minimal description, but “Booked” name implies a booking system.
- No pre-drawn architecture, so we infer patterns from code and directory layout.

##### Main components
A. Clients
- Admin user interface (Filament AdminPanel)
- Operator user interface (Filament OperatorPanel)
- Guest user interface (Filament GuestPanel + public pages)
B. Web Tier
- HTTP server (Nginx/Apache) + PHP-FPM
- Laravel HTTP Kernel
- Routing layer (routes/web.php)
- Middleware (PanelCommonConfig, auth checks)
- Controllers (app/Http/Controllers)
- Form Requests (validation)
C. Application / Business Logic
- Filament Resource classes (app/Filament/…/Resources)
- Services: Notifications, Policies, Casts, Enums, ValueObjects
- Eloquent Models (Booking, Bus, Route, RouteSchedule, User, Operator, Role, Permission)
D. Data Layer
- Relational Database (MySQL/PostgreSQL) – tables created via migrations under database/migrations
- Eloquent ORM for read/write operations
E. Infrastructure Services
- File Storage (local / S3) for logo and uploaded assets
- Queue system (Redis / database) for asynchronous jobs (notifications)
- Mail / Notification service (SMTP, Mailgun, etc.)
- Cache (file or Redis)
F. Development / CI
- GitHub Actions (lint.yml, tests.yml)
- PHPUnit / Pest tests (tests/Feature, tests/ArchTest.php)
- Vite for front-end asset bundling

##### Relationships and interactions
- Browser (Admin/Operator/Guest) → HTTP request → Web server → Laravel Kernel → Route → Middleware → Controller / Filament Resource → Eloquent → Database
- File uploads/downloads handled within Storage facade → file system or S3
- Notifications dispatched via Laravel’s queue → Queue worker → Mail / database notifications
- Auth and RBAC enforced by Policies and app/Models/Role & Permission

##### Architectural patterns & principles
- Layered architecture: Presentation (Blade, Filament UI), Application (Controllers, Filament Resources), Domain (Models, ValueObjects, Enums), Infrastructure (DB, Storage, Mail, Queue).
- MVC at core, extended by Filament for CRU(D) admin panels.
- Role-based access control via Policies, Permissions, Middleware.
- Dependency injection via Service Providers (app/Providers).
- Single codebase multi-panel design by namespacing Filament resources.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Clients Layer
    subgraph "Clients" 
        direction TB
        AdminUI["Admin UI\n(Filament AdminPanel)"]:::client
        OperatorUI["Operator UI\n(Filament OperatorPanel)"]:::client
        GuestUI["Guest UI\n(Filament GuestPanel + Public Pages)"]:::client
    end

    %% Web Tier Layer
    subgraph "Web Tier" 
        direction TB
        HTTPServer["HTTP Server\n(Nginx/Apache + PHP-FPM)"]:::web
        LaravelKernel["Laravel Kernel\n(bootstrap/app.php)"]:::web
        Routing["Routing\n(routes/web.php)"]:::web
        Middleware["Middleware\n(PanelCommonConfig & Auth)"]:::web
        Controllers["Controllers\n(app/Http/Controllers)"]:::web
        Requests["Form Requests\n(app/Http/Requests)"]:::web
    end

    %% Application Logic Layer
    subgraph "Application / Business Logic" 
        direction TB
        FilamentResources["Filament Resource Classes\n(app/Filament/**/Resources)"]:::app
        Notifications["Notifications\n(app/Notifications)"]:::app
        Policies["Policies\n(app/Policies)"]:::app
        Casts["Casts\n(app/Casts)"]:::app
        Enums["Enums\n(app/Enums)"]:::app
        ValueObjects["ValueObjects\n(app/ValueObjects)"]:::app
        Models["Eloquent Models\n(app/Models)"]:::app
    end

    %% Data & Infrastructure Layer
    subgraph "Data / Infrastructure" 
        direction TB
        Database["Relational Database\n(MySQL/PostgreSQL)"]:::data
        Migrations["Migrations\n(database/migrations)"]:::data
        Factories["Factories\n(database/factories)"]:::data
        CacheStore["Cache\n(file/Redis)"]:::data
        FileStorage["File Storage\n(local / S3)"]:::data
        QueueSystem["Queue System\n(Redis/database)"]:::data
        MailService["Mail/Notification Service\n(SMTP/Mailgun)"]:::external
    end

    %% CI & Assets Layer
    subgraph "CI & Assets" 
        direction TB
        CIWorkflows["GitHub Actions\n(.github/workflows)"]:::infra
        Tests["Automated Tests\n(tests/Feature & tests/ArchTest.php)"]:::infra
        AssetBundling["Asset Bundling\n(vite.config.js, resources/js, resources/css)"]:::infra
    end

    %% Connections: Clients to Web Tier
    AdminUI -->|HTTP Request| HTTPServer
    OperatorUI -->|HTTP Request| HTTPServer
    GuestUI -->|HTTP Request| HTTPServer

    %% Web Tier flow
    HTTPServer -->|bootstrap| LaravelKernel
    LaravelKernel -->|route| Routing
    Routing -->|run| Middleware
    Middleware -->|calls| Controllers
    Controllers -->|validates| Requests
    Controllers -->|delegates| FilamentResources

    %% Application Logic interactions
    FilamentResources -->|uses| Models
    FilamentResources -->|checks| Policies
    FilamentResources -->|sends| Notifications
    Models -->|casts| Casts
    Models -->|uses| Enums
    Models -->|wraps| ValueObjects

    %% Data & Infra interactions
    Models -->|read/write| Database
    Database -->|defined by| Migrations
    Database -->|seeded by| Factories
    CacheStore -->|caching| Models
    FileStorage -->|uploads/downloads| Models
    Notifications -->|queued via| QueueSystem
    QueueSystem -->|dispatches| MailService

    %% CI & Assets interactions
    AssetBundling -->|builds assets for| HTTPServer
    Tests -->|validate| Controllers
    CIWorkflows -->|run| Tests

    %% Click Events
    click AdminUI "https://github.com/hasnayeen/booked/tree/main/app/Filament/Admin"
    click OperatorUI "https://github.com/hasnayeen/booked/tree/main/app/Filament/Operator"
    click GuestUI "https://github.com/hasnayeen/booked/tree/main/app/Filament/Guest"
    click HTTPServer "https://github.com/hasnayeen/booked/blob/main/public/index.php"
    click LaravelKernel "https://github.com/hasnayeen/booked/blob/main/bootstrap/app.php"
    click LaravelKernel "https://github.com/hasnayeen/booked/tree/main/app/Providers"
    click Routing "https://github.com/hasnayeen/booked/blob/main/routes/web.php"
    click Middleware "https://github.com/hasnayeen/booked/blob/main/app/Http/Middleware/PanelCommonConfig.php"
    click Controllers "https://github.com/hasnayeen/booked/tree/main/app/Http/Controllers"
    click Requests "https://github.com/hasnayeen/booked/tree/main/app/Http/Requests"
    click FilamentResources "https://github.com/hasnayeen/booked/tree/main/app/Filament/**/Resources"
    click Notifications "https://github.com/hasnayeen/booked/tree/main/app/Notifications"
    click Policies "https://github.com/hasnayeen/booked/tree/main/app/Policies"
    click Casts "https://github.com/hasnayeen/booked/tree/main/app/Casts"
    click Enums "https://github.com/hasnayeen/booked/tree/main/app/Enums"
    click ValueObjects "https://github.com/hasnayeen/booked/tree/main/app/ValueObjects"
    click Models "https://github.com/hasnayeen/booked/tree/main/app/Models"
    click Migrations "https://github.com/hasnayeen/booked/tree/main/database/migrations"
    click Factories "https://github.com/hasnayeen/booked/tree/main/database/factories"
    click FileStorage "https://github.com/hasnayeen/booked/blob/main/config/filesystems.php"
    click FileStorage "https://github.com/hasnayeen/booked/tree/main/storage/app/public/logo"
    click QueueSystem "https://github.com/hasnayeen/booked/blob/main/config/queue.php"
    click MailService "https://github.com/hasnayeen/booked/blob/main/config/mail.php"
    click CacheStore "https://github.com/hasnayeen/booked/blob/main/config/cache.php"
    click CIWorkflows "https://github.com/hasnayeen/booked/blob/main/.github/workflows/lint.yml"
    click CIWorkflows "https://github.com/hasnayeen/booked/blob/main/.github/workflows/tests.yml"
    click Tests "https://github.com/hasnayeen/booked/tree/main/tests/Feature"
    click Tests "https://github.com/hasnayeen/booked/blob/main/tests/ArchTest.php"
    click AssetBundling "https://github.com/hasnayeen/booked/blob/main/vite.config.js"
    click AssetBundling "https://github.com/hasnayeen/booked/tree/main/resources/js"
    click AssetBundling "https://github.com/hasnayeen/booked/tree/main/resources/css"

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,color:#004085;
    classDef web fill:#d4edda,stroke:#155724,color:#155724;
    classDef app fill:#fff3cd,stroke:#856404,color:#856404;
    classDef data fill:#f8d7da,stroke:#721c24,color:#721c24;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef infra fill:#fdfdfe,stroke:#b1b1b1,color:#383d41;
```
