# spatie/laravel-queueable-action architecture

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

- Interactive diagram: https://gitdiagram.com/spatie/laravel-queueable-action
- Repository: https://github.com/spatie/laravel-queueable-action

## Overview

##### Main Components

a) Core Components:
- QueueableAction Trait
- ActionJob Class
- Action Classes (User-defined)
- Laravel Queue System
- Service Provider

b) Supporting Components:
- Testing Framework
- Command System
- Configuration System

**1. Entry Points Layer**
- Controller/Application Code
- Artisan Commands (ActionMakeCommand)

**2. Action Layer**
- QueueableAction Trait
- User Action Classes
- Action Configuration

**3. Queue Processing Layer**
- ActionJob
- Laravel Queue System
- Job Middleware
- Backoff Handling

**4. Testing Layer**
- QueueableActionFake
- Testing Assertions

##### Key Relationships

- How an action gets queued (Application → Action → Queue)
- How the queue processes the action (Queue → ActionJob → Action Execution)
- How dependency injection works with actions
- How the testing framework integrates

##### Specific Implementation Details

- QueueableAction trait with its main methods (onQueue, execute)
- ActionJob class showing its relationship with Laravel's queue system
- Configuration options (queue names, job class customization)
- Testing utilities and assertions

##### Flow Patterns

Key flows:
**Synchronous: Action → execute() → Result**
**Asynchronous: Action → onQueue() → ActionJob → Queue → Process → Result**
**Testing: Action → QueueableActionFake → Assertions**

##### Additional Elements

Notes/callouts for:
- Constructor injection capabilities
- Available configuration options
- Testing assertion methods
- Middleware integration points

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Entry
        AC[Application Code]
        CMD[Action Generator Command]
        click CMD "https://github.com/spatie/laravel-queueable-action/blob/main/src/ActionMakeCommand.php"
    end

    subgraph "Action Layer"
        QAT[QueueableAction Trait]
        UAC[User Action Classes]
        CONF[Configuration]
        STUBS[Action Stubs]
        
        click QAT "https://github.com/spatie/laravel-queueable-action/blob/main/src/QueueableAction.php"
        click CONF "https://github.com/spatie/laravel-queueable-action/blob/main/config/queuableaction.php"
        click STUBS "https://github.com/spatie/laravel-queueable-action/tree/main/src/stubs/"
    end

    subgraph "Queue Processing"
        AJ[ActionJob]
        LQ[Laravel Queue System]
        MID[Job Middleware]
        BH[Backoff Handler]
        
        click AJ "https://github.com/spatie/laravel-queueable-action/blob/main/src/ActionJob.php"
    end

    subgraph "Testing Framework"
        QAF[QueueableActionFake]
        TA[Testing Assertions]
        
        click QAF "https://github.com/spatie/laravel-queueable-action/blob/main/src/Testing/QueueableActionFake.php"
    end

    subgraph "Example Components"
        SA[Simple Action]
        CA[Complex Action]
        FA[Failing Action]
        MA[Middleware Action]
        BA[Backoff Action]
        
        click SA "https://github.com/spatie/laravel-queueable-action/blob/main/tests/TestClasses/SimpleAction.php"
        click CA "https://github.com/spatie/laravel-queueable-action/blob/main/tests/TestClasses/ComplexAction.php"
        click FA "https://github.com/spatie/laravel-queueable-action/blob/main/tests/TestClasses/FailingAction.php"
        click MA "https://github.com/spatie/laravel-queueable-action/blob/main/tests/TestClasses/MiddlewareAction.php"
        click BA "https://github.com/spatie/laravel-queueable-action/blob/main/tests/TestClasses/BackoffAction.php"
    end

    %% Service Provider
    SP[Service Provider]
    click SP "https://github.com/spatie/laravel-queueable-action/blob/main/src/QueueableActionServiceProvider.php"

    %% Exception Handling
    EH[Exception Handler]
    click EH "https://github.com/spatie/laravel-queueable-action/blob/main/src/Exceptions/InvalidConfiguration.php"

    %% Relationships
    AC --> QAT
    CMD --> STUBS
    STUBS --> UAC
    QAT --> AJ
    AJ --> LQ
    LQ --> MID
    MID --> BH
    UAC --> QAT
    CONF --> QAT
    SP --> CONF
    QAF --> TA

    %% Testing Relationships
    UAC --> QAF
    SA --> QAT
    CA --> QAT
    FA --> QAT
    MA --> MID
    BA --> BH

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef framework fill:#4CAF50,stroke:#2E7D32,color:white
    classDef user fill:#FF9800,stroke:#EF6C00,color:white
    classDef testing fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef support fill:#9E9E9E,stroke:#424242,color:white

    class QAT,AJ,SP core
    class LQ,MID,BH framework
    class UAC,SA,CA,FA,MA,BA user
    class QAF,TA testing
    class CONF,STUBS,EH,CMD support
```
