# wirecell/wire-cell-toolkit architecture

> Architecture diagram of the GitHub repository wirecell/wire-cell-toolkit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wirecell/wire-cell-toolkit
- Repository: https://github.com/wirecell/wire-cell-toolkit

## Overview

##### Main Components and Structure

a) Core Infrastructure Layer:
- Utility Components (util/)
- Interface Definitions (iface/)
- Plugin System (NamedFactory)
- Configuration Management (ConfigManager)

b) Processing Framework Layer:
- Data Flow Graph System (pgraph/)
- Threading/Parallel Processing (tbb/)
- Processing Nodes and Ports

c) Algorithm Layers:
- Signal Processing (sigproc/)
- Image Processing (img/)
- Generation Components (gen/)
- Pattern Recognition (patrec/)

d) I/O and Integration Layer:
- Root Integration (root/)
- PyTorch Integration (pytorch/)
- ZIO Integration (zio/)
- Serialization (sio/)

##### Component Relationships

- Follow the dependency tree shown in wct-deps.png
- Core utilities as foundation
- Optional package relationships

- Signal/data processing pipelines
- Inter-component communication paths
- Plugin interactions

- Configuration distribution paths
- Factory instantiation routes

##### Key Architectural Elements

Important architectural features:

a) Plugin System:
- Factory mechanisms
- Component registration
- Dynamic loading

b) Multi-threading:
- TBB integration
- Parallel processing flows
- Thread synchronization

c) Data Structures:
- Tensor representations
- Point clouds
- Signal processing structures

##### Integration Points

External system integration:

a) Framework Integration:
- ROOT
- PyTorch
- CUDA
- External data formats

b) Configuration:
- JSON/Jsonnet
- Experiment-specific configs
- Parameter management

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Infrastructure Layer
    subgraph Core
        Util["Utility Components"]:::core
        Iface["Interface Definitions"]:::core
        Plugin["Plugin System<br/>(NamedFactory)"]:::core
        Config["Configuration<br/>Management"]:::core
    end

    %% Processing Framework Layer
    subgraph Framework
        PGraph["Data Flow Graph<br/>System"]:::framework
        TBB["Threading System<br/>(TBB)"]:::framework
        Node["Node Processing"]:::framework
    end

    %% Algorithm Layer
    subgraph Algorithms
        SigProc["Signal Processing"]:::algo
        ImgProc["Image Processing"]:::algo
        Gen["Generation<br/>Components"]:::algo
        PatRec["Pattern Recognition"]:::algo
    end

    %% I/O and Integration Layer
    subgraph Integration
        Root["ROOT Integration"]:::io
        PyTorch["PyTorch Integration"]:::io
        ZIO["ZIO Integration"]:::io
        SIO["Serialization"]:::io
    end

    %% Configuration Layer
    subgraph ConfigSystem
        ConfigFiles["Configuration Files"]:::config
        ConfigTools["Configuration Tools"]:::config
    end

    %% Testing Layer
    subgraph Testing
        TestFW["Test Framework"]:::test
        UnitTests["Unit Tests"]:::test
    end

    %% Relationships
    Util --> Iface
    Iface --> Plugin
    Plugin --> Config
    
    Config --> PGraph
    PGraph --> TBB
    TBB --> Node

    Node --> SigProc
    Node --> ImgProc
    Node --> Gen
    Node --> PatRec

    SigProc --> Root
    ImgProc --> PyTorch
    Gen --> ZIO
    PatRec --> SIO

    Config -.-> ConfigFiles
    Config -.-> ConfigTools

    TestFW --> UnitTests
    UnitTests --> SigProc
    UnitTests --> ImgProc

    %% Click Events
    click Util "https://github.com/wirecell/wire-cell-toolkit/tree/master/util/"
    click Iface "https://github.com/wirecell/wire-cell-toolkit/tree/master/iface/"
    click Plugin "https://github.com/wirecell/wire-cell-toolkit/blob/master/util/inc/WireCellUtil/NamedFactory.h"
    click Config "https://github.com/wirecell/wire-cell-toolkit/blob/master/util/inc/WireCellUtil/ConfigManager.h"
    click PGraph "https://github.com/wirecell/wire-cell-toolkit/tree/master/pgraph/"
    click TBB "https://github.com/wirecell/wire-cell-toolkit/tree/master/tbb/"
    click Node "https://github.com/wirecell/wire-cell-toolkit/blob/master/pgraph/inc/WireCellPgraph/Node.h"
    click SigProc "https://github.com/wirecell/wire-cell-toolkit/tree/master/sigproc/"
    click ImgProc "https://github.com/wirecell/wire-cell-toolkit/tree/master/img/"
    click Gen "https://github.com/wirecell/wire-cell-toolkit/tree/master/gen/"
    click PatRec "https://github.com/wirecell/wire-cell-toolkit/tree/master/patrec/"
    click Root "https://github.com/wirecell/wire-cell-toolkit/tree/master/root/"
    click PyTorch "https://github.com/wirecell/wire-cell-toolkit/tree/master/pytorch/"
    click ZIO "https://github.com/wirecell/wire-cell-toolkit/tree/master/zio/"
    click SIO "https://github.com/wirecell/wire-cell-toolkit/tree/master/sio/"
    click ConfigFiles "https://github.com/wirecell/wire-cell-toolkit/tree/master/cfg/"
    click ConfigTools "https://github.com/wirecell/wire-cell-toolkit/blob/master/apps/apps/wcsonnet.cxx"
    click TestFW "https://github.com/wirecell/wire-cell-toolkit/tree/master/test/"

    %% Styles
    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef framework fill:#90ee90,stroke:#333,stroke-width:2px
    classDef algo fill:#ffb366,stroke:#333,stroke-width:2px
    classDef io fill:#d9b3ff,stroke:#333,stroke-width:2px
    classDef config fill:#ffff99,stroke:#333,stroke-width:2px
    classDef test fill:#ff9999,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Framework Components"]:::framework
        L3["Algorithms"]:::algo
        L4["I/O Integration"]:::io
        L5["Configuration"]:::config
        L6["Testing"]:::test
    end
```
