# markean/aimz architecture

> Architecture diagram of the GitHub repository markean/aimz, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/markean/aimz
- Repository: https://github.com/markean/aimz

## Overview

aimz is a Python library for scalable probabilistic impact modeling. A user supplies a NumPyro kernel and data to ImpactModel, fits it, then requests predictions or intervention effects. Internally, input preparation and sharding feed forward sampling; streaming coordinates chunked output, which is stored in Zarr or accumulated in memory and formatted as Xarray trees. The graph also preserves the documented MLflow tracking capability. Some subsystem links rely on the SOURCE INDEX or README because excerpts are partial; unsampled implementation details are not assumed.

Main entry points: [`aimz/model/impact_model.py`](https://github.com/markean/aimz/blob/main/aimz/model/impact_model.py) (ImpactModel), [`aimz/model/_streaming.py`](https://github.com/markean/aimz/blob/main/aimz/model/_streaming.py) (Streaming runtime), [`aimz/utils/data/_input_setup.py`](https://github.com/markean/aimz/blob/main/aimz/utils/data/_input_setup.py) (Input preparation), [`aimz/sampling/_forward.py`](https://github.com/markean/aimz/blob/main/aimz/sampling/_forward.py) (Forward sampling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_modeling["Modeling and inference"]
  node_impact_model["ImpactModel<br/>[impact_model.py]"]
  node_kernel_spec["Kernel metadata<br/>[kernel_spec.py]"]
  node_inference_core["Inference core<br/>[_core.py]"]
  node_validation["Validation<br/>[_validation.py]"]
  node_exceptions["Warnings and errors<br/>[_exceptions.py]"]
end

subgraph group_execution["Sampling and streaming"]
  node_streaming["Streaming runtime<br/>[_streaming.py]"]
  node_forward["Forward sampling<br/>[_forward.py]"]
  node_sharding["Sharded execution<br/>[_sharding.py]"]
end

subgraph group_data["Data and results"]
  node_input_setup["Input preparation<br/>[_input_setup.py]"]
  node_kwargs["Kernel arguments<br/>[_kwargs.py]"]
  node_array_dataset["Array dataset<br/>[array_dataset.py]"]
  node_array_loader["Array loader<br/>[array_loader.py]"]
  node_output_writer["Output writer<br/>[_output.py]"]
  node_zarr[("Zarr store")]
  node_format["Xarray formatting<br/>[_format.py]"]
end

subgraph group_tracking["Experiment tracking"]
  node_mlflow_integration["MLflow integration<br/>[__init__.py]"]
end

node_user(("Modeling user"))
node_numpyro["NumPyro and JAX"]
node_mlflow["MLflow"]

node_user -->|"configures and calls"| node_impact_model
node_user -->|"defines kernel"| node_numpyro
node_impact_model -->|"delegates inference"| node_inference_core
node_impact_model -->|"uses metadata"| node_kernel_spec
node_impact_model -->|"validates inputs"| node_validation
node_impact_model -->|"runs streaming"| node_streaming
node_impact_model -->|"requests sampling"| node_forward
node_impact_model -->|"prepares inputs"| node_input_setup
node_impact_model -->|"formats results"| node_format
node_streaming -->|"opens input stream"| node_input_setup
node_streaming -->|"computes samples"| node_forward
node_streaming -->|"uses sharding"| node_sharding
node_streaming -->|"partitions arguments"| node_kwargs
node_streaming -->|"dispatches output"| node_output_writer
node_forward -->|"traces kernel"| node_numpyro
node_sharding -->|"invokes sampler"| node_forward
node_input_setup -->|"groups arguments"| node_kwargs
node_input_setup -->|"uses loader"| node_array_loader
node_array_loader -->|"wraps dataset"| node_array_dataset
node_output_writer -->|"writes chunks"| node_zarr
node_output_writer -->|"uses formatting"| node_format
node_format -->|"loads stored output"| node_zarr
node_impact_model -->|"tracked by integration"| node_mlflow_integration
node_mlflow_integration -->|"logs runs"| node_mlflow

click node_impact_model "https://github.com/markean/aimz/blob/main/aimz/model/impact_model.py"
click node_kernel_spec "https://github.com/markean/aimz/blob/main/aimz/model/kernel_spec.py"
click node_inference_core "https://github.com/markean/aimz/blob/main/aimz/model/_core.py"
click node_validation "https://github.com/markean/aimz/blob/main/aimz/utils/_validation.py"
click node_exceptions "https://github.com/markean/aimz/blob/main/aimz/_exceptions.py"
click node_streaming "https://github.com/markean/aimz/blob/main/aimz/model/_streaming.py"
click node_forward "https://github.com/markean/aimz/blob/main/aimz/sampling/_forward.py"
click node_sharding "https://github.com/markean/aimz/blob/main/aimz/utils/data/_sharding.py"
click node_input_setup "https://github.com/markean/aimz/blob/main/aimz/utils/data/_input_setup.py"
click node_kwargs "https://github.com/markean/aimz/blob/main/aimz/utils/_kwargs.py"
click node_array_dataset "https://github.com/markean/aimz/blob/main/aimz/utils/data/array_dataset.py"
click node_array_loader "https://github.com/markean/aimz/blob/main/aimz/utils/data/array_loader.py"
click node_output_writer "https://github.com/markean/aimz/blob/main/aimz/utils/_output.py"
click node_format "https://github.com/markean/aimz/blob/main/aimz/utils/_format.py"
click node_mlflow_integration "https://github.com/markean/aimz/blob/main/aimz/mlflow/__init__.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_impact_model,node_kernel_spec,node_inference_core,node_validation,node_exceptions,node_user toneBlue
class node_streaming,node_forward,node_sharding toneAmber
class node_input_setup,node_kwargs,node_array_dataset,node_array_loader,node_output_writer,node_zarr,node_format toneMint
class node_mlflow_integration toneRose
class node_numpyro,node_mlflow toneIndigo
```

## Components

### Modeling and inference

- [ImpactModel](https://github.com/markean/aimz/blob/main/aimz/model/impact_model.py): `aimz/model/impact_model.py`
- [Kernel metadata](https://github.com/markean/aimz/blob/main/aimz/model/kernel_spec.py): `aimz/model/kernel_spec.py`
- [Inference core](https://github.com/markean/aimz/blob/main/aimz/model/_core.py): `aimz/model/_core.py`
- [Validation](https://github.com/markean/aimz/blob/main/aimz/utils/_validation.py): `aimz/utils/_validation.py`
- [Warnings and errors](https://github.com/markean/aimz/blob/main/aimz/_exceptions.py): `aimz/_exceptions.py`

### Sampling and streaming

- [Streaming runtime](https://github.com/markean/aimz/blob/main/aimz/model/_streaming.py): `aimz/model/_streaming.py`
- [Forward sampling](https://github.com/markean/aimz/blob/main/aimz/sampling/_forward.py): `aimz/sampling/_forward.py`
- [Sharded execution](https://github.com/markean/aimz/blob/main/aimz/utils/data/_sharding.py): `aimz/utils/data/_sharding.py`

### Data and results

- [Input preparation](https://github.com/markean/aimz/blob/main/aimz/utils/data/_input_setup.py): `aimz/utils/data/_input_setup.py`
- [Kernel arguments](https://github.com/markean/aimz/blob/main/aimz/utils/_kwargs.py): `aimz/utils/_kwargs.py`
- [Array dataset](https://github.com/markean/aimz/blob/main/aimz/utils/data/array_dataset.py): `aimz/utils/data/array_dataset.py`
- [Array loader](https://github.com/markean/aimz/blob/main/aimz/utils/data/array_loader.py): `aimz/utils/data/array_loader.py`
- [Output writer](https://github.com/markean/aimz/blob/main/aimz/utils/_output.py): `aimz/utils/_output.py`
- **Zarr store**
- [Xarray formatting](https://github.com/markean/aimz/blob/main/aimz/utils/_format.py): `aimz/utils/_format.py`

### Experiment tracking

- [MLflow integration](https://github.com/markean/aimz/blob/main/aimz/mlflow/__init__.py): `aimz/mlflow/__init__.py`

### Other components

- **Modeling user**
- **NumPyro and JAX**
- **MLflow**

## Connections

- Modeling user → ImpactModel: configures and calls (evidence: `README.md`)
- Modeling user → NumPyro and JAX: defines kernel (evidence: `README.md`)
- ImpactModel → Inference core: delegates inference (evidence: `aimz/model/impact_model.py`)
- ImpactModel → Kernel metadata: uses metadata (evidence: `aimz/model/impact_model.py`)
- ImpactModel → Validation: validates inputs (evidence: `aimz/model/impact_model.py`)
- ImpactModel → Streaming runtime: runs streaming (evidence: `aimz/model/impact_model.py`)
- ImpactModel → Forward sampling: requests sampling (evidence: `aimz/model/impact_model.py`)
- ImpactModel → Input preparation: prepares inputs (evidence: `aimz/model/impact_model.py`)
- ImpactModel → Xarray formatting: formats results (evidence: `aimz/model/impact_model.py`)
- Streaming runtime → Input preparation: opens input stream (evidence: `aimz/model/_streaming.py`)
- Streaming runtime → Forward sampling: computes samples (evidence: `aimz/model/_streaming.py`)
- Streaming runtime → Sharded execution: uses sharding (evidence: `aimz/model/_streaming.py`)
- Streaming runtime → Kernel arguments: partitions arguments (evidence: `aimz/model/_streaming.py`)
- Streaming runtime → Output writer: dispatches output (evidence: `aimz/model/_streaming.py`)
- Forward sampling → NumPyro and JAX: traces kernel (evidence: `aimz/sampling/_forward.py`)
- Sharded execution → Forward sampling: invokes sampler (evidence: `aimz/utils/data/_sharding.py`)
- Input preparation → Kernel arguments: groups arguments (evidence: `aimz/utils/data/_input_setup.py`)
- Input preparation → Array loader: uses loader (evidence: `aimz/utils/data/_input_setup.py`)
- Array loader → Array dataset: wraps dataset (evidence: `aimz/utils/data/array_loader.py`)
- Output writer → Zarr store: writes chunks (evidence: `aimz/utils/_output.py`)
- Output writer → Xarray formatting: uses formatting (evidence: `aimz/utils/_output.py`)
- Xarray formatting → Zarr store: loads stored output (evidence: `aimz/utils/_format.py`)
- ImpactModel → MLflow integration: tracked by integration (evidence: `aimz/mlflow/__init__.py`)
- MLflow integration → MLflow: logs runs (evidence: `README.md`)
