# jorgenortes/laravel-splade architecture

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

- Interactive diagram: https://gitdiagram.com/jorgenortes/laravel-splade
- Repository: https://github.com/jorgenortes/laravel-splade

## Overview

##### Overall Project Scope and Purpose
- That this is not a full-blown full-stack separate frontend and backend system, but rather a Laravel package (Laravel Splade) that “magically” turns Blade views into an SPA-like experience.
- The README emphasizes features such as seamless server-side routing paired with interactive Vue components, built-in support for modals, form components, lazy loading, event handling (like redirects, toast notifications via Laravel Echo), SSR support, and more.

##### Main Components
a. Laravel Backend (Server-side):
- Controllers: In the “app/app/Http/Controllers” directory are various controllers handling different parts (forms, files, navigation, etc.).
- Models & Eloquent: The “app/app/Models” directory shows core domain models.
- Routing & Middleware: With “app/routes” and middleware configurations in “app/app/Http/Middleware” showing the flow of HTTP requests.
- Service Providers & Configuration: “app/app/Providers”, “config/”, and “app/bootstrap” indicate Laravel’s dependency injection and configuration bootstrapping.
- Artisan Commands: Both under “src/Commands” and the “artisan” file, which handle installation, testing, and maintenance tasks.
- Database Layer: Migrations, seeders, and factories (within “app/database”) reflect how data is structured and stored.

b. Frontend Presentation Layer:
- Blade Templates: The “resources/views” (and corresponding “app/resources/views”) directories present the Blade views that this package leverages.
- Vue 3 Components: The “lib/Components” directory (as well as “app/resources/js”) shows a large set of Vue components (like Modal, Toast, Table, etc.) that are integrated within Blade templates.
- Asset Pipeline: The “package.json”, “vite.config.js”, and “tailwind.config.js” files manage the front-end build tools and CSS frameworks (Tailwind CSS).
- SSR (Server-Side Rendering) Support: Files like “app/resources/js/ssr.js” and “lib/server.js” indicate that there is an SSR mechanism to render Vue components on the server.

c. Integration and Communication:
- Blade Vue Bridge: The design should highlight how the backend-rendered Blade views are enriched with Vue components dynamically. This is accomplished via special Blade components (found both in “app/resources/views/components” and “lib/Components”) that manage state and interactivity.
- Event Handling & Notifications: Representation of events (Redirect, Toast, etc.) flowing from backend processes (possibly triggered by controllers or middleware) to the client, aided by components and Laravel Echo integration.
- Table Rendering & Datagrid: Notice the “app/app/Tables” and “src/Components/Table.php” directories. Include a segment showing how table data flows from Eloquent models via controllers to interactive Tables on the frontend.

##### Relationships & Interactions
- Request → HTTP Kernel (middleware chain)
- Routes → Controllers → Models (data access) → Views (rendered as Blade template)
- How controllers or service providers inject functionality like lazy loading, modals, and file uploads into views.
- Interplay between the server-rendered HTML and the dynamic Vue components that receive updates (with SSR or client-side activation after initial load).
- Integrations with external systems (e.g., broadcasting via Laravel Echo for real-time notifications).

##### Architectural Patterns and Design Principles
- MVC Pattern: Clearly separate the responsibilities of Models, Views, and Controllers.
- Event-Driven Architecture: Represent the event flow (e.g., RedirectEvent, ToastEvent) within the system that allows backend processes to influence frontend behavior.
- Plugin/Component-Based UI: Emphasize the integration of reusable Vue components within the Blade environment.
- Modularization: The separation between the “app” (Laravel application), “src” (core package code), and “lib” (Vue and JS components) should be clearly distinguished.

##### Relevant Technologies, Frameworks, and Libraries
- Laravel (PHP framework) – the backbone of the server-side application.
- Blade Templating Engine – used for server-side view rendering.
- Vue 3 – powering the interactivity on the client side.
- Tailwind CSS – for frontend styling (with default styling available in some components).
- Vite – for the asset bundling and development server.
- Laravel Breeze (if used) – as mentioned in the README for starter kit integration.
- Laravel Echo – for processing real-time events from the backend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    ClientBrowser("Client Browser"):::client

    subgraph "Laravel Backend"
        RoutesMiddleware("Routes & Middleware"):::backend
        Controllers("Controllers"):::backend
        Models("Eloquent Models"):::backend
        Events("Events & Listeners"):::backend
        ServiceProviders("Service Providers & Config"):::backend
        ArtisanCommands("Artisan Commands"):::backend
        DatabaseLayer("Database Layer"):::backend
    end

    subgraph "Frontend Presentation"
        BladeTemplates("Blade Templates"):::frontend
        VueComponents("Vue 3 Components"):::frontend
        SSRSupport("SSR Support"):::frontend
        AssetPipeline("Asset Pipeline"):::frontend
    end

    subgraph "Shared Package / Integration"
        BladeVueBridge("Blade Vue Bridge"):::integration
        EventNotifications("Event Handling & Notifications"):::integration
        FileUploads("File Uploads & Form Handling"):::integration
        TableRendering("Table Rendering & Data Grid"):::integration
    end

    %% Flow of Requests and Data
    ClientBrowser -->|"HTTPRequest"| RoutesMiddleware
    RoutesMiddleware -->|"RoutesTo"| Controllers
    Controllers -->|"DataProcess"| Models
    Controllers -->|"RenderView"| BladeTemplates
    BladeTemplates -->|"EnhancedBy"| BladeVueBridge
    BladeVueBridge -->|"Integrates"| VueComponents
    SSRSupport -->|"Renders"| VueComponents
    Controllers -->|"Triggers"| Events
    Events -->|"Notifies"| EventNotifications
    EventNotifications -->|"UpdatesUI"| VueComponents
    Controllers -->|"Handles"| FileUploads
    Controllers -->|"ProvidesData"| TableRendering
    TableRendering -->|"DisplaysIn"| VueComponents
    ServiceProviders -->|"Configures"| RoutesMiddleware
    Models -->|"DBAccess"| DatabaseLayer
    ClientBrowser -->|"LoadsAssets"| AssetPipeline
    AssetPipeline -->|"Supplies"| VueComponents
    ArtisanCommands -->|"Maintenance"| ServiceProviders

    %% Click Events
    click Controllers "https://github.com/jorgenortes/laravel-splade/tree/main/app/app/Http/Controllers"
    click Models "https://github.com/jorgenortes/laravel-splade/tree/main/app/app/Models"
    click RoutesMiddleware "https://github.com/jorgenortes/laravel-splade/tree/main/app/routes"
    click Events "https://github.com/jorgenortes/laravel-splade/tree/main/app/app/Events"
    click ServiceProviders "https://github.com/jorgenortes/laravel-splade/tree/main/app/app/Providers"
    click ArtisanCommands "https://github.com/jorgenortes/laravel-splade/tree/main/src/Commands"
    click DatabaseLayer "https://github.com/jorgenortes/laravel-splade/tree/main/app/database"
    click BladeTemplates "https://github.com/jorgenortes/laravel-splade/tree/main/app/resources/views"
    click VueComponents "https://github.com/jorgenortes/laravel-splade/tree/main/lib/Components"
    click AssetPipeline "https://github.com/jorgenortes/laravel-splade/blob/main/package.json"
    click SSRSupport "https://github.com/jorgenortes/laravel-splade/blob/main/app/resources/js/ssr.js"
    click BladeVueBridge "https://github.com/jorgenortes/laravel-splade/tree/main/app/resources/views/components"
    click EventNotifications "https://github.com/jorgenortes/laravel-splade/blob/main/lib/Components/Toast.vue"
    click FileUploads "https://github.com/jorgenortes/laravel-splade/tree/main/src/FileUploads"
    click TableRendering "https://github.com/jorgenortes/laravel-splade/tree/main/app/app/Tables"

    %% Styles
    classDef backend fill:#D1E8E2,stroke:#333,stroke-width:2px;
    classDef frontend fill:#C3D3FF,stroke:#333,stroke-width:2px;
    classDef integration fill:#FFD8B1,stroke:#333,stroke-width:2px;
    classDef client fill:#FFCCCC,stroke:#333,stroke-width:2px;
```
