# wiegerw/nerva architecture

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

- Interactive diagram: https://gitdiagram.com/wiegerw/nerva
- Repository: https://github.com/wiegerw/nerva

## Overview

This repository contributes dataset preparation utilities to the broader Nerva neural-network project; it does not contain the neural-network libraries themselves. The principal workflow is selecting MNIST or CIFAR-10 through the CLI, optionally downloading source data, then producing flattened, normalized NPZ datasets. MNIST is loaded directly from its archive; CIFAR-10 is extracted and its batches are assembled. The graph covers only the sampled preparation script, not downstream training consumers.

Main entry points: [`data/prepare_data.py`](https://github.com/wiegerw/nerva/blob/main/data/prepare_data.py) (Dataset CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_user(("CLI user"))
node_cli["Dataset CLI<br/>[prepare_data.py]"]
node_mnist_download["MNIST download<br/>[prepare_data.py]"]
node_mnist_source["MNIST archive"]
node_mnist_convert["MNIST conversion<br/>[prepare_data.py]"]
node_cifar_download["CIFAR download<br/>[prepare_data.py]"]
node_cifar_source["CIFAR archive"]
node_cifar_convert["CIFAR conversion<br/>[prepare_data.py]"]
node_batch_loader["Batch loader<br/>[prepare_data.py]"]
node_prepared_data["Prepared NPZ"]
node_mnist_service["MNIST host"]
node_cifar_service["CIFAR host"]

node_user -->|"selects dataset"| node_cli
node_cli -->|"optionally calls"| node_mnist_download
node_cli -->|"calls"| node_mnist_convert
node_mnist_download -->|"downloads from"| node_mnist_service
node_mnist_download -->|"writes archive"| node_mnist_source
node_mnist_convert -->|"reads archive"| node_mnist_source
node_mnist_convert -->|"writes NPZ"| node_prepared_data
node_cli -->|"optionally calls"| node_cifar_download
node_cli -->|"calls"| node_cifar_convert
node_cifar_download -->|"downloads from"| node_cifar_service
node_cifar_download -->|"stores and extracts"| node_cifar_source
node_cifar_convert -->|"calls"| node_batch_loader
node_batch_loader -->|"reads batches"| node_cifar_source
node_cifar_convert -->|"writes NPZ"| node_prepared_data

click node_cli "https://github.com/wiegerw/nerva/blob/main/data/prepare_data.py"
click node_mnist_download "https://github.com/wiegerw/nerva/blob/main/data/prepare_data.py"
click node_mnist_convert "https://github.com/wiegerw/nerva/blob/main/data/prepare_data.py"
click node_cifar_download "https://github.com/wiegerw/nerva/blob/main/data/prepare_data.py"
click node_cifar_convert "https://github.com/wiegerw/nerva/blob/main/data/prepare_data.py"
click node_batch_loader "https://github.com/wiegerw/nerva/blob/main/data/prepare_data.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_user toneBlue
class node_cli,node_mnist_download,node_mnist_convert,node_cifar_download,node_cifar_convert,node_batch_loader toneTeal
class node_mnist_source,node_cifar_source,node_prepared_data,node_mnist_service,node_cifar_service toneIndigo
```

## Components

### Other components

- **CLI user**
- [Dataset CLI](https://github.com/wiegerw/nerva/blob/main/data/prepare_data.py): `data/prepare_data.py`
- [MNIST download](https://github.com/wiegerw/nerva/blob/main/data/prepare_data.py): `data/prepare_data.py`
- **MNIST archive**
- [MNIST conversion](https://github.com/wiegerw/nerva/blob/main/data/prepare_data.py): `data/prepare_data.py`
- [CIFAR download](https://github.com/wiegerw/nerva/blob/main/data/prepare_data.py): `data/prepare_data.py`
- **CIFAR archive**
- [CIFAR conversion](https://github.com/wiegerw/nerva/blob/main/data/prepare_data.py): `data/prepare_data.py`
- [Batch loader](https://github.com/wiegerw/nerva/blob/main/data/prepare_data.py): `data/prepare_data.py`
- **Prepared NPZ**
- **MNIST host**
- **CIFAR host**

## Connections

- CLI user → Dataset CLI: selects dataset (evidence: `data/prepare_data.py`)
- Dataset CLI → MNIST download: optionally calls (evidence: `data/prepare_data.py`)
- Dataset CLI → MNIST conversion: calls (evidence: `data/prepare_data.py`)
- MNIST download → MNIST host: downloads from (evidence: `data/prepare_data.py`)
- MNIST download → MNIST archive: writes archive (evidence: `data/prepare_data.py`)
- MNIST conversion → MNIST archive: reads archive (evidence: `data/prepare_data.py`)
- MNIST conversion → Prepared NPZ: writes NPZ (evidence: `data/prepare_data.py`)
- Dataset CLI → CIFAR download: optionally calls (evidence: `data/prepare_data.py`)
- Dataset CLI → CIFAR conversion: calls (evidence: `data/prepare_data.py`)
- CIFAR download → CIFAR host: downloads from (evidence: `data/prepare_data.py`)
- CIFAR download → CIFAR archive: stores and extracts (evidence: `data/prepare_data.py`)
- CIFAR conversion → Batch loader: calls (evidence: `data/prepare_data.py`)
- Batch loader → CIFAR archive: reads batches (evidence: `data/prepare_data.py`)
- CIFAR conversion → Prepared NPZ: writes NPZ (evidence: `data/prepare_data.py`)
