# ecmwf/ecflow architecture

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

- Interactive diagram: https://gitdiagram.com/ecmwf/ecflow
- Repository: https://github.com/ecmwf/ecflow

## Overview

##### Project type and purpose
- ecFlow is a full-stack, client/server workflow system written in C++ with multiple language bindings, a Qt-based GUI, HTTP/REST and UDP interfaces, and command-line tools.
- It orchestrates the execution of suites of tasks with dependencies and time triggers, provides fault tolerance and restart, and is used at ECMWF for operational workflows.

##### High-level file-structure analysis
- Top-level directories:
- libs/… – C++ libraries organizing core domain (core, node, attribute), client logic, server logic, REST, UDP, services, tests.
- Viewer/… – Qt GUI application and its accompanying libViewer for socket communication.
- 3rdparty/… – vendored dependencies (cereal, httplib, nlohmann/json).
- libs/pyext/… – Python bindings and samples.
- tools/… – shell/python scripts and utilities.
- releng/… – CI/CD and container orchestration.
- docs/… – Sphinx documentation, REST API specs, tutorials.
- CMakeLists.txt, CMakePresets.json – build configuration.

a. Main components:
1. Server
– Protocol layers:
- TCP/SSL server (libs/server)
- HTTP/REST server (libs/rest using httplib + JSON)
- UDP interface (libs/udp)
– Core engine: request dispatch, command execution (libs/base, libs/core, libs/node)
– Persistence: checkpoint saver (writing defs to disk), periodic scheduler
– Services: aviso (etcd client), mirror, executor plugin framework (libs/service)
2. Clients
– CLI client (ecflow client tool using libs/client over TCP/SSL)
– Python API (pyext bindings exposing client + core + node)
– Qt GUI (“ecflowUI” in Viewer/ecflowUI) connecting via libViewer sockets to a local helper that proxies to server over TCP
– REST clients (any HTTP client via REST API)
– UDP clients (built-in in client to subscribe to server events)
3. Third-party dependencies
– cereal for serialization
– httplib for HTTP/REST
– nlohmann/json for JSON handling
4. Tools & scripts
– ecflow_fuse, load/shutdown/start shell scripts, suite generation

b. Relationships and interactions:
- CLI ↔ Server over TCP/SSL
- Qt GUI ↔ libViewer local socket → Server over TCP/SSL
- Python scripts ↔ Python API ↔ Server over TCP/SSL or REST
- External processes ↔ REST API over HTTP/BasicAuth
- Server publishes events via UDP; UDP clients subscribe
- Server core modules call persistence, scheduler, services internally

c. Architectural patterns and principles:
- Layered architecture:
- Protocol layer (TCP/SSL, HTTP, UDP)
- Application layer (command dispatch, domain logic in base/core/node)
- Persistence layer (checkpoint, file system)
- Service plugin layer (aviso, mirror, executor)
- Modular C++ libraries for clear separation of concerns
- Client abstraction: CLI, GUI, Python all build atop common client library
- Build & deployment via CMake, CI/CD via GitHub Actions and Bamboo containers

d. Key technologies/frameworks:
- C++17, CMake, Qt (for Viewer), cereal, httplib, nlohmann/json, Python3 bindings, OpenSSL (SSL/TCP)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    subgraph "Clients" 
        direction TB
        CLI["CLI Client"]:::client
        PythonAPI["Python API"]:::client
        GUI["Qt GUI (ecflowUI)"]:::client
        RESTClient["REST Consumer"]:::client
        UDPClient["UDP Subscriber"]:::client
    end

    %% libViewer proxy for GUI
    GUI -->|local socket| LibViewer["libViewer\n(LocalSocketServer)"]:::client

    %% Server
    subgraph "Server" 
        direction TB
        subgraph "Protocol Layer"
            direction TB
            TCP["TCP/SSL Server"]:::protocol
            HTTP["HTTP/REST Server"]:::protocol
            UDP["UDP Interface"]:::protocol
        end
        subgraph "Application Layer"
            direction TB
            BaseCore["Base/Core/Node Domain Logic"]:::core
        end
        subgraph "Persistence Layer"
            direction TB
            Checkpoint["Checkpoint Saver"]:::persistence
            Scheduler["Periodic Scheduler"]:::persistence
        end
        subgraph "Service Plugins"
            direction TB
            Aviso["Aviso Service"]:::service
            Mirror["Mirror Service"]:::service
            Executor["Executor Plugin"]:::service
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Etcd["etcd Cluster"]:::external
        MirrorStore["Mirror Store"]:::external
        FileSystem["File System"]:::external
    end

    %% Third-party Libraries
    subgraph "3rd-Party Libs"
        direction TB
        Cereal["cereal"]:::third
        Httplib["httplib"]:::third
        JSONLib["nlohmann/json"]:::third
    end

    %% Tools & Scripts
    subgraph "Tools & Scripts"
        direction TB
        Start["ecflow_start.sh"]:::infra
        Stop["ecflow_stop.sh"]:::infra
        Load["ecflow_load.sh"]:::infra
    end

    %% CI/CD & Build
    subgraph "Build & CI/CD"
        direction TB
        CMake["CMake"]:::infra
        Releng["releng/compose.yaml"]:::infra
    end

    %% Client to Server interactions
    CLI -->|TCP/SSL| TCP
    LibViewer -->|TCP/SSL| TCP
    PythonAPI -->|TCP/SSL or REST| TCP
    PythonAPI -->|REST| HTTP
    RESTClient -->|HTTP/BasicAuth| HTTP
    UDPClient -->|subscribe| UDP

    %% Server internals
    TCP -->|dispatch| BaseCore
    HTTP -->|dispatch| BaseCore
    UDP -->|dispatch| BaseCore
    BaseCore -->|write| Checkpoint
    BaseCore -->|schedule| Scheduler
    BaseCore -->|invoke| Aviso
    BaseCore -->|invoke| Mirror
    BaseCore -->|invoke| Executor
    Aviso -->|calls| Etcd
    Mirror -->|sync| MirrorStore
    Checkpoint -->|persist| FileSystem

    %% Third-party usage
    HTTP --> Cereal
    HTTP --> Httplib
    HTTP --> JSONLib

    %% Tools and CI context
    Start --> TCP
    Stop --> TCP
    Load --> TCP
    CMake -.-> BaseCore
    Releng -.-> CMake

    %% Click Events
    click TCP "https://github.com/ecmwf/ecflow/blob/develop/libs/server/src/ecflow/server/TcpServer.cpp"
    click TCP "https://github.com/ecmwf/ecflow/blob/develop/libs/server/src/ecflow/server/SslTcpServer.cpp"
    click HTTP "https://github.com/ecmwf/ecflow/blob/develop/libs/rest/src/ecflow/http/HttpServer.cpp"
    click HTTP "https://github.com/ecmwf/ecflow/blob/develop/libs/rest/src/ecflow/http/ApiV1Impl.cpp"
    click UDP "https://github.com/ecmwf/ecflow/blob/develop/libs/udp/src/ecflow/udp/UDPServer.cpp"
    click UDP "https://github.com/ecmwf/ecflow/blob/develop/libs/udp/src/ecflow/udp/RequestHandler.cpp"
    click BaseCore "https://github.com/ecmwf/ecflow/blob/develop/libs/base/src/ecflow/base/ServerProtocol.hpp"
    click BaseCore "https://github.com/ecmwf/ecflow/blob/develop/libs/base/src/ecflow/base/ServerReply.cpp"
    click BaseCore "https://github.com/ecmwf/ecflow/blob/develop/libs/core/src/ecflow/core/Ecf.cpp"
    click BaseCore "https://github.com/ecmwf/ecflow/blob/develop/libs/core/src/ecflow/core/Ecf.hpp"
    click BaseCore "https://github.com/ecmwf/ecflow/blob/develop/libs/node/src/ecflow/node/Node.cpp"
    click BaseCore "https://github.com/ecmwf/ecflow/blob/develop/libs/node/src/ecflow/node/Task.cpp"
    click Checkpoint "https://github.com/ecmwf/ecflow/blob/develop/libs/server/src/ecflow/server/CheckPtSaver.cpp"
    click Scheduler "https://github.com/ecmwf/ecflow/blob/develop/libs/server/src/ecflow/server/PeriodicScheduler.cpp"
    click Aviso "https://github.com/ecmwf/ecflow/blob/develop/libs/service/src/ecflow/service/aviso/AvisoService.cpp"
    click Mirror "https://github.com/ecmwf/ecflow/blob/develop/libs/service/src/ecflow/service/mirror/MirrorService.cpp"
    click Executor "https://github.com/ecmwf/ecflow/blob/develop/libs/service/src/ecflow/service/executor/PeriodicTaskExecutor.hpp"
    click CLI "https://github.com/ecmwf/ecflow/blob/develop/libs/client/src/ecflow/client/ClientMain.cpp"
    click CLI "https://github.com/ecmwf/ecflow/blob/develop/libs/client/src/ecflow/client/ClientInvoker.cpp"
    click PythonAPI "https://github.com/ecmwf/ecflow/blob/develop/libs/pyext/src/ecflow/python/PythonBinding.hpp"
    click PythonAPI "https://github.com/ecmwf/ecflow/blob/develop/libs/pyext/src/ecflow/python/ExportClient.cpp"
    click PythonAPI "https://github.com/ecmwf/ecflow/blob/develop/libs/pyext/src/ecflow/python/ExportCore.cpp"
    click PythonAPI "https://github.com/ecmwf/ecflow/blob/develop/libs/pyext/src/ecflow/python/ExportNode.cpp"
    click GUI "https://github.com/ecmwf/ecflow/blob/develop/Viewer/ecflowUI/src/ViewerMain.cpp"
    click GUI "https://github.com/ecmwf/ecflow/blob/develop/Viewer/ecflowUI/src/MainWindow.cpp"
    click LibViewer "https://github.com/ecmwf/ecflow/blob/develop/Viewer/libViewer/src/LocalSocketServer.cpp"
    click LibViewer "https://github.com/ecmwf/ecflow/blob/develop/Viewer/libViewer/src/DirectoryHandler.cpp"
    click Cereal "https://github.com/ecmwf/ecflow/blob/develop/3rdparty/cereal/include/cereal/archives/json.hpp"
    click Httplib "https://github.com/ecmwf/ecflow/blob/develop/3rdparty/cpp-httplib/include/httplib.h"
    click JSONLib "https://github.com/ecmwf/ecflow/blob/develop/3rdparty/json/include/nlohmann/json.hpp"
    click Start "https://github.com/ecmwf/ecflow/blob/develop/tools/ecflow_start.sh"
    click Stop "https://github.com/ecmwf/ecflow/blob/develop/tools/ecflow_stop.sh"
    click Load "https://github.com/ecmwf/ecflow/blob/develop/tools/ecflow_load.sh"
    click CMake "https://github.com/ecmwf/ecflow/blob/develop/CMakeLists.txt"
    click Releng "https://github.com/ecmwf/ecflow/blob/develop/releng/imachination/compose.yaml"

    %% Styles
    classDef client fill:#E8F1F2,stroke:#097485,color:#073642;
    classDef protocol fill:#FFF5BA,stroke:#B58900,color:#586E75;
    classDef core fill:#E0F7FA,stroke:#006064,color:#004D40;
    classDef persistence fill:#FFF3E0,stroke:#E65100,color:#BF360C;
    classDef service fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C;
    classDef external fill:#ECEFF1,stroke:#607D8B,color:#263238;
    classDef third fill:#F1F8E9,stroke:#7CB342,color:#33691E;
    classDef infra fill:#FBE9E7,stroke:#D84315,color:#BF360C;
```
