# neurodesk/neurocontainers architecture

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

- Interactive diagram: https://gitdiagram.com/neurodesk/neurocontainers
- Repository: https://github.com/neurodesk/neurocontainers

## Overview

##### Main Components
- CI/CD Pipeline: Represent the GitHub workflows (located in .github/workflows) that trigger builds, tests, and issue management. These workflows (e.g., auto-build.yml, build-apps.yml) automate the container builds.
- Container Builder: The interactive_builder directory holds scripts (e.g., extract.py, run_interactive_builder.sh) that may be involved in processing or customizing container builds.
- Recipe Modules: The bulk of the repository is the “recipes” directory that contains subdirectories for each neuro-tool (e.g., afni, ants, fmriprep, freesurfer, etc.). Each recipe includes build scripts, test scripts, and documentation for its respective tool.
- Documentation: The docs folder (and recipe-specific READMEs) gives the requirements and guidelines for containerizing these applications.
- Repository Configuration: Files like .dockerignore, .gitignore, LICENSE, and other CI/CD related configuration files that guide the overall process.
- External Integrations: Connections to external documentation sites (neurodesk.org) and possibly artifact repositories (such as Docker Hub) where the built containers are pushed.

##### Component Relationships and Data Flow
- CI/CD then invokes the Container Builder and associated build scripts within each recipe directory.
- After the build process, successful container builds are pushed to the corresponding container registry or made available for Neurodesktop integration. Show this as an external system.

##### Architectural Patterns and Design Principles
- Automation: The CI/CD workflows encapsulate automated building and testing, emphasizing a “pipeline” or “chain of responsibility” pattern.
- Separation of Concerns: Distinguish between configuration, build scripts, tests, and documentation.

##### Relevant Technologies and External Dependencies
- GitHub Actions: Used for building, testing, and manually triggered processes.
- Docker/Container Technology: Since container building is core, include Docker as an underlying technology.
- Scripting Languages: The use of shell scripts (.sh), Python (extract.py), R (dependencies.R) and, in some cases, Julia, MATLAB scripts in some recipes.
- External Documentation: Link to Neurodesktop and Neurocontainers websites as part of the ecosystem.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A("Event Triggers"):::automation
    B("CI/CD Pipeline (GitHub Workflows)"):::automation
    A --> B

    B --> C
    B --> D

    C("Container Builder (Interactive Builder)"):::automation
    D("Recipe Modules (Neuro-Tool Recipes)"):::module

    C --> E
    D --> E

    E("Testing & Validation"):::automation
    E --> F
    F("Deployment/Publishing (Container Registry & Neurodesktop)"):::external

    %% Container Builder internal scripts
    C1("extract.py"):::automation
    C2("run_interactive_builder.sh"):::automation
    C --> C1
    C --> C2

    %% Support components: Documentation
    G("Documentation (docs & READMEs)"):::doc
    G -.-> B

    %% Repository Configuration subgraph
    subgraph "Repository Configuration"
        RC1[".dockerignore"]:::config
        RC2[".gitignore"]:::config
        RC3["LICENSE"]:::config
    end
    RC1 -.-> B
    RC2 -.-> B
    RC3 -.-> B

    %% Click Events
    click B "https://github.com/neurodesk/neurocontainers/tree/master/.github/workflows"
    click C "https://github.com/neurodesk/neurocontainers/tree/master/interactive_builder"
    click C1 "https://github.com/neurodesk/neurocontainers/blob/master/interactive_builder/extract.py"
    click C2 "https://github.com/neurodesk/neurocontainers/blob/master/interactive_builder/run_interactive_builder.sh"
    click D "https://github.com/neurodesk/neurocontainers/tree/master/recipes"
    click G "https://github.com/neurodesk/neurocontainers/tree/master/docs"
    click RC1 "https://github.com/neurodesk/neurocontainers/blob/master/.dockerignore"
    click RC2 "https://github.com/neurodesk/neurocontainers/blob/master/.gitignore"
    click RC3 "https://github.com/neurodesk/neurocontainers/tree/master/LICENSE"

    %% Styles
    classDef automation fill:#aee1f9,stroke:#333,stroke-width:2px;
    classDef module fill:#a8e6cf,stroke:#333,stroke-width:2px;
    classDef external fill:#ffcc5c,stroke:#333,stroke-width:2px;
    classDef doc fill:#dcedc1,stroke:#333,stroke-width:2px;
    classDef config fill:#ffd1dc,stroke:#333,stroke-width:2px;
```
