# gmlc-tdc/helics architecture

> Architecture diagram of the GitHub repository gmlc-tdc/helics, 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/gmlc-tdc/helics
- Repository: https://github.com/gmlc-tdc/helics

## Overview

##### Main Components

a. Core Layer:
- Core Federation Management (/src/helics/core)
- Time Coordination System
- Message Routing Infrastructure
- Broker System

b. Network Layer (/src/helics/network):
- Multiple Transport Protocols:
- ZMQ
- TCP
- UDP
- MPI
- IPC
- Inproc

c. Application API Layer (/src/helics/application_api):
- Value Federate Interface
- Message Federate Interface
- Filter Interface
- Translator Interface

d. Language Bindings Layer:
- C/C++ Core
- Python
- Java
- Julia
- MATLAB/Octave
- Others (C#, nim)

##### Key Relationships

a. Hierarchical Structure:
**Core Broker**
- Sub-brokers
- Federates

b. Data Flow Paths:
- Publication/Subscription channels
- Message endpoints
- Filter chains
- Translation paths

**┌─────────────────────────────────────────────┐**
- Applications Layer             │
- (External Simulators/Tools using HELICS)   │
- ┤
- Language Bindings Layer           │
- (Python, Java, Julia, MATLAB, etc.)      │
- ┤
- Application API Layer            │
- (Value/Message Federates, Filters, etc.)  │
- ┤
- Core Layer                    │
- (Broker, Time Coordination, Messaging)     │
- ┤
- Network Layer                   │
- (ZMQ, TCP, UDP, MPI, IPC, Inproc)       │
- ┘

##### Important Details

a. Time Management:
- Synchronization paths
- Timing coordinators
- Dependency relationships

b. Message Routing:
- Publication/subscription paths
- Direct endpoint connections
- Filter chains

c. Configuration:
- JSON/TOML configuration inputs
- Command line interfaces
- Environment variable settings

##### Specific HELICS Features to Highlight

- Broker hierarchies
- Time synchronization mechanisms
- Value and message interfaces
- Filter and translator operations
- Core types and federates
- Logging and query systems

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef core fill:#b3d1ff,stroke:#333
    classDef network fill:#90EE90,stroke:#333
    classDef api fill:#FFB366,stroke:#333
    classDef binding fill:#DDA0DD,stroke:#333
    classDef external fill:#E6E6E6,stroke:#333
    
    %% External Applications Layer
    subgraph Applications
        EXT1[External Simulators]:::external
        EXT2[Analysis Tools]:::external
    end

    %% Language Bindings Layer
    subgraph Bindings
        JAVA[Java]:::binding
        CSHARP[C#]:::binding
        CPP[C/C++ Core]:::binding
        PYTHON[Python]:::binding
        JULIA[Julia]:::binding
        MATLAB[MATLAB/Octave]:::binding
    end

    %% Application API Layer
    subgraph API
        VFI[Value Federate Interface]:::api
        MFI[Message Federate Interface]:::api
        FI[Filter Interface]:::api
        TI[Translator Interface]:::api
    end

    %% Core Layer
    subgraph Core
        CFM[Core Federation Management]:::core
        TCS[Time Coordination System]:::core
        MRI[Message Routing]:::core
        BS[Broker System]:::core
        TD[Time Dependencies]:::core
        HM[Handle Management]:::core
        FS[Federate State]:::core
    end

    %% Network Layer
    subgraph Network
        ZMQ[ZMQ Protocol]:::network
        TCP[TCP Protocol]:::network
        UDP[UDP Protocol]:::network
        MPI[MPI Protocol]:::network
        IPC[IPC Protocol]:::network
        INPROC[Inproc Protocol]:::network
    end

    %% Relationships
    Applications --> Bindings
    Bindings --> API
    API --> Core
    Core --> Network

    %% Core Internal Relationships
    CFM --> TCS
    CFM --> MRI
    CFM --> BS
    TCS --> TD
    BS --> HM
    HM --> FS

    %% Click events for component mapping
    click CFM "https://github.com/gmlc-tdc/helics/blob/main/src/helics/core/CoreBroker.hpp"
    click TCS "https://github.com/gmlc-tdc/helics/blob/main/src/helics/core/TimeCoordinator.hpp"
    click MRI "https://github.com/gmlc-tdc/helics/blob/main/src/helics/core/ActionMessage.hpp"
    click BS "https://github.com/gmlc-tdc/helics/blob/main/src/helics/core/BrokerBase.hpp"
    click ZMQ "https://github.com/gmlc-tdc/helics/tree/main/src/helics/network/zmq/"
    click TCP "https://github.com/gmlc-tdc/helics/tree/main/src/helics/network/tcp/"
    click UDP "https://github.com/gmlc-tdc/helics/tree/main/src/helics/network/udp/"
    click MPI "https://github.com/gmlc-tdc/helics/tree/main/src/helics/network/mpi/"
    click IPC "https://github.com/gmlc-tdc/helics/tree/main/src/helics/network/ipc/"
    click INPROC "https://github.com/gmlc-tdc/helics/tree/main/src/helics/network/inproc/"
    click VFI "https://github.com/gmlc-tdc/helics/blob/main/src/helics/application_api/ValueFederate.hpp"
    click MFI "https://github.com/gmlc-tdc/helics/blob/main/src/helics/application_api/MessageFederate.hpp"
    click FI "https://github.com/gmlc-tdc/helics/blob/main/src/helics/application_api/Filters.hpp"
    click TI "https://github.com/gmlc-tdc/helics/blob/main/src/helics/application_api/Translator.hpp"
    click JAVA "https://github.com/gmlc-tdc/helics/tree/main/interfaces/java/"
    click CSHARP "https://github.com/gmlc-tdc/helics/tree/main/interfaces/csharp/"
    click CPP "https://github.com/gmlc-tdc/helics/tree/main/src/helics/shared_api_library/"
    click TD "https://github.com/gmlc-tdc/helics/blob/main/src/helics/core/TimeDependencies.hpp"
    click HM "https://github.com/gmlc-tdc/helics/blob/main/src/helics/core/HandleManager.hpp"
    click FS "https://github.com/gmlc-tdc/helics/blob/main/src/helics/core/FederateState.hpp"
```
