# bioexcel/gromacs-docker architecture

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

- Interactive diagram: https://gitdiagram.com/bioexcel/gromacs-docker
- Repository: https://github.com/bioexcel/gromacs-docker

## Overview

##### Main Components
- Build Stages / Containers: Illustrate the three-part process described in the README:
– An initial container build stage that creates an optimized FFTW-enabled container.
– Multiple job matrix stages that invoke generate_specifications_file.py to produce SIMD-specific GROMACS builds.
– The final stage, where a new Docker container is assembled by copying the optimised containers (one per SIMD type) into a single unified image.
- Core Tools and Scripts:
– The Dockerfile that is used to build the main container.
– The “gmx-chooser” script which detects CPU features (AVX/SSE) and selects the appropriate binary at runtime.
– “gromacs-hpccm-recipes-mult-stages” which provides specifications and multi-stage recipes – showcasing the modular design.
- External Dependencies and Integration Points:
– NVIDIA’s CUDA runtime (from the nvidia/cuda base image) used to provide GPU acceleration.
– Docker Hub integration to push the final images.
– GitHub repository integrations (e.g. CI workflows that trigger on pull requests or commits).

##### Relationships and Interactions
- Data Flow and Dependencies:
– Next, show how each SIMD-specific container is created and tagged (using the naming convention “gmx-GROMACS_version-cuda-CUDA_version-SIMD_type”).
– Finally, illustrate how these containers are merged into a consolidated Docker container.
- Conditional Decisions:
– Illustrate the “gmx-chooser” operating at runtime, using hardware detection (CPU SIMD flags) to select the proper GROMACS binary for execution.
- External Interactions:
– Represent external repositories like Docker Hub and external dependencies (CUDA, FFTW, OpenMPI etc.) as external blocks.

##### Architectural Patterns/Design Principles
- Multi-Stage Builds: Emphasize the separation into distinct stages (building base, specialized builds, final image assembly).
- CI/CD-Driven Container Deployment: Highlight the automation via GitHub Actions which parameterizes builds using a job matrix.
- Hardware Acceleration Considerations: Show that the system detects hardware capabilities at runtime via “gmx-chooser” to optimize performance.
- Modular and Configurable: Note the reliance on configurable variables (e.g., SIMD types) in the workflow file which provides flexibility in the build process.

- CI/CD Pipeline (GitHub Actions with main.yml)
- Build Stages:
1. FFTW Optimized Container
2. SIMD-specific GROMACS containers (matrix jobs)
3. Final container assembly (combining all SIMD builds)
- Runtime Component:
– gmx-chooser for detecting hardware and selecting the correct binary.
- External Dependencies:
– nvidia/cuda base image, Docker Hub, and other libraries (fftw, openmpi, etc.)
– Triggering of CI jobs, dependency relationships between build stages, and the merging into the final container image.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CI/CD Pipeline"
        A["CI Pipeline (GitHub Actions)"]
    end

    subgraph "Build Process"
        B["FFTW Optimized Container"]
        C["SIMD-Specific GROMACS Builds"]
        D["Final Container Assembly"]
    end

    subgraph "Deployment"
        E["Docker Hub Push"]
    end

    subgraph "Runtime"
        G["gmx-chooser (Hardware Detection)"]
    end

    subgraph "Tools & Configs"
        H["Dockerfile"]
        I["Multi-stage Build Recipes"]
    end

    subgraph "External Dependencies"
        F["nvidia/cuda Base Image"]
    end

    A -->|"triggers"| B
    B -->|"dependency"| C
    C -->|"merging"| D
    D -->|"pushes"| E
    D -->|"runtime_call"| G

    H -->|"builds"| B
    H -->|"builds"| D
    I -->|"specifies"| B
    I -->|"guides"| C
    I -->|"configures"| D

    F -->|"GPU_acceleration"| D

    click A "https://github.com/bioexcel/gromacs-docker/blob/dev/.github/workflows/main.yml"
    click H "https://github.com/bioexcel/gromacs-docker/tree/dev/Dockerfile"
    click G "https://github.com/bioexcel/gromacs-docker/tree/dev/gmx-chooser"
    click I "https://github.com/bioexcel/gromacs-docker/tree/dev/gromacs-hpccm-recipes-mult-stages"

    class A ci
    class B,C,D build
    class E,F external
    class G runtime
    class H,I tool

    classDef ci fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef build fill:#bbf,stroke:#333,stroke-width:2px;
    classDef runtime fill:#ffc0cb,stroke:#333,stroke-width:2px;
    classDef external fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef tool fill:#fdd,stroke:#333,stroke-width:2px;
```
