# alphal00p/spenso architecture

> Architecture diagram of the GitHub repository alphal00p/spenso, 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/spenso
- Repository: https://github.com/alphal00p/spenso

## Overview

##### Main Components

a. Core Tensor Engine
- Split into two main branches: Sparse Tensors (Spensors) and Dense Tensors (Densors)

b. Supporting Systems
Create surrounding modules that connect to the core:

##### Structure System
- Abstract Index Management
- Concrete Index Management
- Dimension Handling
- Representation System
- Slot Management

##### Mathematical Operations
- Arithmetic Operations
- Complex Number Support
- Polynomial Operations
- Contraction Engine
- Algebraic Traits

##### Data Management
- Iterator System
- Data Storage
- Parametric Handling

##### Component Relationships

**[Structure System] ←→ [Core Tensor Engine] ←→ [Mathematical Operations]**
- ↑                     ↑                         ↑
- → [Data Management] ←────────────────┘

##### Implementation Details

Technical details in smaller sub-components:
- Rust-specific features (trait implementations)
- Type system interactions
- Memory management strategies

##### The mathematical operation framework

Keep the abstraction level focused on the architectural components while including enough detail to show the sophisticated nature of the tensor operations and type system.

- ▢ Dense Tensor Components
- ⬡ Sparse Tensor Components
- → Direct Dependency
- ⇢ Optional Dependency
- ↔ Bidirectional Interaction

This design should capture both the mathematical sophistication and the practical implementation details of the Spenso library while maintaining clarity about the system's architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core
        TensorEngine["Core Tensor Engine"]:::core
        SparseTensor[("Sparse Tensors")]:::sparse
        DenseTensor["Dense Tensors"]:::dense
        TensorEngine --> SparseTensor
        TensorEngine --> DenseTensor
    end

    subgraph Structure
        StructSys["Structure System"]:::structure
        AbsIndex["Abstract Index"]:::structure
        ConIndex["Concrete Index"]:::structure
        DimHandle["Dimension Handling"]:::structure
        RepSys["Representation System"]:::structure
        SlotMgmt["Slot Management"]:::structure
        
        StructSys --> AbsIndex
        StructSys --> ConIndex
        StructSys --> DimHandle
        StructSys --> RepSys
        StructSys --> SlotMgmt
    end

    subgraph Math
        MathOps["Mathematical Operations"]:::math
        ArithOps["Arithmetic Operations"]:::math
        ComplexNum["Complex Number Support"]:::math
        PolyOps["Polynomial Operations"]:::math
        ContractEng["Contraction Engine"]:::math
        AlgTraits["Algebraic Traits"]:::math
        
        MathOps --> ArithOps
        MathOps --> ComplexNum
        MathOps --> PolyOps
        MathOps --> ContractEng
        MathOps --> AlgTraits
    end

    subgraph Data
        DataMgmt["Data Management"]:::data
        IterSys["Iterator System"]:::data
        DataStore["Data Storage"]:::data
        ParamHandle["Parametric Handling"]:::data
        
        DataMgmt --> IterSys
        DataMgmt --> DataStore
        DataMgmt --> ParamHandle
    end

    %% Main connections
    StructSys <--> TensorEngine
    TensorEngine <--> MathOps
    DataMgmt --> TensorEngine
    DataMgmt --> StructSys
    DataMgmt --> MathOps

    %% Additional Components
    NetOps["Network Operations"]:::support
    PermHandle["Permutation Handling"]:::support
    SymComp["Symbolic Computations"]:::support
    Utils["Utility Functions"]:::support

    NetOps --> TensorEngine
    PermHandle --> TensorEngine
    SymComp --> TensorEngine
    Utils --> TensorEngine

    %% Click events
    click TensorEngine "https://github.com/alphal00p/spenso/blob/master/src/spenso.rs"
    click AbsIndex "https://github.com/alphal00p/spenso/blob/master/src/structure/abstract_index.rs"
    click ConIndex "https://github.com/alphal00p/spenso/blob/master/src/structure/concrete_index.rs"
    click DimHandle "https://github.com/alphal00p/spenso/blob/master/src/structure/dimension.rs"
    click RepSys "https://github.com/alphal00p/spenso/blob/master/src/structure/representation.rs"
    click SlotMgmt "https://github.com/alphal00p/spenso/blob/master/src/structure/slot.rs"
    click ArithOps "https://github.com/alphal00p/spenso/blob/master/src/arithmetic.rs"
    click ComplexNum "https://github.com/alphal00p/spenso/blob/master/src/complex.rs"
    click PolyOps "https://github.com/alphal00p/spenso/blob/master/src/polynomial.rs"
    click ContractEng "https://github.com/alphal00p/spenso/blob/master/src/contraction.rs"
    click AlgTraits "https://github.com/alphal00p/spenso/blob/master/src/algebraic_traits.rs"
    click IterSys "https://github.com/alphal00p/spenso/blob/master/src/iterators.rs"
    click DataStore "https://github.com/alphal00p/spenso/blob/master/src/data.rs"
    click ParamHandle "https://github.com/alphal00p/spenso/blob/master/src/parametric/atomcore.rs"
    click NetOps "https://github.com/alphal00p/spenso/blob/master/src/network.rs"
    click PermHandle "https://github.com/alphal00p/spenso/blob/master/src/permutation.rs"
    click SymComp "https://github.com/alphal00p/spenso/blob/master/src/symbolic.rs"
    click Utils "https://github.com/alphal00p/spenso/blob/master/src/utils.rs"

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef sparse fill:#E91E63,stroke:#C2185B,color:white
    classDef dense fill:#4CAF50,stroke:#388E3C,color:white
    classDef structure fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef math fill:#FFC107,stroke:#FFA000,color:black
    classDef data fill:#00BCD4,stroke:#0097A7,color:white
    classDef support fill:#FF5722,stroke:#E64A19,color:white
```
