# icarlosvega/ilastik architecture

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

- Interactive diagram: https://gitdiagram.com/icarlosvega/ilastik
- Repository: https://github.com/icarlosvega/ilastik

## Overview

##### Project type and purpose
- From the README and file tree, this is a complex, desktop‐based interactive image analysis toolkit (“ilastik”) that guides users through machine‐learning workflows (pixel classification, object tracking, etc.). It is not a web application but a full‐featured GUI application with headless/CLI support and a pluggable operator/dataflow engine (“lazyflow”).

##### File structure
- Top‐level modules:
- ilastik/            ← main application (shell, applets, workflows, utility, plugins)
- lazyflow/           ← core dataflow engine and operators
- bin/                ← command‐line scripts
- notebooks/          ← example notebooks using APIs
- dev/, conda‑recipe ← development environment and packaging
- tests/              ← automated tests
- docs/               ← Sphinx documentation for ilastik and lazyflow
- Patterns:
- Modular “applets” under ilastik/applets – each implements one workflow step (GUI + operator + serializer)
- “Workflows” under ilastik/workflows – orchestrations of applets into end‑to‑end pipelines
- Core dataflow graph under lazyflow, with operators for I/O, filters, ML, caching
- Plugin manager handling third‑party feature/format plugins (ilastik/plugins and plugins_default)
- Deployment/configuration: setup.py, pyproject.toml, conda recipes, CI configs, packaging scripts in bin/ and scripts/.

##### Extract architecture hints from the README
- ilastik.org workflows are interactive but also headless (bin/train_headless.py, shell/headless).
- Relies on Qt for GUI (drawer .ui files under applets and shell/gui/ui).
- ML dependencies: vigra, scikit-learn, PyTorch via tiktorch.
- I/O supports HDF5, TIFF, RESTful volumes, DVID.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% GUI Layer
    subgraph "GUI Layer" 
        direction TB
        GUI["ilastik shell & applet GUIs"]:::frontend
    end

    %% Orchestration Layer
    subgraph "Orchestration Layer"
        direction TB
        Workflows["Workflows & Controllers"]:::orchestration
        AppletBase["Applet Base Class"]:::orchestration
    end

    %% Dataflow Engine
    subgraph "Dataflow Engine"
        direction TB
        LFGraph["lazyflow graph"]:::engine
        LFOp["lazyflow operator"]:::engine
        LFOpDir["operators/"]:::engine
        LFReq["request/"]:::engine
        LFTools["tools/"]:::engine
    end

    %% I/O & Storage
    subgraph "I/O & Storage"
        direction TB
        IOOps["ioOperators/"]:::storage
        IOUtil["io_util/"]:::storage
        Storage["HDF5, Zarr, REST, DVID"]:::storage
    end

    %% ML Libraries Integration
    subgraph "ML Libraries"
        direction TB
        Classifiers["classifiers/"]:::ml
        TTOps["operators/tiktorch/"]:::ml
        TTCtrl["tiktorchController.py"]:::ml
    end

    %% Plugin System
    subgraph "Plugin System"
        direction TB
        PluginMgr["manager.py"]:::plugin
        Plugins["plugins/ & plugins_default/"]:::plugin
    end

    %% CLI / Headless
    subgraph "CLI / Headless Interface"
        direction TB
        TrainHeadless["train_headless.py"]:::cli
        HeadlessShell["headlessShell.py"]:::cli
        BinScripts["bin scripts"]:::cli
    end

    %% Packaging & CI
    subgraph "Packaging & CI"
        direction TB
        Setup["setup.py"]:::packaging
        PyProj["pyproject.toml"]:::packaging
        Conda["meta.yaml"]:::packaging
        CI1[".github/workflows"]:::packaging
        CI2[".circleci/config.yml"]:::packaging
    end

    %% Connections
    User[[User]]:::external -->|"interacts with"| GUI
    GUI -->|"invoke workflow"| Workflows
    Workflows -->|"uses applet base"| AppletBase
    Workflows -->|"builds graph"| LFGraph
    AppletBase -->|"creates operator"| LFOp
    LFGraph -->|"requests data"| LFReq
    LFGraph -->|"uses tools"| LFTools
    LFOp -->|"reads/writes"| IOOps
    IOOps -->|"helper util"| IOUtil
    LFOp -->|"calls ML libs"| Classifiers
    LFOp -->|"calls ML libs"| TTOps
    TTOps -->|"controller"| TTCtrl
    Workflows -->|"discovers plugins"| PluginMgr
    PluginMgr -->|"loads bundles"| Plugins
    TrainHeadless -->|"bypasses GUI"| Workflows
    HeadlessShell -->|"bypasses GUI"| Workflows
    BinScripts -->|"CLI entry"| Workflows
    Setup --- Packaging
    PyProj --- Packaging
    Conda --- Packaging
    CI1 --- Packaging
    CI2 --- Packaging

    %% Click Events
    click GUI "https://github.com/icarlosvega/ilastik/tree/main/ilastik/shell/gui/"
    click Workflows "https://github.com/icarlosvega/ilastik/tree/main/ilastik/workflows/"
    click AppletBase "https://github.com/icarlosvega/ilastik/blob/main/ilastik/applets/base/applet.py"
    click LFGraph "https://github.com/icarlosvega/ilastik/blob/main/lazyflow/graph.py"
    click LFOp "https://github.com/icarlosvega/ilastik/blob/main/lazyflow/operator.py"
    click LFOpDir "https://github.com/icarlosvega/ilastik/tree/main/lazyflow/operators/"
    click LFReq "https://github.com/icarlosvega/ilastik/tree/main/lazyflow/request/"
    click LFTools "https://github.com/icarlosvega/ilastik/tree/main/lazyflow/tools/"
    click IOOps "https://github.com/icarlosvega/ilastik/tree/main/lazyflow/operators/ioOperators/"
    click IOUtil "https://github.com/icarlosvega/ilastik/tree/main/lazyflow/utility/io_util/"
    click Classifiers "https://github.com/icarlosvega/ilastik/tree/main/lazyflow/classifiers/"
    click TTOps "https://github.com/icarlosvega/ilastik/tree/main/lazyflow/operators/tiktorch/"
    click TTCtrl "https://github.com/icarlosvega/ilastik/blob/main/ilastik/applets/neuralNetwork/tiktorchController.py"
    click PluginMgr "https://github.com/icarlosvega/ilastik/blob/main/ilastik/plugins/manager.py"
    click Plugins "https://github.com/icarlosvega/ilastik/tree/main/ilastik/plugins_default/"
    click TrainHeadless "https://github.com/icarlosvega/ilastik/blob/main/bin/train_headless.py"
    click HeadlessShell "https://github.com/icarlosvega/ilastik/blob/main/ilastik/shell/headless/headlessShell.py"
    click BinScripts "https://github.com/icarlosvega/ilastik/tree/main/bin/"
    click Setup "https://github.com/icarlosvega/ilastik/blob/main/setup.py"
    click PyProj "https://github.com/icarlosvega/ilastik/blob/main/pyproject.toml"
    click Conda "https://github.com/icarlosvega/ilastik/blob/main/conda-recipe/meta.yaml"
    click CI1 "https://github.com/icarlosvega/ilastik/tree/main/.github/workflows/"
    click CI2 "https://github.com/icarlosvega/ilastik/blob/main/.circleci/config.yml"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,color:#1B2631
    classDef orchestration fill:#F9E79F,stroke:#B7950B,color:#784212
    classDef engine fill:#ABEBC6,stroke:#1D8348,color:#145A32
    classDef storage fill:#FDEBD0,stroke:#B9770E,color:#6E2C00
    classDef ml fill:#D2B4DE,stroke:#6C3483,color:#4A235A
    classDef plugin fill:#F5CBA7,stroke:#BA4A00,color:#4E342E
    classDef cli fill:#AED6F1,stroke:#1B4F72,color:#1B2631
    classDef packaging fill:#E5E7E9,stroke:#616A6B,color:#1B2631
    classDef external stroke-dasharray: 5 5,color:#000000
```
