# pymc-devs/pymc architecture

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

## Overview

##### Main Components Identification

The system should be divided into these major components:

a) Core Statistical Components:
- Distributions System
- Sampling Engines
- Variational Inference System
- Gaussian Processes
- ODE Solvers

b) Infrastructure Components:
- Model Management
- Backend Systems
- PyTensor Integration
- Data Handling

##### Specific Components

a) Model System:
- Model Core (/pymc/model/core.py)
- Model Graph (/pymc/model_graph.py)
- Model Transforms

b) Statistical Components:
- Distributions (/pymc/distributions/)
- MCMC Samplers (/pymc/sampling/)
- Variational Inference (/pymc/variational/)
- Gaussian Processes (/pymc/gp/)

c) Backend Systems:
- ArviZ Integration
- NDArray Backend
- PyTensor Integration

##### Key Interactions to Highlight

- Model definition flow
- Sampling process flow
- Backend storage interaction
- PyTensor computation pipeline
- Distribution system integration

##### Additional Elements

Include:
- Version information
- External dependency connections
- Data flow direction indicators

##### Implementation Details

Use these visual elements:
- Rectangles: Major components
- Rounded rectangles: Subcomponents
- Hexagons: External interfaces

##### Documentation Integration

References to:
- Key configuration files
- Main entry points
- Critical interfaces
- External dependencies

##### The clear flow from model definition to result generation

Remember to maintain a balance between detail and clarity, focusing on the architectural relationships while avoiding overwhelming technical implementation details.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        ModelAPI["Model Definition API"]:::api
        SamplingUI["Sampling Interface"]:::api
        VisTools["Visualization Tools"]:::api
    end

    subgraph "Core Processing Layer"
        ModelMgmt["Model Management"]:::core
        click ModelMgmt "https://github.com/pymc-devs/pymc/blob/main/pymc/model/core.py"
        
        subgraph "Statistical Components"
            DistSys["Distribution System"]:::stats
            click DistSys "https://github.com/pymc-devs/pymc/tree/main/pymc/distributions/"
            
            SampEng["Sampling Engines"]:::stats
            click SampEng "https://github.com/pymc-devs/pymc/tree/main/pymc/sampling/"
            
            VarInf["Variational Inference"]:::stats
            click VarInf "https://github.com/pymc-devs/pymc/tree/main/pymc/variational/"
            
            GausProc["Gaussian Processes"]:::stats
            click GausProc "https://github.com/pymc-devs/pymc/tree/main/pymc/gp/"
            
            ODESolv["ODE Solvers"]:::stats
            click ODESolv "https://github.com/pymc-devs/pymc/tree/main/pymc/ode/"
        end

        subgraph "Computation Components"
            StatComp["Statistical Computation"]:::compute
            click StatComp "https://github.com/pymc-devs/pymc/blob/main/pymc/math.py"
            
            DataMgmt["Data Management"]:::compute
            click DataMgmt "https://github.com/pymc-devs/pymc/blob/main/pymc/data.py"
            
            ModelGraph["Model Graph"]:::compute
            click ModelGraph "https://github.com/pymc-devs/pymc/blob/main/pymc/model_graph.py"
        end
    end

    subgraph "Backend Layer"
        PyTensorInt["PyTensor Integration"]:::backend
        click PyTensorInt "https://github.com/pymc-devs/pymc/blob/main/pymc/pytensorf.py"
        
        subgraph "Storage Systems"
            NDArray["NDArray Backend"]:::storage
            click NDArray "https://github.com/pymc-devs/pymc/blob/main/pymc/backends/ndarray.py"
            
            ArvizInt["ArviZ Integration"]:::storage
            click ArvizInt "https://github.com/pymc-devs/pymc/blob/main/pymc/backends/arviz.py"
            
            BaseBackend["Base Backend"]:::storage
            click BaseBackend "https://github.com/pymc-devs/pymc/blob/main/pymc/backends/base.py"
        end
    end

    %% Relationships
    ModelAPI --> ModelMgmt
    ModelAPI --> DistSys
    SamplingUI --> SampEng
    VisTools --> ArvizInt

    ModelMgmt --> StatComp
    ModelMgmt --> ModelGraph
    ModelMgmt --> DataMgmt

    DistSys --> StatComp
    SampEng --> StatComp
    VarInf --> StatComp
    GausProc --> StatComp
    ODESolv --> StatComp

    StatComp --> PyTensorInt
    DataMgmt --> NDArray
    ModelGraph --> PyTensorInt

    PyTensorInt --> BaseBackend
    NDArray --> ArvizInt

    %% Styles
    classDef api fill:#9370DB,stroke:#333,stroke-width:2px
    classDef core fill:#4169E1,stroke:#333,stroke-width:2px
    classDef stats fill:#1E90FF,stroke:#333,stroke-width:2px
    classDef compute fill:#FFA500,stroke:#333,stroke-width:2px
    classDef backend fill:#20B2AA,stroke:#333,stroke-width:2px
    classDef storage fill:#3CB371,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        API[API Components]:::api
        Core[Core Components]:::core
        Stats[Statistical Components]:::stats
        Comp[Computation Components]:::compute
        Back[Backend Components]:::backend
        Store[Storage Components]:::storage
    end
```
