# bpmn-io/variable-resolver architecture

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

- Interactive diagram: https://gitdiagram.com/bpmn-io/variable-resolver
- Repository: https://github.com/bpmn-io/variable-resolver

## Overview

##### Main Components

a. Core Components:
- VariableProvider (Base Class)
- VariableResolver Service
- Platform-specific Resolvers:
- ZeebeVariableResolver
- CamundaVariableResolver

b. Integration Layer:
- BPMN-JS Integration Point
- Moddle Extensions Interface

c. Utility Components:
- Variable Extractors
- Scope Management
- Caching System

- ┌─────────────────────────────────────────┐
- Client Application            │
- ┘
- ↓
- ┌─────────────────────────────────────────┐
- BPMN-JS Core               │
- ┘
- ↓
- ┌─────────────────────────────────────────┐
- Variable Resolver Module         │
- ┌───────────────┐    ┌──────────────┐  │
- VariableProvider│←───│VariableResolver│ │
- ┘    └──────────────┘  │
- ↓                  ↓           │
- ┌───────────────┐    ┌──────────────┐  │
- Zeebe Resolver │    │Camunda Resolver│ │
- ┘    └──────────────┘  │
- ┘
- ↓
- ┌─────────────────────────────────────────┐
- ┘

##### Important Relationships

a. Extension Points:
- How custom VariableProviders can be plugged in
- Extension mechanism for both Zeebe and Camunda platforms

b. Data Flow:
- Variable resolution flow from BPMN elements to consumer
- Caching mechanisms
- Scope inheritance patterns

- ┌─────────────────┐
- Raw Variables   │→→→│ Merge Logic │→→→│ Resolved Variables │
- ┘   └────────────┘   └──────────────────┘

- ┌─────────────┐
- Process   │
- Scope     │
- ┬───────┘
- ↓
- ┌─────────────┐
- Element   │
- Scope     │
- ┘

##### Implementation Details to Highlight
- Variable extraction mechanisms
- Async operation support
- Integration with BPMN-JS modeler
- Platform-specific adapters

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Application"]
        BPMNJS["BPMN-JS Core"]
    end

    subgraph VRM["Variable Resolver Module"]
        VP["VariableProvider"]:::core
        VR["VariableResolver"]:::core
        
        subgraph Platform["Platform-specific Resolvers"]
            ZR["Zeebe Resolver"]:::platform
            CR["Camunda Resolver"]:::platform
        end
        
        subgraph Utils["Utility Components"]
            VE["Variable Extractors"]:::util
            SM["Scope Management"]:::util
            CS["Caching System"]:::util
            EE["Extension Elements"]:::util
            FEEL["FEEL Utility"]:::util
            VC["Variable Context"]:::util
        end
    end

    subgraph Data["BPMN Diagram Data"]
        BD["Process & Element Data"]
    end

    %% Relationships
    BPMNJS --> VP
    VP --> VR
    VR --> ZR
    VR --> CR
    
    ZR --> VE
    ZR --> FEEL
    ZR --> VC
    
    VR --> Utils
    Platform --> Utils
    
    ZR --> BD
    CR --> BD

    %% Click Events
    click VP "https://github.com/bpmn-io/variable-resolver/blob/main/lib/VariableProvider.js"
    click VR "https://github.com/bpmn-io/variable-resolver/blob/main/lib/base/VariableResolver.js"
    click ZR "https://github.com/bpmn-io/variable-resolver/blob/main/lib/zeebe/VariableResolver.js"
    click CR "https://github.com/bpmn-io/variable-resolver/blob/main/lib/camunda/VariableResolver.js"
    click VE "https://github.com/bpmn-io/variable-resolver/blob/main/lib/zeebe/extractors/connectors.js"
    click SM "https://github.com/bpmn-io/variable-resolver/blob/main/lib/base/util/scopeUtil.js"
    click CS "https://github.com/bpmn-io/variable-resolver/blob/main/lib/base/util/CachedValue.js"
    click EE "https://github.com/bpmn-io/variable-resolver/blob/main/lib/base/util/ExtensionElementsUtil.js"
    click FEEL "https://github.com/bpmn-io/variable-resolver/blob/main/lib/zeebe/util/feelUtility.js"
    click VC "https://github.com/bpmn-io/variable-resolver/blob/main/lib/zeebe/util/VariableContext.js"

    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef platform fill:#4CAF50,stroke:#2E7D32,color:white
    classDef util fill:#FF9800,stroke:#EF6C00,color:white
    classDef external fill:#9E9E9E,stroke:#616161,color:white

    %% Legend
    subgraph Legend
        C[Core Components]:::core
        P[Platform Components]:::platform
        U[Utility Components]:::util
        E[External Interfaces]:::external
    end
```
