# durable-workflow/workflow architecture

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

- Interactive diagram: https://gitdiagram.com/durable-workflow/workflow
- Repository: https://github.com/durable-workflow/workflow

## Overview

Durable Workflow is a Laravel-embedded engine for authoring and running durable PHP workflows. The main path is application code starting a workflow, runtime coordination through activities, timers and other commands, task delivery by Laravel queues, and durable history that supports replay after failures. The package also exposes scheduling, webhook interactions, payload codecs/storage, and operator visibility/repair surfaces. The graph uses README statements and shown source-index references; unsampled runtime links are omitted rather than inferred.

Main entry points: [`src/V2`](https://github.com/durable-workflow/workflow/tree/main/src/V2) (Workflow runtime), [`src/Queue/DatabaseTaskDelivery.php`](https://github.com/durable-workflow/workflow/blob/main/src/Queue/DatabaseTaskDelivery.php) (Task delivery), [`src/V2/Models/WorkflowRun.php`](https://github.com/durable-workflow/workflow/blob/main/src/V2/Models/WorkflowRun.php) (Run state), [`src/V2/Models/WorkflowTask.php`](https://github.com/durable-workflow/workflow/blob/main/src/V2/Models/WorkflowTask.php) (Task state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Workflow authoring"]
  node_workflow_code["Workflow code<br/>[AsyncWorkflow.php]"]
  node_activity_code["Activity handlers<br/>[Activity.php]"]
end

subgraph group_execution["Runtime execution"]
  node_runtime["Workflow runtime"]
  node_activity_runtime["Activity execution"]
  node_task_jobs["Workflow task jobs"]
  node_schedule["Workflow schedules"]
end

subgraph group_durability["Durable state"]
  node_history[("Execution history")]
  node_run_state[("Run state<br/>[WorkflowRun.php]")]
  node_task_state[("Task state<br/>[WorkflowTask.php]")]
  node_codecs["Payload codecs<br/>[Avro.php]"]
  node_payload_storage["External payload storage"]
end

subgraph group_integration["Laravel integrations"]
  node_task_delivery["Task delivery"]
  node_webhooks["Webhook interface<br/>[Webhooks.php]"]
  node_auth["Webhook authentication"]
end

subgraph group_operations["Operations"]
  node_operator["Monitoring and repair"]
  node_commands["Operator commands"]
end

node_application(("Application developer"))
node_queue_worker["Laravel queue worker"]
node_laravel["Laravel services"]
node_database[("Application database")]

node_application -->|"authors"| node_workflow_code
node_workflow_code -->|"starts"| node_runtime
node_runtime -->|"coordinates"| node_activity_runtime
node_activity_runtime -->|"runs"| node_activity_code
node_runtime -->|"records tasks"| node_task_state
node_task_delivery -->|"inspects"| node_task_state
node_task_delivery -->|"dispatches"| node_task_jobs
node_queue_worker -->|"executes"| node_task_jobs
node_runtime -->|"persists history"| node_history
node_history -->|"records run events"| node_run_state
node_run_state -->|"stores runs"| node_database
node_task_state -->|"stores tasks"| node_database
node_application -->|"configures"| node_schedule
node_schedule -->|"starts occurrences"| node_runtime
node_application -.->|"uses endpoints"| node_webhooks
node_webhooks -->|"validates requests"| node_auth
node_runtime -->|"encodes payloads"| node_codecs
node_runtime -.->|"stores payloads"| node_payload_storage
node_operator -->|"inspects models"| node_run_state
node_commands -.->|"reports status"| node_operator
node_laravel -->|"provides queues"| node_task_delivery
node_laravel -->|"provides storage"| node_database

click node_workflow_code "https://github.com/durable-workflow/workflow/blob/main/src/V2/AsyncWorkflow.php"
click node_activity_code "https://github.com/durable-workflow/workflow/blob/main/src/V2/Activity.php"
click node_runtime "https://github.com/durable-workflow/workflow/tree/main/src/V2"
click node_activity_runtime "https://github.com/durable-workflow/workflow/blob/main/src/V2/ActivityTaskBridge.php"
click node_task_delivery "https://github.com/durable-workflow/workflow/blob/main/src/Queue/DatabaseTaskDelivery.php"
click node_task_jobs "https://github.com/durable-workflow/workflow/blob/main/src/V2/Jobs/RunWorkflowTask.php"
click node_history "https://github.com/durable-workflow/workflow/blob/main/src/V2/Models/WorkflowHistoryEvent.php"
click node_run_state "https://github.com/durable-workflow/workflow/blob/main/src/V2/Models/WorkflowRun.php"
click node_task_state "https://github.com/durable-workflow/workflow/blob/main/src/V2/Models/WorkflowTask.php"
click node_schedule "https://github.com/durable-workflow/workflow/blob/main/src/V2/Support/ScheduleManager.php"
click node_webhooks "https://github.com/durable-workflow/workflow/blob/main/src/V2/Webhooks.php"
click node_auth "https://github.com/durable-workflow/workflow/blob/main/src/Auth/WebhookAuthenticator.php"
click node_codecs "https://github.com/durable-workflow/workflow/blob/main/src/Serializers/Avro.php"
click node_payload_storage "https://github.com/durable-workflow/workflow/blob/main/src/V2/Contracts/ExternalPayloadStorageDriver.php"
click node_operator "https://github.com/durable-workflow/workflow/blob/main/src/V2/Support/WaterlineEngineSource.php"
click node_commands "https://github.com/durable-workflow/workflow/blob/main/src/Commands/V2DoctorCommand.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_workflow_code,node_activity_code toneBlue
class node_runtime,node_activity_runtime,node_task_jobs,node_schedule,node_database toneAmber
class node_history,node_run_state,node_task_state,node_codecs,node_payload_storage toneMint
class node_task_delivery,node_webhooks,node_auth,node_queue_worker toneRose
class node_operator,node_commands,node_application,node_laravel toneIndigo
```

## Components

### Workflow authoring

- [Workflow code](https://github.com/durable-workflow/workflow/blob/main/src/V2/AsyncWorkflow.php): `src/V2/AsyncWorkflow.php`
- [Activity handlers](https://github.com/durable-workflow/workflow/blob/main/src/V2/Activity.php): `src/V2/Activity.php`

### Runtime execution

- [Workflow runtime](https://github.com/durable-workflow/workflow/tree/main/src/V2): `src/V2`
- [Activity execution](https://github.com/durable-workflow/workflow/blob/main/src/V2/ActivityTaskBridge.php): `src/V2/ActivityTaskBridge.php`
- [Workflow task jobs](https://github.com/durable-workflow/workflow/blob/main/src/V2/Jobs/RunWorkflowTask.php): `src/V2/Jobs/RunWorkflowTask.php`
- [Workflow schedules](https://github.com/durable-workflow/workflow/blob/main/src/V2/Support/ScheduleManager.php): `src/V2/Support/ScheduleManager.php`

### Durable state

- [Execution history](https://github.com/durable-workflow/workflow/blob/main/src/V2/Models/WorkflowHistoryEvent.php): `src/V2/Models/WorkflowHistoryEvent.php`
- [Run state](https://github.com/durable-workflow/workflow/blob/main/src/V2/Models/WorkflowRun.php): `src/V2/Models/WorkflowRun.php`
- [Task state](https://github.com/durable-workflow/workflow/blob/main/src/V2/Models/WorkflowTask.php): `src/V2/Models/WorkflowTask.php`
- [Payload codecs](https://github.com/durable-workflow/workflow/blob/main/src/Serializers/Avro.php): `src/Serializers/Avro.php`
- [External payload storage](https://github.com/durable-workflow/workflow/blob/main/src/V2/Contracts/ExternalPayloadStorageDriver.php): `src/V2/Contracts/ExternalPayloadStorageDriver.php`

### Laravel integrations

- [Task delivery](https://github.com/durable-workflow/workflow/blob/main/src/Queue/DatabaseTaskDelivery.php): `src/Queue/DatabaseTaskDelivery.php`
- [Webhook interface](https://github.com/durable-workflow/workflow/blob/main/src/V2/Webhooks.php): `src/V2/Webhooks.php`
- [Webhook authentication](https://github.com/durable-workflow/workflow/blob/main/src/Auth/WebhookAuthenticator.php): `src/Auth/WebhookAuthenticator.php`

### Operations

- [Monitoring and repair](https://github.com/durable-workflow/workflow/blob/main/src/V2/Support/WaterlineEngineSource.php): `src/V2/Support/WaterlineEngineSource.php`
- [Operator commands](https://github.com/durable-workflow/workflow/blob/main/src/Commands/V2DoctorCommand.php): `src/Commands/V2DoctorCommand.php`

### Other components

- **Application developer**
- **Laravel queue worker**
- **Laravel services**
- **Application database**

## Connections

- Application developer → Workflow code: authors (evidence: `README.md`)
- Workflow code → Workflow runtime: starts (evidence: `README.md`)
- Workflow runtime → Activity execution: coordinates (evidence: `README.md`)
- Activity execution → Activity handlers: runs (evidence: `README.md`)
- Workflow runtime → Task state: records tasks (evidence: `README.md`)
- Task delivery → Task state: inspects (evidence: `src/Queue/DatabaseTaskDelivery.php`)
- Task delivery → Workflow task jobs: dispatches (evidence: `src/Queue/DatabaseTaskDelivery.php`)
- Laravel queue worker → Workflow task jobs: executes (evidence: `README.md`)
- Workflow runtime → Execution history: persists history (evidence: `README.md`)
- Execution history → Run state: records run events (evidence: `src/V2/Models/WorkflowHistoryEvent.php`)
- Run state → Application database: stores runs (evidence: `README.md`)
- Task state → Application database: stores tasks (evidence: `README.md`)
- Application developer → Workflow schedules: configures (evidence: `README.md`)
- Workflow schedules → Workflow runtime: starts occurrences (evidence: `README.md`)
- Application developer → Webhook interface: uses endpoints (evidence: `src/V2/Webhooks.php`)
- Webhook interface → Webhook authentication: validates requests (evidence: `src/V2/Webhooks.php`)
- Workflow runtime → Payload codecs: encodes payloads (evidence: `src/V2/Models/WorkflowRun.php`)
- Workflow runtime → External payload storage: stores payloads (evidence: `src/V2/Contracts/ExternalPayloadStorageDriver.php`)
- Monitoring and repair → Run state: inspects models (evidence: `src/V2/Support/WaterlineEngineSource.php`)
- Operator commands → Monitoring and repair: reports status
- Laravel services → Task delivery: provides queues (evidence: `README.md`)
- Laravel services → Application database: provides storage (evidence: `README.md`)
