# alphal00p/gammaloop architecture

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

- Interactive diagram: https://gitdiagram.com/alphal00p/gammaloop
- Repository: https://github.com/alphal00p/gammaloop

## Overview

##### Main Components Identification

The system consists of three major layers:
a) Python Interface Layer
- Command-line interface (gammaloop)
- Python API for programmatic access
- Jupyter notebook integration

b) Rust Core Layer
- Core computation engine
- Monte-Carlo integration
- Graph manipulation and analysis

c) Model and Data Layer
- Physics models (SM, scalars)
- Configuration management
- Test resources and examples

**[User Interfaces]**

- CLI (gammaloop)
- Python API
- Jupyter Notebooks

- v
**[Python Layer]**

- Base Objects
- Graph
- Model
- Parameter Cards

- Cross Section
- Cross Section
- Supergraph

- Exporters
- Interface
- GammaLoop Interface

- v
**[Rust Core Engine]**

- API Bridge
- Python Bindings

- Core Components
- CFF (Causal Flow Functions)
- LTD (Loop Tree Duality)
- Graph Processing
- Integration Engine

- Physics
- Numerator
- Model
- Momentum

- Utilities
- Debug/Testing

- v
**[Data Layer]**

- Models
- Standard Model
- Scalar Models

- Configuration
- YAML Files

- Test Resources

##### Component Relationships

- Bidirectional communication between Python and Rust layers through the API bridge
- Data flow from configuration files to both Python and Rust components
- Integration points between physics models and computation engine

##### Additional Elements

- Version compatibility information
- External dependencies (gcc, Python 3.11+, Rust 1.77+)
- Critical paths for performance-sensitive operations

##### Implementation Details

- The modular nature of the system
- Clear separation between interface and computation layers
- Data flow during cross-section calculations
- Integration points with external physics models
- Testing and validation pathways

##### Key Architectural Patterns

- Bridge pattern between Python and Rust
- Factory pattern for model creation
- Strategy pattern for different integration methods
- Observer pattern for computation progress

This system design should help the principal software engineer understand both the high-level architecture and the important implementation details of gammaLoop, while highlighting the critical interactions between components.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef python fill:#2ecc71,stroke:#27ae60,color:white
    classDef rust fill:#e74c3c,stroke:#c0392b,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black

    %% User Interface Layer
    subgraph UI["User Interface Layer"]
        CLI["Command Line Interface"]
        PyAPI["Python API"]
        Jupyter["Jupyter Notebooks"]
    end

    %% Python Layer
    subgraph PY["Python Layer"]
        subgraph BaseObj["Base Objects"]
            Graph["Graph"]
            Model["Model"]
            ParamCards["Parameter Cards"]
        end

        subgraph CrossSec["Cross Section"]
            CS["Cross Section"]
            SG["Supergraph"]
        end

        subgraph Interface["Interface"]
            GLInterface["GammaLoop Interface"]
        end
    end

    %% Rust Core Layer
    subgraph RUST["Rust Core Engine"]
        subgraph Bridge["API Bridge"]
            PyBindings["Python Bindings"]
        end

        subgraph Core["Core Components"]
            CFF["Causal Flow Functions"]
            LTD["Loop Tree Duality"]
            GraphProc["Graph Processing"]
            IntEngine["Integration Engine"]
        end

        subgraph Physics["Physics"]
            Numerator["Numerator"]
            PhysModel["Model"]
            Momentum["Momentum"]
        end
    end

    %% Data Layer
    subgraph DATA["Data Layer"]
        subgraph Models["Models"]
            SM["Standard Model"]
            Scalar["Scalar Models"]
        end

        Config["Configuration"]
        TestRes["Test Resources"]
    end

    %% Relationships
    UI --> PY
    PY --> Bridge
    Bridge --> Core
    Core --> Physics
    Physics --> DATA
    DATA --> PY

    %% Click events
    click CLI "https://github.com/alphal00p/gammaloop/tree/main/python/gammaloop/bin/gammaloop"
    click PyAPI "https://github.com/alphal00p/gammaloop/blob/main/python/gammaloop/interface/gammaloop_interface.py"
    click Jupyter "https://github.com/alphal00p/gammaloop/blob/main/python/gammaloop/examples/jupyter/steer_gammaloop.ipynb"
    click Graph "https://github.com/alphal00p/gammaloop/blob/main/python/gammaloop/base_objects/graph.py"
    click Model "https://github.com/alphal00p/gammaloop/blob/main/python/gammaloop/base_objects/model.py"
    click ParamCards "https://github.com/alphal00p/gammaloop/blob/main/python/gammaloop/base_objects/param_card.py"
    click CS "https://github.com/alphal00p/gammaloop/blob/main/python/gammaloop/cross_section/cross_section.py"
    click SG "https://github.com/alphal00p/gammaloop/blob/main/python/gammaloop/cross_section/supergraph.py"
    click Core "https://github.com/alphal00p/gammaloop/blob/main/src/lib.rs"
    click GraphProc "https://github.com/alphal00p/gammaloop/blob/main/src/graph/half_edge.rs"
    click IntEngine "https://github.com/alphal00p/gammaloop/blob/main/src/integrate.rs"
    click LTD "https://github.com/alphal00p/gammaloop/blob/main/src/ltd.rs"
    click CFF "https://github.com/alphal00p/gammaloop/blob/main/src/cff/mod.rs"
    click SM "https://github.com/alphal00p/gammaloop/tree/main/python/gammaloop/data/models/sm"
    click Scalar "https://github.com/alphal00p/gammaloop/tree/main/python/gammaloop/data/models/scalars"
    click Config "https://github.com/alphal00p/gammaloop/blob/main/python/gammaloop/data/config/gammaloop_config.yaml"
    click TestRes "https://github.com/alphal00p/gammaloop/tree/main/src/test_resources"
    click PyBindings "https://github.com/alphal00p/gammaloop/blob/main/src/api/python.rs"
    click Numerator "https://github.com/alphal00p/gammaloop/blob/main/src/numerator/ufo.rs"
    click Momentum "https://github.com/alphal00p/gammaloop/blob/main/src/momentum.rs"
    click PhysModel "https://github.com/alphal00p/gammaloop/blob/main/src/model.rs"

    %% Style applications
    class CLI,PyAPI,Jupyter ui
    class Graph,Model,ParamCards,CS,SG,GLInterface python
    class PyBindings,CFF,LTD,GraphProc,IntEngine,Numerator,PhysModel,Momentum rust
    class SM,Scalar,Config,TestRes data
```
