# imcf/python-imcflibs architecture

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

- Interactive diagram: https://gitdiagram.com/imcf/python-imcflibs
- Repository: https://github.com/imcf/python-imcflibs

## Overview

##### Main Components
a. Core Library:
- Base package “imcflibs” which includes utility modules (e.g., iotools.py, log.py, pathtools.py, strtools.py).
- That these functions are generic and provide common utility support.
b. ImageJ/Central Imaging Module:
- Sub-package “imcflibs/imagej” contains specialized modules for interfacing with ImageJ/Fiji (e.g., bioformats.py, shading.py, stitching.py, projections.py, etc.).
c. Testing Infrastructure:
- “tests” directory which mirrors the primary modules. This shows unit tests for both generic utilities and the specialized ImageJ functionality.
d. Build and Deployment System:
- Maven build configuration (pom.xml), GitHub workflows in “.github/workflows”, and shell scripts in “scripts” (like build_and_deploy.sh).
- This ties into CI/CD and publication to the SciJava Maven repository.
e. External Interfaces:
- External dependencies and integrations, specifically the connection with Fiji/ImageJ2, update sites, and Maven-based release mechanism.

##### Relationships and Interactions
- That tests are performed against both the generic and ImageJ parts of the library to validate functionality.
- Link build scripts and Maven configurations to the source code – emphasizing that any changes in the core or ImageJ modules trigger CI/CD workflows before deployment.
- A connection (perhaps as a side note) between the library and external systems: namely, how end users integrate this library into their ImageJ setup (via the IMCF Uni Basel update site).

##### Architectural Patterns and Design Principles
- Modular design: The separation between general utility functions and image processing-specific wrappers.
- Clear separation of concerns: “src/imcflibs” for functionality and “tests” for verification.
- Integration of CI/CD: Continuous integration (via GitHub workflows) and Maven-based release pipeline.
- Interoperability design: Although it’s written in Python, it is built around the ImageJ ecosystem which may use Jython, emphasizing a hybrid approach in terms of language and environment compatibility.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source Code
    subgraph "Source Code"
        %% Core Library Subgraph
        subgraph "Core Library"
            CL["imcflibs (Core Library)"]:::core
            IOT["iotools.py"]:::core
            LOG["log.py"]:::core
            PT["pathtools.py"]:::core
            STR["strtools.py"]:::core
        end

        %% ImageJ Module Subgraph
        subgraph "ImageJ Module"
            IM["imcflibs/imagej (ImageJ Module)"]:::imagej
            BIO["bioformats.py"]:::imagej
            SHAD["shading.py"]:::imagej
            STIT["stitching.py"]:::imagej
            PROJ["projections.py"]:::imagej
            OTHER["Other Modules"]:::imagej
        end
    end

    %% Testing Infrastructure Subgraph
    subgraph "Testing Infrastructure"
        TEST["tests (Tests)"]:::test
        T_BIO["tests/imagej/bioformats/import_image/test_01.py"]:::test
        T_BF["tests/imagej/bioformats/write_bf_memoryfile/test_01.py"]:::test
        T_IOT["tests/test_iotools.py"]:::test
        T_PT["tests/test_pathtools.py"]:::test
        T_STR["tests/test_strtools.py"]:::test
    end

    %% Build and Deployment Subgraph
    subgraph "Build and Deployment"
        MAVEN["pom.xml"]:::build
        WORKFLOWS[".github/workflows (Workflows)"]:::build
        GITHUB_SH[".github/build.sh & .github/setup.sh"]:::build
        SCRIPTS["scripts (Shell Scripts)"]:::build
    end

    %% External Interfaces Node
    EXT["External Interfaces (Fiji/ImageJ2, SciJava Maven)"]:::external

    %% Relationships
    %% ImageJ Module depends on Core Library
    IM -->|"UtilityCalls"| CL
    BIO -->|"UtilityCalls"| CL
    SHAD -->|"UtilityCalls"| CL
    STIT -->|"UtilityCalls"| CL
    PROJ -->|"UtilityCalls"| CL

    %% Testing validates Core and ImageJ Modules
    TEST -->|"TestValidations"| CL
    TEST -->|"TestValidations"| IM
    T_BIO -->|"TestValidations"| BIO
    T_BF -->|"TestValidations"| BIO
    T_IOT -->|"TestValidations"| IOT
    T_PT -->|"TestValidations"| PT
    T_STR -->|"TestValidations"| STR

    %% Build and Deployment triggered by source code changes
    CL -->|"DeploymentTrigger"| MAVEN
    IM -->|"DeploymentTrigger"| MAVEN

    %% CI/CD flows from Build to External Integration
    MAVEN -->|"MavenRelease"| EXT
    WORKFLOWS -->|"CI/CD"| EXT
    SCRIPTS -->|"BuildScripts"| EXT

    %% ImageJ Module processes images for external systems
    IM -->|"ImageProcessing"| EXT

    %% Click Events for Core Library
    click CL "https://github.com/imcf/python-imcflibs/tree/master/src/imcflibs"
    click IOT "https://github.com/imcf/python-imcflibs/blob/master/src/imcflibs/iotools.py"
    click LOG "https://github.com/imcf/python-imcflibs/blob/master/src/imcflibs/log.py"
    click PT "https://github.com/imcf/python-imcflibs/blob/master/src/imcflibs/pathtools.py"
    click STR "https://github.com/imcf/python-imcflibs/blob/master/src/imcflibs/strtools.py"

    %% Click Events for ImageJ Module
    click IM "https://github.com/imcf/python-imcflibs/tree/master/src/imcflibs/imagej"
    click BIO "https://github.com/imcf/python-imcflibs/blob/master/src/imcflibs/imagej/bioformats.py"
    click SHAD "https://github.com/imcf/python-imcflibs/blob/master/src/imcflibs/imagej/shading.py"
    click STIT "https://github.com/imcf/python-imcflibs/blob/master/src/imcflibs/imagej/stitching.py"
    click PROJ "https://github.com/imcf/python-imcflibs/blob/master/src/imcflibs/imagej/projections.py"

    %% Click Events for Testing Infrastructure
    click TEST "https://github.com/imcf/python-imcflibs/tree/master/tests"
    click T_BIO "https://github.com/imcf/python-imcflibs/blob/master/tests/imagej/bioformats/import_image/test_01.py"
    click T_BF "https://github.com/imcf/python-imcflibs/blob/master/tests/imagej/bioformats/write_bf_memoryfile/test_01.py"
    click T_IOT "https://github.com/imcf/python-imcflibs/blob/master/tests/test_iotools.py"
    click T_PT "https://github.com/imcf/python-imcflibs/blob/master/tests/test_pathtools.py"
    click T_STR "https://github.com/imcf/python-imcflibs/blob/master/tests/test_strtools.py"

    %% Click Events for Build and Deployment System
    click MAVEN "https://github.com/imcf/python-imcflibs/blob/master/pom.xml"
    click WORKFLOWS "https://github.com/imcf/python-imcflibs/tree/master/.github/workflows"
    click GITHUB_SH "https://github.com/imcf/python-imcflibs/blob/master/.github/build.sh"
    click SCRIPTS "https://github.com/imcf/python-imcflibs/tree/master/scripts"

    %% Class definitions for styling
    classDef core fill:#add8e6,stroke:#000,stroke-width:1px
    classDef imagej fill:#90ee90,stroke:#000,stroke-width:1px
    classDef test fill:#f08080,stroke:#000,stroke-width:1px
    classDef build fill:#ffcc99,stroke:#000,stroke-width:1px
    classDef external fill:#dda0dd,stroke:#000,stroke-width:1px
```
