# openfreeenergy/openfe architecture

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

- Interactive diagram: https://gitdiagram.com/openfreeenergy/openfe
- Repository: https://github.com/openfreeenergy/openfe

## Overview

##### Project Type and Purpose
- This is a Python library plus CLI tool (“openfe” + “openfecli”) for planning and executing alchemical free energy calculations using OpenMM under the hood.
- It provides:
- A programmatic API (openfe/) for building chemical systems, alchemical networks, execution protocols, and analysis.

##### File Structure
- Top-level packages:
- openfe/ – core library, subdivided into orchestration, setup (network planning, atom mapping, chemical-system generation), protocols (OpenMM AFE/RFE/MD + utilities), storage (metadata server/client), analysis, and generic utils.
- openfecli/ – CLI layer defining commands, click types, parameter definitions, plugins, and fetching abstractions.
- Supporting directories:
- docs/, devtools/, production/ – documentation, helper scripts, Docker/Conda recipes (not part of runtime).
- .github/workflows, CI configs, packaging files – continuous-integration and release pipelines.
- Tests live alongside each module to validate functionality.

##### README for Additional Insights
- Confirms the project is a flagship library of a consortium, supports both interactive (API) and batch (CLI) use, and wraps OpenMM for molecular simulations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        API["Python API"]:::frontend
        CLI["CLI Tool"]:::frontend
        CMD["Commands"]:::frontend
        CT["Click Types"]:::frontend
        PD["Parameter Definitions"]:::frontend
        FET["Fetching Abstractions"]:::frontend
        PLG["Plugin System"]:::frontend
    end

    subgraph "Core Layer"
        ORCH["Orchestration Core"]:::core
    end

    subgraph "Setup Subsystem"
        Planner["Network Planner"]:::core
        AtomMap["Atom Mapping"]:::core
        ChemGen["Chemical-System Generator"]:::core
    end

    subgraph "Protocol Engines"
        AFE["OpenMM AFE"]:::core
        RFE["OpenMM RFE"]:::core
        MD["OpenMM MD"]:::core
        OMMU["OpenMM Utilities"]:::core
    end

    subgraph "Storage Layer"
        MetaStore["Metadata Store Interface"]:::infra
        ResServer["Metadata Server"]:::infra
        ResClient["Metadata Client"]:::infra
    end

    subgraph "Analysis & Viz"
        Analysis["Analysis API"]:::infra
        NetPlot["Network & 3D Plotting"]:::infra
    end

    DUE["Citation Tracking (DUE)"]:::external
    EXTOpenMM[(OpenMM Engine)]:::external
    Compute[(Batch/Cloud Compute)]:::external

    API -->|uses| ORCH
    CLI -->|parses & invokes| ORCH
    ORCH -->|plans| Planner
    ORCH -->|maps atoms| AtomMap
    ORCH -->|generates systems| ChemGen
    ORCH -->|executes| AFE
    ORCH -->|executes| RFE
    ORCH -->|executes| MD
    ORCH -->|uses| OMMU
    AFE -->|push results| ResClient
    RFE -->|push results| ResClient
    MD -->|push results| ResClient
    ResClient -->|stores/retrieves| ResServer
    ResClient -->|interfaces| MetaStore
    Analysis -->|consumes results| ResClient
    Analysis -->|plots networks| NetPlot
    AFE -->|runs on| EXTOpenMM
    RFE -->|runs on| EXTOpenMM
    MD -->|runs on| EXTOpenMM
    AFE -->|schedules| Compute
    RFE -->|schedules| Compute
    MD -->|schedules| Compute
    ORCH -.->|credits| DUE

    click API "https://github.com/openfreeenergy/openfe/blob/main/openfe/__init__.py"
    click CLI "https://github.com/openfreeenergy/openfe/blob/main/openfecli/cli.py"
    click ORCH "https://github.com/openfreeenergy/openfe/blob/main/openfe/orchestration/__init__.py"
    click Planner "https://github.com/openfreeenergy/openfe/blob/main/openfe/setup/alchemical_network_planner/relative_alchemical_network_planner.py"
    click AtomMap "https://github.com/openfreeenergy/openfe/blob/main/openfe/setup/atom_mapping/ligandatommapper.py"
    click ChemGen "https://github.com/openfreeenergy/openfe/blob/main/openfe/setup/chemicalsystem_generator/easy_chemicalsystem_generator.py"
    click AFE "https://github.com/openfreeenergy/openfe/blob/main/openfe/protocols/openmm_afe/equil_solvation_afe_method.py"
    click RFE "https://github.com/openfreeenergy/openfe/blob/main/openfe/protocols/openmm_rfe/equil_rfe_methods.py"
    click MD "https://github.com/openfreeenergy/openfe/blob/main/openfe/protocols/openmm_md/plain_md_methods.py"
    click OMMU "https://github.com/openfreeenergy/openfe/blob/main/openfe/protocols/openmm_utils/omm_compute.py"
    click ResServer "https://github.com/openfreeenergy/openfe/blob/main/openfe/storage/resultserver.py"
    click ResClient "https://github.com/openfreeenergy/openfe/blob/main/openfe/storage/resultclient.py"
    click MetaStore "https://github.com/openfreeenergy/openfe/blob/main/openfe/storage/metadatastore.py"
    click Analysis "https://github.com/openfreeenergy/openfe/blob/main/openfe/analysis/plotting.py"
    click NetPlot "https://github.com/openfreeenergy/openfe/blob/main/openfe/utils/network_plotting.py"
    click DUE "https://github.com/openfreeenergy/openfe/blob/main/openfe/due.py"
    click CMD "https://github.com/openfreeenergy/openfe/blob/main/openfecli/commands/plan_rbfe_network.py"
    click CT "https://github.com/openfreeenergy/openfe/blob/main/openfecli/clicktypes/hyphenchoice.py"
    click PD "https://github.com/openfreeenergy/openfe/blob/main/openfecli/parameters/plan_network_options.py"
    click FET "https://github.com/openfreeenergy/openfe/blob/main/openfecli/fetching.py"
    click PLG "https://github.com/openfreeenergy/openfe/blob/main/openfecli/plugins.py"

    classDef frontend fill:#bbdefb,stroke:#1e88e5
    classDef core fill:#c8e6c9,stroke:#2e7d32
    classDef infra fill:#ffe0b2,stroke:#ef6c00
    classDef external fill:#eeeeee,stroke:#616161,stroke-dasharray:5 5
```
