# realrashid/sweet-alert architecture

> Architecture diagram of the GitHub repository realrashid/sweet-alert, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/realrashid/sweet-alert
- Repository: https://github.com/realrashid/sweet-alert

## Overview

Laravel SweetAlert turns application requests to show alerts into configured SweetAlert2 dialogs: developers use the facade or helper, build an alert, toast, or input, flash it to session storage, and render it through the Blade directive. Major documented branches include guarded actions, Livewire events, Inertia sharing, and v7 upgrades. The excerpts show builder-to-flasher and service-provider wiring; some integration and browser-side relationships are documented in the README but their implementation was not sampled.

Main entry points: [`src/Builders/AbstractAlertBuilder.php`](https://github.com/realrashid/sweet-alert/blob/main/src/Builders/AbstractAlertBuilder.php) (Shared Builder), [`src/Facades/Alert.php`](https://github.com/realrashid/sweet-alert/blob/main/src/Facades/Alert.php) (Alert Facade), [`src/Support/AlertFlasher.php`](https://github.com/realrashid/sweet-alert/blob/main/src/Support/AlertFlasher.php) (Alert Flasher), [`src/Builders/AlertBuilder.php`](https://github.com/realrashid/sweet-alert/blob/main/src/Builders/AlertBuilder.php) (Alert Builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Alert API"]
  node_facade["Alert Facade<br/>[Alert.php]"]
  node_alert_builder["Alert Builder<br/>[AlertBuilder.php]"]
  node_toast_builder["Toast Builder<br/>[ToastBuilder.php]"]
  node_input_builder["Input Builder<br/>[InputBuilder.php]"]
  node_shared_builder["Shared Builder"]
  node_builder_concerns["Builder Concerns"]
  node_type_enums["Alert Enums"]
end

subgraph group_delivery["Alert Delivery"]
  node_config["Alert Configuration<br/>[AlertConfig.php]"]
  node_flasher["Alert Flasher<br/>[AlertFlasher.php]"]
  node_session_store["Session Store"]
  node_blade_view["Alert Blade View<br/>[alert.blade.php]"]
  node_browser_runtime["Browser Runtime<br/>[sweet-alert.js]"]
end

subgraph group_integrations["Framework Integrations"]
  node_livewire_trait["Livewire Trait"]
  node_inertia_middleware["Inertia Middleware"]
  node_guard_middleware["Guarded Action Middleware<br/>[ToSweetAlert.php]"]
  node_provider["Service Provider"]
end

subgraph group_migration["Upgrade Tools"]
  node_upgrader["Code Upgrader<br/>[Upgrader.php]"]
  node_upgrade_change["Upgrade Change<br/>[UpgradeChange.php]"]
  node_upgrade_command["Upgrade Command<br/>[UpgradeCommand.php]"]
end

node_developer(("Application Developer"))
node_session[("Laravel Session")]
node_application(("Laravel Application"))

node_developer -->|"builds alert"| node_facade
node_facade -->|"creates alerts"| node_alert_builder
node_facade -->|"creates toasts"| node_toast_builder
node_facade -->|"creates inputs"| node_input_builder
node_alert_builder -->|"extends"| node_shared_builder
node_toast_builder -->|"extends"| node_shared_builder
node_input_builder -->|"extends"| node_shared_builder
node_shared_builder -->|"uses"| node_builder_concerns
node_shared_builder -->|"flashes config"| node_flasher
node_input_builder -->|"accepts input types"| node_type_enums
node_alert_builder -->|"uses alert types"| node_type_enums
node_flasher -->|"packages config"| node_config
node_flasher -->|"writes alerts"| node_session_store
node_session_store -->|"stores data"| node_session
node_application -->|"renders directive"| node_blade_view
node_application -.->|"runs alerts"| node_browser_runtime
node_application -.->|"dispatches alerts"| node_livewire_trait
node_application -.->|"shares alerts"| node_inertia_middleware
node_application -.->|"guards actions"| node_guard_middleware
node_provider -->|"registers service"| node_flasher
node_provider -->|"binds store"| node_session_store
node_developer -->|"runs upgrade"| node_upgrade_command
node_upgrade_command -->|"rewrites source"| node_upgrader
node_upgrader -->|"collects changes"| node_upgrade_change

click node_facade "https://github.com/realrashid/sweet-alert/blob/main/src/Facades/Alert.php"
click node_alert_builder "https://github.com/realrashid/sweet-alert/blob/main/src/Builders/AlertBuilder.php"
click node_toast_builder "https://github.com/realrashid/sweet-alert/blob/main/src/Builders/ToastBuilder.php"
click node_input_builder "https://github.com/realrashid/sweet-alert/blob/main/src/Builders/InputBuilder.php"
click node_shared_builder "https://github.com/realrashid/sweet-alert/blob/main/src/Builders/AbstractAlertBuilder.php"
click node_builder_concerns "https://github.com/realrashid/sweet-alert/tree/main/src/Concerns"
click node_type_enums "https://github.com/realrashid/sweet-alert/tree/main/src/Enums"
click node_config "https://github.com/realrashid/sweet-alert/blob/main/src/Support/AlertConfig.php"
click node_flasher "https://github.com/realrashid/sweet-alert/blob/main/src/Support/AlertFlasher.php"
click node_session_store "https://github.com/realrashid/sweet-alert/blob/main/src/Storage/AlertSessionStore.php"
click node_blade_view "https://github.com/realrashid/sweet-alert/blob/main/resources/views/alert.blade.php"
click node_browser_runtime "https://github.com/realrashid/sweet-alert/blob/main/resources/js/sweet-alert.js"
click node_livewire_trait "https://github.com/realrashid/sweet-alert/blob/main/src/Concerns/SweetAlertTrait.php"
click node_inertia_middleware "https://github.com/realrashid/sweet-alert/blob/main/src/Http/Middleware/ShareSweetAlertWithInertia.php"
click node_guard_middleware "https://github.com/realrashid/sweet-alert/blob/main/src/Http/Middleware/ToSweetAlert.php"
click node_provider "https://github.com/realrashid/sweet-alert/blob/main/src/SweetAlertServiceProvider.php"
click node_upgrader "https://github.com/realrashid/sweet-alert/blob/main/src/Support/Upgrader.php"
click node_upgrade_change "https://github.com/realrashid/sweet-alert/blob/main/src/Support/UpgradeChange.php"
click node_upgrade_command "https://github.com/realrashid/sweet-alert/blob/main/src/Commands/UpgradeCommand.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_facade,node_alert_builder,node_toast_builder,node_input_builder,node_shared_builder,node_builder_concerns,node_type_enums toneBlue
class node_config,node_flasher,node_session_store,node_blade_view,node_browser_runtime,node_session toneAmber
class node_livewire_trait,node_inertia_middleware,node_guard_middleware,node_provider toneMint
class node_upgrader,node_upgrade_change,node_upgrade_command toneRose
class node_developer,node_application toneIndigo
```

## Components

### Alert API

- [Alert Facade](https://github.com/realrashid/sweet-alert/blob/main/src/Facades/Alert.php): `src/Facades/Alert.php`
- [Alert Builder](https://github.com/realrashid/sweet-alert/blob/main/src/Builders/AlertBuilder.php): `src/Builders/AlertBuilder.php`
- [Toast Builder](https://github.com/realrashid/sweet-alert/blob/main/src/Builders/ToastBuilder.php): `src/Builders/ToastBuilder.php`
- [Input Builder](https://github.com/realrashid/sweet-alert/blob/main/src/Builders/InputBuilder.php): `src/Builders/InputBuilder.php`
- [Shared Builder](https://github.com/realrashid/sweet-alert/blob/main/src/Builders/AbstractAlertBuilder.php): `src/Builders/AbstractAlertBuilder.php`
- [Builder Concerns](https://github.com/realrashid/sweet-alert/tree/main/src/Concerns): `src/Concerns`
- [Alert Enums](https://github.com/realrashid/sweet-alert/tree/main/src/Enums): `src/Enums`

### Alert Delivery

- [Alert Configuration](https://github.com/realrashid/sweet-alert/blob/main/src/Support/AlertConfig.php): `src/Support/AlertConfig.php`
- [Alert Flasher](https://github.com/realrashid/sweet-alert/blob/main/src/Support/AlertFlasher.php): `src/Support/AlertFlasher.php`
- [Session Store](https://github.com/realrashid/sweet-alert/blob/main/src/Storage/AlertSessionStore.php): `src/Storage/AlertSessionStore.php`
- [Alert Blade View](https://github.com/realrashid/sweet-alert/blob/main/resources/views/alert.blade.php): `resources/views/alert.blade.php`
- [Browser Runtime](https://github.com/realrashid/sweet-alert/blob/main/resources/js/sweet-alert.js): `resources/js/sweet-alert.js`

### Framework Integrations

- [Livewire Trait](https://github.com/realrashid/sweet-alert/blob/main/src/Concerns/SweetAlertTrait.php): `src/Concerns/SweetAlertTrait.php`
- [Inertia Middleware](https://github.com/realrashid/sweet-alert/blob/main/src/Http/Middleware/ShareSweetAlertWithInertia.php): `src/Http/Middleware/ShareSweetAlertWithInertia.php`
- [Guarded Action Middleware](https://github.com/realrashid/sweet-alert/blob/main/src/Http/Middleware/ToSweetAlert.php): `src/Http/Middleware/ToSweetAlert.php`
- [Service Provider](https://github.com/realrashid/sweet-alert/blob/main/src/SweetAlertServiceProvider.php): `src/SweetAlertServiceProvider.php`

### Upgrade Tools

- [Code Upgrader](https://github.com/realrashid/sweet-alert/blob/main/src/Support/Upgrader.php): `src/Support/Upgrader.php`
- [Upgrade Change](https://github.com/realrashid/sweet-alert/blob/main/src/Support/UpgradeChange.php): `src/Support/UpgradeChange.php`
- [Upgrade Command](https://github.com/realrashid/sweet-alert/blob/main/src/Commands/UpgradeCommand.php): `src/Commands/UpgradeCommand.php`

### Other components

- **Application Developer**
- **Laravel Session**
- **Laravel Application**

## Connections

- Application Developer → Alert Facade: builds alert (evidence: `README.md`)
- Alert Facade → Alert Builder: creates alerts (evidence: `src/Facades/Alert.php`)
- Alert Facade → Toast Builder: creates toasts (evidence: `src/Facades/Alert.php`)
- Alert Facade → Input Builder: creates inputs (evidence: `src/Facades/Alert.php`)
- Alert Builder → Shared Builder: extends (evidence: `src/Builders/AlertBuilder.php`)
- Toast Builder → Shared Builder: extends (evidence: `src/Builders/ToastBuilder.php`)
- Input Builder → Shared Builder: extends (evidence: `src/Builders/InputBuilder.php`)
- Shared Builder → Builder Concerns: uses (evidence: `src/Builders/AbstractAlertBuilder.php`)
- Shared Builder → Alert Flasher: flashes config (evidence: `src/Builders/AbstractAlertBuilder.php`)
- Input Builder → Alert Enums: accepts input types (evidence: `src/Builders/InputBuilder.php`)
- Alert Builder → Alert Enums: uses alert types (evidence: `src/Builders/AlertBuilder.php`)
- Alert Flasher → Alert Configuration: packages config (evidence: `src/Support/AlertFlasher.php`)
- Alert Flasher → Session Store: writes alerts (evidence: `src/Support/AlertFlasher.php`)
- Session Store → Laravel Session: stores data (evidence: `src/Storage/AlertSessionStore.php`)
- Laravel Application → Alert Blade View: renders directive
- Laravel Application → Browser Runtime: runs alerts
- Laravel Application → Livewire Trait: dispatches alerts (evidence: `README.md`)
- Laravel Application → Inertia Middleware: shares alerts (evidence: `README.md`)
- Laravel Application → Guarded Action Middleware: guards actions (evidence: `README.md`)
- Service Provider → Alert Flasher: registers service (evidence: `src/SweetAlertServiceProvider.php`)
- Service Provider → Session Store: binds store (evidence: `src/SweetAlertServiceProvider.php`)
- Application Developer → Upgrade Command: runs upgrade (evidence: `README.md`)
- Upgrade Command → Code Upgrader: rewrites source (evidence: `src/Commands/UpgradeCommand.php`)
- Code Upgrader → Upgrade Change: collects changes (evidence: `src/Support/Upgrader.php`)
