# nationalgenomicsinfrastructure/miarka-provision architecture

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

- Interactive diagram: https://gitdiagram.com/nationalgenomicsinfrastructure/miarka-provision
- Repository: https://github.com/nationalgenomicsinfrastructure/miarka-provision

## Overview

Based on our analysis of the file tree and the README, this project is clearly an Ansible-based deployment framework for the NGI environment, used to manage and deploy various production and staging services (such as NGI-Pipeline, Piper, TACA, Tarzan, and several Arteria-related services) on a High Performance Cluster. It is not a typical full-stack application nor a compiler, but rather a sophisticated “deployment orchestration” solution that uses Ansible playbooks and roles to configure, install, and synchronize software deployments across multiple machines/environments.

##### Main Components
- Deployment Controller/Management Node: Represent the “Miarka” deployment node where Ansible is invoked (from either a local environment or via a Singularity container). Mark the bootstrap scripts, Docker and Singularity image creation (docker/, bootstrap/).
- Ansible Infrastructure: Show the key playbooks (install.yml, sync.yml) that drive the deployment stages – “local deployment”, “sync to shared filesystem”, and “post-deployment configuration.”
- env_vars: Contains deployment environment and site-specific variable files.
- env_secrets: Secret or sensitive variables such as tokens, passwords, and API keys.
- host_vars & group_vars: Host- and group-specific configuration used during play execution.
- Roles Directory: This is the heart of the system; include several subcomponents:
- Each role corresponds to a service or function (e.g., arteria-checkqc-ws, arteria-checksum-ws, arteria-delivery-ws, etc.). They have tasks, defaults, meta, and templates subdirectories.
- That each role encapsulates its own installation tasks and configuration templates (Jinja2).
- That additional roles include “misc-tools”, “nextflow”, “nf-core”, etc. – representing various pipelines and tools.
- Inventory & Task Directories: Inventory files (inventory.yml) list target hosts; tasks/ and files/ hold common tasks and configurations for deployment.
- Deployment Stages: Illustrate the three-stage deployment:
- Stage 1: Local disk installation on Miarka (via install.yml).
- Stage 2: Synchronization to a shared filesystem (via sync.yml).
- Stage 3: Post-sync site-specific configuration and service restarts.
- External Interfaces & Infrastructure: Identify external systems such as:
- The HPC shared file system, host nodes (miarka1, miarka2), and user systems.
- SSH multiplexing and network interactions.
- Artifacts like symlinks under /vulpes/ngi/<environment> and the restarting of services (supervisord-managed Arteria services).

##### Relationships and Interactions
- Variable import flows from env_vars/env_secrets to the playbook engine and from roles/defaults into task execution.
- Use of Docker/Singularity images to standardize the Ansible environment.
- Process flow from deployment to synchronization and finally to post-deployment service restart.

##### Architectural Patterns and Design Principles
- Separation of deployment logic into modules (Ansible roles).
- Environment-specific configuration management using layered variable directories (env_vars, env_secrets, host_vars, group_vars).
- Usage of templates (Jinja2) to render configuration files dynamically.
- Emphasis on reproducibility and automation (e.g., using bootstrap scripts and containerized environments).

##### Technology, Frameworks, and Tools
- Ansible as the configuration management and deployment tool.
- Singularity and Docker for containerized execution.
- SSH and SSH multiplexing for secure, efficient connectivity.
- Git for source control and deployment versioning.
- YAML for playbooks and variable files.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Deployment Control Node
    subgraph "Deployment Control Node"
        A1["Miarka Deployment Node"]:::controlnode
        A2["Bootstrap Scripts"]:::controlnode
        A3["Docker Build Files"]:::controlnode
    end

    %% Ansible Infrastructure
    subgraph "Ansible Infrastructure"
        B1["Ansible Playbooks"]:::ansible
        B2["install.yml"]:::ansible
        B3["sync.yml"]:::ansible
    end

    %% Configuration Sources
    subgraph "Configuration Sources"
        C1["env_vars"]:::config
        C2["env_secrets"]:::config
        C3["host_vars"]:::config
        C4["group_vars"]:::config
    end

    %% Inventory & Task Directories
    subgraph "Inventory & Task Directories"
        D1["inventory.yml"]:::inventory
        D2["tasks/"]:::inventory
        D3["files/"]:::inventory
    end

    %% Roles Directory
    subgraph "Roles Directory"
        E1["Ansible Roles"]:::role
    end

    %% Deployment Stages
    subgraph "Deployment Stages"
        F1["Stage 1: Local Installation"]:::deploy
        F2["Stage 2: Shared FS Sync"]:::deploy
        F3["Stage 3: Post-deployment Config & Service Restart"]:::deploy
    end

    %% External Interfaces
    subgraph "External Interfaces"
        G1["HPC Shared File System"]:::external
        G2["Host Nodes (miarka1,miarka2)"]:::external
        G3["User Systems"]:::external
        G4["SSH & Supervisord Services"]:::external
    end

    %% Relationships
    A1 -->|"runs"| B1
    A1 --> A2
    A1 --> A3

    C1 -->|"vars"| B1
    C2 -->|"vars"| B1
    C3 -->|"vars"| B1
    C4 -->|"vars"| B1

    D1 -->|"inventory"| B1
    D2 -->|"tasks"| B1
    D3 -->|"files"| B1

    E1 -->|"roles"| B1

    B1 --> B2
    B1 --> B3

    B2 -->|"executes"| F1
    B3 -->|"executes"| F2

    F1 --> F3
    F2 --> F3

    F2 -->|"syncToFS"| G1
    D1 -->|"targets"| G2
    F3 -->|"restart"| G4

    %% Click Events
    click A2 "https://github.com/nationalgenomicsinfrastructure/miarka-provision/tree/main/bootstrap/"
    click A3 "https://github.com/nationalgenomicsinfrastructure/miarka-provision/tree/main/docker/"
    click B2 "https://github.com/nationalgenomicsinfrastructure/miarka-provision/blob/main/install.yml"
    click B3 "https://github.com/nationalgenomicsinfrastructure/miarka-provision/blob/main/sync.yml"
    click D1 "https://github.com/nationalgenomicsinfrastructure/miarka-provision/blob/main/inventory.yml"
    click D2 "https://github.com/nationalgenomicsinfrastructure/miarka-provision/tree/main/tasks/"
    click D3 "https://github.com/nationalgenomicsinfrastructure/miarka-provision/tree/main/files/"
    click C1 "https://github.com/nationalgenomicsinfrastructure/miarka-provision/tree/main/env_vars/"
    click C2 "https://github.com/nationalgenomicsinfrastructure/miarka-provision/tree/main/env_secrets/"
    click C3 "https://github.com/nationalgenomicsinfrastructure/miarka-provision/tree/main/host_vars/"
    click C4 "https://github.com/nationalgenomicsinfrastructure/miarka-provision/tree/main/group_vars/"
    click E1 "https://github.com/nationalgenomicsinfrastructure/miarka-provision/tree/main/roles/"

    %% Styles
    classDef controlnode fill:#f9e79f,stroke:#f39c12,stroke-width:2px;
    classDef ansible fill:#d5f5e3,stroke:#28b463,stroke-width:2px;
    classDef config fill:#d6eaf8,stroke:#3498db,stroke-width:2px;
    classDef inventory fill:#fadbd8,stroke:#e74c3c,stroke-width:2px;
    classDef role fill:#f5eef8,stroke:#af7ac5,stroke-width:2px;
    classDef deploy fill:#fef9e7,stroke:#f1c40f,stroke-width:2px;
    classDef external fill:#f0e68c,stroke:#b8860b,stroke-width:2px;
```
