# helgestein/helao-pub architecture

> Architecture diagram of the GitHub repository helgestein/helao-pub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/helgestein/helao-pub
- Repository: https://github.com/helgestein/helao-pub

## Overview

##### Project Type and Purpose
- HELAO is a distributed, hierarchical laboratory automation and orchestration framework built atop FastAPI.
- It orchestrates “experiments” defined as sequences of “actions,” each wrapping lower-level hardware drivers or analysis steps.

##### File Structure
- Top-Level Python Scripts:
– helao.py / launcher.py / main.py: CLI entry points for validating config and launching server groups.
– cli.py / Run-File.ps1 / RunPython.ps1: Helpers for local runs or interactive use.
- ‘orchestrators/’: Orchestrator implementations (demo orchestration logic, generic orchestrator class).
- ‘action/’: High-level wrappers exposing device or analysis functionality via REST.
- ‘driver/’: Low-level device drivers (real or simulation) for each hardware component.
- ‘server/’: FastAPI server scripts that wrap drivers to expose HTTP APIs.
- ‘config/’: JSON and Python files defining server groups, device parameters, and world configurations.
- ‘visualizer/’, ‘notebooks/’: Client-side tools for inspecting data or demoing Kafka integration.
- ‘celery_conf.py’: Async task configuration for long-running operations (e.g., machine-learning).

##### Extract Additional Insights from README
- Hierarchical Layers: Orchestrator → Actions → Drivers.
- Communication: All layers expose Python class methods through FastAPI.
- Experiment Definition: A JSON/YAML “sequence of events” (SOE) passed into the orchestrator.
- Devices: A catalog of motion, electrochemistry, spectroscopy, and analysis “devices,” each with its own driver and server.

a. Client Layer
– CLI / helao.py / notebooks / visualizer
– Submits experiments (SOEs) via REST to the Orchestrator
b. Orchestration Layer
– orchestrator.py + demo_orch.py
– Receives experiment definitions, manages SOE, and dispatches Actions
c. Action Layer
– action/*.py modules
– Expose high-level routines (e.g., measure, pump, analyze ML) via FastAPI
d. Driver Layer
– driver/*_driver.py modules
– Interface to real hardware or simulation code
e. Hardware / Simulation
– Physical devices or their simulate counterparts (galil_simulate, gamry_simulate, etc.)
f. Configuration & Persistence
– config/*.py, config.json: define which servers to launch in a “world”
– Experiment metadata, HDF5 output files stored on disk
g. Supporting Infrastructure
– celery_conf.py for asynchronous tasks
– Kafka listener/sender in notebooks (optional messaging layer)

##### Relationships & Data Flows
- Client → Orchestrator:
– POST /experiments with SOE JSON → orchestrator REST endpoint
- Orchestrator → Action:
– For each event, HTTP call to action service (action host:port)
- Action → Driver:
– HTTP call to driver server (driver host:port)
- Driver → Hardware/Simulation:
– Direct API (TCP/IP, serial, .NET DLL) or call simulate module
- Data Persistence:
– Drivers or actions write measurement data to HDF5 or local files
- Async Tasks:
– Long-running actions may enqueue jobs via Celery

##### Architectural Patterns & Design Principles
- Hierarchical layering for clear separation of concerns
- Microservice-style deployment: each action/driver runs as a separate FastAPI server
- Configuration-driven deployment: define server groups in config/world.py
- RESTful APIs for inter-service communication
- Experiment-level metadata propagation down to all layers

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        CLI["CLI & Scripts"]:::client
        NB["Notebooks"]:::client
        VIZ["Visualizer"]:::client
    end

    %% Orchestration Layer
    subgraph "Orchestration Layer"
        direction TB
        ORC["orchestrator.py"]:::orch
        DEMO["demo_orch.py"]:::orch
    end

    %% Action Layer
    subgraph "Action Layer"
        direction TB
        MEAS["measure_action.py"]:::action
        ANL["analysis_action.py"]:::action
        ML["ml_action.py"]:::action
        MOVE["movement_mecademic.py"]:::action
        TPL["template_action.py"]:::action
    end

    %% Server Layer
    subgraph "Server Layer"
        direction TB
        A_S["arcoptix_server.py"]:::server
        AU_S["autolab_server.py"]:::server
        F_S["force_server.py"]:::server
        GIO["galil_io.py"]:::server
        GMOT["galil_motion.py"]:::server
        GAM_S["gamry_server.py"]:::server
        HAM_S["hamilton_server.py"]:::server
        KAD_S["kadi_server.py"]:::server
        LANG_S["lang_server.py"]:::server
        MEC_S["mecademic_server.py"]:::server
        MIN_S["minipump_server.py"]:::server
        OCE_S["ocean_server.py"]:::server
        OWI_S["owis_server.py"]:::server
        PUMP_S["pump_server.py"]:::server
        TPL_S["template_server.py"]:::server
    end

    %% Driver Layer
    subgraph "Driver Layer"
        direction TB
        A_D["arcoptix_driver.py"]:::driver
        AU_D["autolab_driver.py"]:::driver
        F_D["force_driver.py"]:::driver
        G_D["galil_driver.py"]:::driver
        GAM_D["gamry_driver.py"]:::driver
        HAM_D["hamilton_driver.py"]:::driver
        KAD_D["kadi_driver.py"]:::driver
        LANG_D["lang_driver.py"]:::driver
        MEC_D["mecademic_driver.py"]:::driver
        MIN_D["minipump_driver.py"]:::driver
        OCE_D["ocean_driver.py"]:::driver
        OWI_D["owis_driver.py"]:::driver
        PUMP_D["pump_driver.py"]:::driver
        ML_D["ml_driver.py"]:::driver
        SIM_GAL["galil_simulate.py"]:::driver
        SIM_GAM["gamry_simulate.py"]:::driver
    end

    %% Hardware/Simulation
    subgraph "Hardware / Simulation"
        direction TB
        PHY["Physical Devices"]:::hardware
    end

    %% Configuration & Persistence
    subgraph "Config & Persistence"
        direction TB
        CFG_JSON["config.json"]:::config
        CFG_PY["config.py"]:::config
        WORLD["world.py"]:::config
        STORE["HDF5 Storage"]:::storage
    end

    %% Supporting Infrastructure
    subgraph "Supporting Infrastructure"
        direction TB
        CELERY["celery_conf.py"]:::infra
    end

    %% Connections
    CLI -->|POST SOE| ORC
    NB -->|POST SOE| ORC
    VIZ -->|POST SOE| ORC

    WORLD -->|defines servers| ORC
    CFG_JSON -->|defines parameters| ORC
    CFG_PY -->|defines parameters| ORC

    ORC -->|dispatch| MEAS
    ORC -->|dispatch| ANL
    ORC -->|dispatch| ML
    ORC -->|dispatch| MOVE
    ORC -->|dispatch| TPL

    MEAS -->|HTTP call| A_S
    ANL -->|HTTP call| AU_S
    ML -->|HTTP call| GAM_S
    MOVE -->|HTTP call| GIO
    TPL -->|HTTP call| TPL_S

    A_S -->|wraps| A_D
    AU_S -->|wraps| AU_D
    F_S -->|wraps| F_D
    GIO -->|wraps| G_D
    GMOT -->|wraps| G_D
    GAM_S -->|wraps| GAM_D
    HAM_S -->|wraps| HAM_D
    KAD_S -->|wraps| KAD_D
    LANG_S -->|wraps| LANG_D
    MEC_S -->|wraps| MEC_D
    MIN_S -->|wraps| MIN_D
    OCE_S -->|wraps| OCE_D
    OWI_S -->|wraps| OWI_D
    PUMP_S -->|wraps| PUMP_D
    TPL_S -->|wraps| TPL_S

    A_D -->|controls| PHY
    AU_D -->|controls| PHY
    F_D -->|controls| PHY
    G_D -->|controls| PHY
    GAM_D -->|controls| PHY
    HAM_D -->|controls| PHY
    KAD_D -->|controls| PHY
    LANG_D -->|controls| PHY
    MEC_D -->|controls| PHY
    MIN_D -->|controls| PHY
    OCE_D -->|controls| PHY
    OWI_D -->|controls| PHY
    PUMP_D -->|controls| PHY
    ML_D -->|controls| PHY
    SIM_GAL -->|simulates| G_D
    SIM_GAM -->|simulates| GAM_D

    A_D -->|writes data| STORE
    AU_D -->|writes data| STORE
    F_D -->|writes data| STORE
    G_D -->|writes data| STORE
    GAM_D -->|writes data| STORE

    MEAS -->|enqueue| CELERY
    ANL -->|enqueue| CELERY
    ML -->|enqueue| CELERY

    %% Click Events
    click CLI "https://github.com/helgestein/helao-pub/blob/master//helao.py"
    click CLI "https://github.com/helgestein/helao-pub/blob/master//launcher.py"
    click CLI "https://github.com/helgestein/helao-pub/blob/master//main.py"
    click CLI "https://github.com/helgestein/helao-pub/blob/master//cli.py"
    click CLI "https://github.com/helgestein/helao-pub/blob/master//Run-File.ps1"
    click CLI "https://github.com/helgestein/helao-pub/blob/master//RunPython.ps1"
    click NB "https://github.com/helgestein/helao-pub/tree/master//notebooks/"
    click VIZ "https://github.com/helgestein/helao-pub/tree/master//visualizer/"
    click ORC "https://github.com/helgestein/helao-pub/blob/master//orchestrators/orchestrator.py"
    click DEMO "https://github.com/helgestein/helao-pub/blob/master//orchestrators/demo_orch.py"
    click MEAS "https://github.com/helgestein/helao-pub/blob/master//action/measure_action.py"
    click ANL "https://github.com/helgestein/helao-pub/blob/master//action/analysis_action.py"
    click ML "https://github.com/helgestein/helao-pub/blob/master//action/ml_action.py"
    click MOVE "https://github.com/helgestein/helao-pub/blob/master//action/movement_mecademic.py"
    click TPL "https://github.com/helgestein/helao-pub/blob/master//action/template_action.py"
    click A_D "https://github.com/helgestein/helao-pub/blob/master//driver/arcoptix_driver.py"
    click AU_D "https://github.com/helgestein/helao-pub/blob/master//driver/autolab_driver.py"
    click F_D "https://github.com/helgestein/helao-pub/blob/master//driver/force_driver.py"
    click G_D "https://github.com/helgestein/helao-pub/blob/master//driver/galil_driver.py"
    click GAM_D "https://github.com/helgestein/helao-pub/blob/master//driver/gamry_driver.py"
    click HAM_D "https://github.com/helgestein/helao-pub/blob/master//driver/hamilton_driver.py"
    click KAD_D "https://github.com/helgestein/helao-pub/blob/master//driver/kadi_driver.py"
    click LANG_D "https://github.com/helgestein/helao-pub/blob/master//driver/lang_driver.py"
    click MEC_D "https://github.com/helgestein/helao-pub/blob/master//driver/mecademic_driver.py"
    click MIN_D "https://github.com/helgestein/helao-pub/blob/master//driver/minipump_driver.py"
    click OCE_D "https://github.com/helgestein/helao-pub/blob/master//driver/ocean_driver.py"
    click OWI_D "https://github.com/helgestein/helao-pub/blob/master//driver/owis_driver.py"
    click PUMP_D "https://github.com/helgestein/helao-pub/blob/master//driver/pump_driver.py"
    click ML_D "https://github.com/helgestein/helao-pub/blob/master//driver/ml_driver.py"
    click SIM_GAL "https://github.com/helgestein/helao-pub/blob/master//driver/galil_simulate.py"
    click SIM_GAM "https://github.com/helgestein/helao-pub/blob/master//driver/gamry_simulate.py"
    click A_S "https://github.com/helgestein/helao-pub/blob/master//server/arcoptix_server.py"
    click AU_S "https://github.com/helgestein/helao-pub/blob/master//server/autolab_server.py"
    click F_S "https://github.com/helgestein/helao-pub/blob/master//server/force_server.py"
    click GIO "https://github.com/helgestein/helao-pub/blob/master//server/galil_io.py"
    click GMOT "https://github.com/helgestein/helao-pub/blob/master//server/galil_motion.py"
    click GAM_S "https://github.com/helgestein/helao-pub/blob/master//server/gamry_server.py"
    click HAM_S "https://github.com/helgestein/helao-pub/blob/master//server/hamilton_server.py"
    click KAD_S "https://github.com/helgestein/helao-pub/blob/master//server/kadi_server.py"
    click LANG_S "https://github.com/helgestein/helao-pub/blob/master//server/lang_server.py"
    click MEC_S "https://github.com/helgestein/helao-pub/blob/master//server/mecademic_server.py"
    click MIN_S "https://github.com/helgestein/helao-pub/blob/master//server/minipump_server.py"
    click OCE_S "https://github.com/helgestein/helao-pub/blob/master//server/ocean_server.py"
    click OWI_S "https://github.com/helgestein/helao-pub/blob/master//server/owis_server.py"
    click PUMP_S "https://github.com/helgestein/helao-pub/blob/master//server/pump_server.py"
    click TPL_S "https://github.com/helgestein/helao-pub/blob/master//server/template_server.py"
    click CFG_JSON "https://github.com/helgestein/helao-pub/blob/master//config/config.json"
    click CFG_PY "https://github.com/helgestein/helao-pub/blob/master//config/config.py"
    click WORLD "https://github.com/helgestein/helao-pub/blob/master//config/world.py"
    click CELERY "https://github.com/helgestein/helao-pub/blob/master//celery_conf.py"

    %% Styles
    classDef client fill:#D0E7FF,stroke:#0366D6,stroke-width:1px
    classDef orch fill:#DFFFE0,stroke:#28A745,stroke-width:1px
    classDef action fill:#FFEDD5,stroke:#FB8C00,stroke-width:1px
    classDef server fill:#E8E9F3,stroke:#6F42C1,stroke-width:1px
    classDef driver fill:#F3E8FF,stroke:#6F42C1,stroke-width:1px
    classDef hardware fill:#F0F0F0,stroke:#6C757D,stroke-width:1px
    classDef config fill:#FFF5BA,stroke:#D39E00,stroke-width:1px
    classDef storage fill:#FFECEC,stroke:#D73A49,stroke-width:1px
    classDef infra fill:#FBEFF8,stroke:#E83E8C,stroke-width:1px
```
