# elsa-workflows/elsa-studio architecture

> Architecture diagram of the GitHub repository elsa-workflows/elsa-studio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/elsa-workflows/elsa-studio
- Repository: https://github.com/elsa-workflows/elsa-studio

## Overview

##### Main Components
- Core Framework & Services: The foundation lies in the Elsa.Studio.Core and associated framework projects (e.g., Elsa.Studio.Core.BlazorServer and Elsa.Studio.Core.BlazorWasm) that define contracts, service extensions, dependency injection helpers, and core business logic. These also interact with localization, menu systems, and notifications.
- Modules: There is an extensive set of modules (Agents, Counter, Dashboard, Environments, Localization, Login, Secrets, Security, UIHints, Webhooks, and multiple workflow modules) which can be diagrammed as extensions/plugins that add workflows-specific functions and UI components.
- Hosts: Multiple hosting projects exist such as:
– Elsa.Studio.Host.Server: For a Blazor Server hosted experience.
– Elsa.Studio.Host.Wasm and Elsa.Studio.Host.HostedWasm: For Blazor WASM deployments.
– Elsa.Studio.Host.CustomElements: Which likely provides integration of custom web elements.
- Frontend Clients: In addition to the Blazor frontends, there are React-based sample wrappers (in the wrappers directory) that show how the workflow designer and list components can be used as standalone or embeddable modules.
- Client Libraries & Asset Builders: The ClientLib folders in projects such as Elsa.Studio.DomInterop and Elsa.Studio.Workflows.Designer contain JavaScript/TypeScript and Webpack/Vite configurations used to build client assets.
- Configuration & Deployments: Files like Dockerfiles and build scripts indicate containerization and CI/CD integration.

##### Relationships & Data Flow
- The hosts depend on the core services and load various modules at runtime.
- The core components provide API endpoints, dependency injection and shared UI services that feed both Blazor and React frontend components.
- Module-specific services (e.g., Login, Localization) connect to the backend API and affect the UI (e.g., login components, localizable strings).
- The client asset build pipelines (using NPM scripts) build static assets that are then integrated into the hosting projects.
- Data and event flows: From user interactions on the client (Blazor/React UIs) to backend APIs (via HTTP message handlers like AuthenticatingApiHttpMessageHandler) and then into core workflow management services.

##### Architectural Patterns & Design Principles
- Modularity & Extensibility: The extensive use of modules illustrates an extensible plugin architecture—each module adds its own pages, components, services, and menu items.
- Separation of Concerns: There’s a clear separation between UI (frontend wrappers, Blazor components), core business logic (Elsa.Studio.Core), and service modules.
- Client–Server & API Layering: Frontends interact with backend APIs provided by hosting projects. The separation between server-side and WebAssembly (client-side) hosting is also explicit.
- Use of Dependency Injection & Service Collection Extensions: Numerous “ServiceCollectionExtensions.cs” files across the tree show a heavy reliance on DI and modular configuration.

##### Relevant Technologies, Frameworks & Libraries
- .NET 7 and .NET 8 SDK (C# and ASP.NET Core).
- Blazor (both Server and WASM) for rich interactive web UIs.
- MudBlazor for UI component styling.
- React (in the wrappers) for alternative frontends.
- Node.js and npm for asset building (Webpack, Vite, Storybook).
- Containerization with Docker (Dockerfiles in server and WASM hosts).
- Build and CI/CD integration (GitHub workflows, NuGet packaging).

##### Essential Elements
- Clear labels for each component (e.g., “Elsa.Studio.Core”, “Workflow Modules”, “Blazor Host – Server”, “React Wrapper Frontend”).
- Additionally, include supporting infrastructure elements such as CI/CD pipelines and asset build processes as peripheral components if needed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        UI1["Blazor Client"]:::ui
        UI2["React Wrapper Frontend"]:::ui
    end

    %% Backend/API Layer
    subgraph "Backend/API Layer"
        API1["Blazor Server Host"]:::api
        API2["Blazor WASM Host"]:::api
        API3["Hosted WASM Host"]:::api
        API4["Custom Elements Host"]:::api
    end

    %% Core Framework & Modules Layer
    subgraph "Core Framework & Modules"
        %% Core Framework Subgraph
        subgraph "Core Framework"
            CF1["Elsa.Studio.Core"]:::core
            CF2["Elsa.Studio.Core.BlazorServer"]:::core
            CF3["Elsa.Studio.Core.BlazorWasm"]:::core
        end
        
        %% Modules Subgraph
        subgraph "Modules"
            M0["Modules Manager"]:::core
            M1["Agents Module"]:::module
            M2["Counter Module"]:::module
            M3["Dashboard Module"]:::module
            M4["Environments Module"]:::module
            M5["Localization Module (Shared)"]:::module
            M6["Localization Module (BlazorServer)"]:::module
            M7["Localization Module (BlazorWasm)"]:::module
            M8["Login Module (Shared)"]:::module
            M9["Login Module (BlazorServer)"]:::module
            M10["Login Module (BlazorWasm)"]:::module
            M11["Secrets Module"]:::module
            M12["Security Module"]:::module
            M13["UIHints Module"]:::module
            M14["Webhooks Module"]:::module
            M15["Workflows Module (Core)"]:::module
            M16["Workflows Module (Designer)"]:::module
            M17["Workflows Module (Workflows)"]:::module
            M18["Workflow Contexts Module"]:::module
        end
    end

    %% Client Libraries & Asset Builders
    subgraph "Client Libs & Asset Builders"
        CL1["Dom Interop ClientLib"]:::module
        CL2["Workflows Designer ClientLib"]:::module
    end

    %% Configuration & Deployments
    subgraph "Configuration & Deployments"
        D1["Dockerfile (Server)"]:::deployment
        D2["Dockerfile (WASM)"]:::deployment
        D3["CI/CD Configs"]:::deployment
    end

    %% Arrows: UI Layer to Backend/API Layer
    UI1 -->|"calls_API"| API1
    UI1 -->|"calls_API"| API2
    UI2 -->|"calls_API"| API4

    %% Arrows: Backend/API Layer to Core Framework
    API1 -->|"invokes_services"| CF1
    API2 -->|"invokes_services"| CF1
    API3 -->|"invokes_services"| CF1
    API4 -->|"invokes_services"| CF1

    %% Arrows: Core Framework interactions
    CF1 -->|"extends_with"| CF2
    CF1 -->|"extends_with"| CF3
    CF1 -->|"loads_modules"| M0
    CF1 -->|"pushes_updates"| UI1

    %% Arrows: Modules Manager to individual Modules
    M0 -->|"activates"| M1
    M0 -->|"activates"| M2
    M0 -->|"activates"| M3
    M0 -->|"activates"| M4
    M0 -->|"activates"| M5
    M0 -->|"activates"| M6
    M0 -->|"activates"| M7
    M0 -->|"activates"| M8
    M0 -->|"activates"| M9
    M0 -->|"activates"| M10
    M0 -->|"activates"| M11
    M0 -->|"activates"| M12
    M0 -->|"activates"| M13
    M0 -->|"activates"| M14
    M0 -->|"activates"| M15
    M0 -->|"activates"| M16
    M0 -->|"activates"| M17
    M0 -->|"activates"| M18

    %% Arrows: Client Libs integrated into Backend
    CL1 -->|"assets_integration"| API1
    CL2 -->|"assets_integration"| API1

    %% Arrows: Configuration & Deployments into Hosts
    D1 -->|"deploys_to"| API1
    D2 -->|"deploys_to"| API2
    D3 ---|"supports"| API1
    D3 ---|"supports"| API2
    D3 ---|"supports"| API3
    D3 ---|"supports"| API4

    %% Click Events for Core Framework & Services
    click CF1 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/framework/Elsa.Studio.Core"
    click CF2 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/framework/Elsa.Studio.Core.BlazorServer"
    click CF3 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/framework/Elsa.Studio.Core.BlazorWasm"

    %% Click Events for Modules
    click M1 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Agents"
    click M2 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Counter"
    click M3 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Dashboard"
    click M4 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Environments"
    click M5 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Localization"
    click M6 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Localization.BlazorServer"
    click M7 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Localization.BlazorWasm"
    click M8 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Login"
    click M9 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Login.BlazorServer"
    click M10 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Login.BlazorWasm"
    click M11 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Secrets"
    click M12 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Security"
    click M13 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.UIHints"
    click M14 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Webhooks"
    click M15 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Workflows.Core"
    click M16 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Workflows.Designer"
    click M17 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.Workflows"
    click M18 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/modules/Elsa.Studio.WorkflowContexts"

    %% Click Events for Hosts
    click API1 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/hosts/Elsa.Studio.Host.Server"
    click API2 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/hosts/Elsa.Studio.Host.Wasm"
    click API3 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/hosts/Elsa.Studio.Host.HostedWasm"
    click API4 "https://github.com/elsa-workflows/elsa-studio/blob/main/src/hosts/Elsa.Studio.Host.CustomElements"

    %% Click Events for UI Clients
    click UI1 "https://github.com/elsa-workflows/elsa-studio/tree/main/samples/BlazorApp1"
    click UI2 "https://github.com/elsa-workflows/elsa-studio/tree/main/src/wrappers/wrappers/react-wrapper"

    %% Click Events for Client Libs
    click CL1 "https://github.com/elsa-workflows/elsa-studio/tree/main/src/framework/Elsa.Studio.DomInterop/ClientLib"
    click CL2 "https://github.com/elsa-workflows/elsa-studio/tree/main/src/modules/Elsa.Studio.Workflows.Designer/ClientLib"

    %% Click Events for Configuration & Deployments
    click D1 "https://github.com/elsa-workflows/elsa-studio/tree/main/src/hosts/Elsa.Studio.Host.Server/Dockerfile"
    click D2 "https://github.com/elsa-workflows/elsa-studio/tree/main/src/hosts/Elsa.Studio.Host.Wasm/Dockerfile"
    click D3 "https://github.com/elsa-workflows/elsa-studio/tree/main/.github/workflows"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#0c5460,stroke-width:2px,color:#0c5460;
    classDef api fill:#d4edda,stroke:#155724,stroke-width:2px,color:#155724;
    classDef core fill:#fff3cd,stroke:#856404,stroke-width:2px,color:#856404;
    classDef module fill:#f8d7da,stroke:#721c24,stroke-width:2px,color:#721c24;
    classDef deployment fill:#e2e3e5,stroke:#6c757d,stroke-width:2px,color:#6c757d;
```
