# chroscielski/azure-functions-durable-js architecture

> Architecture diagram of the GitHub repository chroscielski/azure-functions-durable-js, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chroscielski/azure-functions-durable-js
- Repository: https://github.com/chroscielski/azure-functions-durable-js

## Overview

##### Main Components

a) Core Infrastructure Layer:
- Azure Functions Runtime Environment
- Azure Storage (for state management)
- Storage Queues (function invocation)
- Storage Tables (checkpointing)

b) Durable Functions Components:
- Client Functions (entry points)
- Orchestrator Functions (workflow controllers)
- Activity Functions (task executors)
- Entity Functions (state management)

c) Internal Framework Components (from src/):
- Task Management System
- Task Factory
- Task Set Handler
- Timer Tasks
- Action Management System
- Activity Actions
- Entity Actions
- HTTP Actions
- Timer Actions
- History Management
- Event Processing
- State Management
- Entity Framework
- Entity State Management
- Lock Management

##### Relationship Flows to Illustrate

a) Primary Execution Flow:
**Client Function → Orchestrator Function → Activity Functions**

b) State Management Flow:
**Orchestrator → Event Sourcing → Storage Tables ↔ State Reconstruction**

c) Entity Interactions:
**Functions ↔ Entity Operations ↔ Entity State**

##### Technical Details

- Node.js runtime environment (v8.6.0+)
- Azure Functions Core Tools integration
- Microsoft.Azure.WebJobs.Extensions.DurableTask dependency
- Storage account requirements
- Key NPM package dependencies

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Azure["Azure Functions Runtime Environment"]
        subgraph Functions["Function Types"]
            CF[Client Functions]:::client
            OF[Orchestrator Functions]:::orchestrator
            AF[Activity Functions]:::activity
            EF[Entity Functions]:::entity
        end

        subgraph TaskMgmt["Task Management System"]
            TF["Task Factory"]:::task
            TSH["Task Set Handler"]:::task
            TT["Timer Tasks"]:::task
        end

        subgraph ActionMgmt["Action Management System"]
            AA["Activity Actions"]:::action
            EA["Entity Actions"]:::action
            HA["HTTP Actions"]:::action
            TA["Timer Actions"]:::action
        end

        subgraph HistoryMgmt["History Management"]
            EP["Event Processing"]:::history
            SM["State Management"]:::history
        end

        subgraph EntityFW["Entity Framework"]
            ESM["Entity State Management"]:::entity
            LM["Lock Management"]:::entity
        end

        subgraph CoreComp["Core Components"]
            OC["Orchestrator Context"]:::core
            OCL["Orchestrator Client"]:::core
            EC["Entity Context"]:::core
        end

        subgraph Storage["Azure Storage"]
            SQ[(Storage Queues)]:::storage
            ST[(Storage Tables)]:::storage
        end

        subgraph ErrorHandling["Error Handling"]
            RL["Retry Logic"]:::error
            EM["Error Management"]:::error
            AE["Aggregate Errors"]:::error
        end
    end

    %% Relationships
    CF --> OF
    OF --> AF
    OF --> EF
    OF --> HistoryMgmt
    OF --> TaskMgmt
    AF --> ActionMgmt
    EF --> EntityFW
    TaskMgmt --> Storage
    HistoryMgmt --> Storage
    EntityFW --> Storage
    ErrorHandling --> OF

    %% Click Events
    click TF "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/tasks/taskfactory.ts"
    click TSH "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/tasks/taskset.ts"
    click TT "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/tasks/timertask.ts"
    click AA "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/actions/callactivityaction.ts"
    click EA "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/actions/callentityaction.ts"
    click HA "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/actions/callhttpaction.ts"
    click TA "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/actions/createtimeraction.ts"
    click EP "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/history/historyevent.ts"
    click SM "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/history/historyeventtype.ts"
    click ESM "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/entities/entitystate.ts"
    click LM "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/entities/durablelock.ts"
    click OC "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/durableorchestrationcontext.ts"
    click OCL "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/durableorchestrationclient.ts"
    click EC "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/durableentitycontext.ts"
    click RL "https://github.com/Chroscielski/azure-functions-durable-js/tree/dev/samples/CallActivityWithRetry/"
    click EM "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/durableerror.ts"
    click AE "https://github.com/Chroscielski/azure-functions-durable-js/blob/dev/src/aggregatederror.ts"

    %% Styles
    classDef client fill:#90EE90
    classDef orchestrator fill:#98FB98
    classDef activity fill:#98FB98
    classDef entity fill:#DDA0DD
    classDef task fill:#FFA500
    classDef action fill:#FF8C00
    classDef history fill:#9370DB
    classDef storage fill:#A9A9A9
    classDef core fill:#4682B4
    classDef error fill:#FF6347

    %% Legend
    subgraph Legend
        L1[Client Functions]:::client
        L2[Orchestrator/Activity]:::orchestrator
        L3[Entity Components]:::entity
        L4[Task Management]:::task
        L5[Action Management]:::action
        L6[History Management]:::history
        L7[Storage]:::storage
        L8[Core Components]:::core
        L9[Error Handling]:::error
    end
```
