# zenoxml/scirex architecture

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

- Interactive diagram: https://gitdiagram.com/zenoxml/scirex
- Repository: https://github.com/zenoxml/scirex

## Overview

- Core Framework: Represent the central “SciREX” framework that ties together all functionalities.
- Deep Learning Module: This is subdivided into two primary backends:
- JAX Backend (scirex/core/dl/jax_backend): Contains the JAX/Equinox implementation with submodules for activations, layers (attention, convolution, dropout, etc.), loss functions, metrics, and network architectures (like FCNN, GCN, MLP).
- TensorFlow Backend (scirex/core/dl/tf_backend): Contains similar deep learning building blocks for TensorFlow such as layers, networks, and optimizers.
- Machine Learning Module: Found under scirex/core/ml, it includes implementations for supervised (classification—logistic regression, decision trees, naive Bayes, SVM; regression—linear, polynomial, ridge, LASSO, SVR) and unsupervised methods (clustering algorithms like k-means, DBSCAN, etc.).
- Scientific Machine Learning (SciML) Module: This is the core for scientific computing and research tools. It includes:
- PINNs and FastVPINNs implementations (scirex/core/sciml/pinns & fastvpinns)
- Additional subpackages like ‘fe’ (finite elements), ‘fno’ (Fourier Neural Operators), and geometry modules
- Supporting utilities for data handling, plotting, and computation.
- Experimentation & Research Tools: Although not a standalone “service”, be sure to denote that SciREX has built-in experiment tracking, reproducible research capabilities, visualization, and configuration files (as indicated by documentation and workflow CI configurations).
- Supporting Components:
- Examples: A robust set of example scripts (in examples/ and docs/api) to illustrate usage of deep learning, machine learning, and SciML components.
- Tests: Located under tests/ showing how unit tests but also integration tests are structured.
- Documentation: Comprehensive docs (docs/) that detail API usage, examples, and contribution guidelines.

##### Component relationships and interactions
- The “SciREX Core Framework” is the parent container that integrates the DL, ML, and SciML modules.
- External integrations such as GPU acceleration (mentioned under Hardware Optimization) which supports the computational aspects within DL and SciML components.

##### Architectural patterns and design principles
- Modularity: Use separate blocks/containers for each major module (DL, ML, SciML) and have sub-blocks for backend implementations in DL.
- Layered Architecture: The top layer (user interfaces, example scripts, documentation) communicates with the core system – which then interacts with specialized libraries and computation backends.
- Extensibility & Reproducibility: Highlight design choices that allow easy integration of new scientific algorithms or ML models and tracking of experiments.
- Separation of Concerns: Emphasize that while deep learning functionalities have dedicated submodules (layers, networks, loss, metrics), scientific computing tasks (PDE solving with PINNs, FNO, FE) are handled separately in the SciML module.

##### Final Composition
- Branch this into three main nodes: Deep Learning (further split into JAX and TensorFlow backends), Machine Learning, and Scientific Machine Learning (SciML).
- Below or adjacent, indicate “Documentation”, “Tests”, and “CI/Workflows” as support structures.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User/Example Scripts"]:::user
    Core["SciREX Core Framework"]:::core
    U --> Core

    subgraph "Core Modules"
        DL["Deep Learning Module"]:::dl
        ML["Machine Learning Module"]:::ml
        SciML["Scientific ML Module"]:::sciml
    end
    Core --> DL
    Core --> ML
    Core --> SciML

    %% Deep Learning Backends
    subgraph "Deep Learning Backends"
        DLJAX["JAX Backend"]:::jax
        DLTf["TensorFlow Backend"]:::tf
    end
    DL --> DLJAX
    DL --> DLTf

    %% Scientific ML Subcomponents
    subgraph "SciML Components"
        PINNs["PINNs"]:::pinns
        FastVPINNs["FastVPINNs"]:::fast
        FE["FE Subpackage"]:::fe
        FNO["FNO Subpackage"]:::fno
        Geometry["Geometry Subpackage"]:::geometry
    end
    SciML --> PINNs
    SciML --> FastVPINNs
    SciML --> FE
    SciML --> FNO
    SciML --> Geometry

    %% Common Utilities shared by ML and SciML modules
    CU["Common Utilities"]:::utilities
    ML --> CU
    SciML --> CU

    %% GPU Acceleration integration for DL and SciML components
    GPU["GPU Acceleration"]:::gpu
    DL --> GPU
    SciML --> GPU

    %% Experimentation and Research Tools
    Exp["Experimentation & Research Tools"]:::exp
    Core --> Exp

    subgraph "Support Structures"
        Ex["Examples"]:::examples
        Doc["Documentation"]:::docs
        Tst["Tests"]:::tests
        CI["CI/CD Pipelines"]:::ci
    end
    Exp --> Ex
    Exp --> Doc
    Exp --> Tst
    Exp --> CI

    %% Click Events
    click Core "https://github.com/zenoxml/scirex/blob/main/scirex/core/__init__.py"
    click DLJAX "https://github.com/zenoxml/scirex/tree/main/scirex/core/dl/jax_backend"
    click DLTf "https://github.com/zenoxml/scirex/tree/main/scirex/core/dl/tf_backend"
    click ML "https://github.com/zenoxml/scirex/tree/main/scirex/core/ml"
    click PINNs "https://github.com/zenoxml/scirex/tree/main/scirex/core/sciml/pinns"
    click FastVPINNs "https://github.com/zenoxml/scirex/tree/main/scirex/core/sciml/fastvpinns"
    click FE "https://github.com/zenoxml/scirex/tree/main/scirex/core/sciml/fe"
    click FNO "https://github.com/zenoxml/scirex/tree/main/scirex/core/sciml/fno"
    click Geometry "https://github.com/zenoxml/scirex/tree/main/scirex/core/sciml/geometry"
    click Ex "https://github.com/zenoxml/scirex/tree/main/examples/"
    click Doc "https://github.com/zenoxml/scirex/tree/main/docs/"
    click Tst "https://github.com/zenoxml/scirex/tree/main/tests/"
    click CI "https://github.com/zenoxml/scirex/tree/main/.github/workflows"

    %% Styles
    classDef user fill:#d1e7dd,stroke:#0f5132,stroke-width:2px;
    classDef core fill:#cff4fc,stroke:#055160,stroke-width:2px;
    classDef dl fill:#e7f5ff,stroke:#74c0fc,stroke-width:2px;
    classDef jax fill:#fff3bf,stroke:#ffec99,stroke-width:2px;
    classDef tf fill:#ffe3e3,stroke:#ffa8a8,stroke-width:2px;
    classDef ml fill:#e9ecef,stroke:#adb5bd,stroke-width:2px;
    classDef sciml fill:#fcebea,stroke:#f5c2c7,stroke-width:2px;
    classDef pinns fill:#ffefc1,stroke:#ffd43b,stroke-width:2px;
    classDef fast fill:#d3f9d8,stroke:#69db7c,stroke-width:2px;
    classDef fe fill:#e7f5ff,stroke:#74c0fc,stroke-width:2px;
    classDef fno fill:#e7f5ff,stroke:#74c0fc,stroke-width:2px;
    classDef geometry fill:#e7f5ff,stroke:#74c0fc,stroke-width:2px;
    classDef utilities fill:#f8d7da,stroke:#f5c2c7,stroke-width:2px;
    classDef gpu fill:#d1c4e9,stroke:#9575cd,stroke-width:2px;
    classDef exp fill:#d1e7dd,stroke:#0f5132,stroke-width:2px;
    classDef examples fill:#ffffff,stroke:#000000,stroke-width:1px;
    classDef docs fill:#ffffff,stroke:#000000,stroke-width:1px;
    classDef tests fill:#ffffff,stroke:#000000,stroke-width:1px;
    classDef ci fill:#ffffff,stroke:#000000,stroke-width:1px;
```
