# kochgroup/chi-som architecture

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

- Interactive diagram: https://gitdiagram.com/kochgroup/chi-som
- Repository: https://github.com/kochgroup/chi-som

## Overview

ChI-SOM trains self-organizing maps for molecular datasets, then supports analysis through a desktop viewer or headless plots. The main workflow is to create or load fingerprint datasets, train on CPU or CUDA, derive map outputs, and explore or visualize the results. The graph preserves documented large-dataset storage, interactive filtering and inspection, and command-line viewing. Some relationships are based on the SOURCE INDEX’s import references rather than full excerpts; links among unsampled subsystems are omitted where their runtime wiring is uncertain.

Main entry points: [`src/chisom/__init__.py`](https://github.com/kochgroup/chi-som/blob/main/src/chisom/__init__.py) (Python API), [`src/chisom/_som.py`](https://github.com/kochgroup/chi-som/blob/main/src/chisom/_som.py) (SOM model), [`src/chisom/_interface/gui.py`](https://github.com/kochgroup/chi-som/blob/main/src/chisom/_interface/gui.py) (Interactive viewer), [`src/chisom/io/datastores.py`](https://github.com/kochgroup/chi-som/blob/main/src/chisom/io/datastores.py) (HDF5 datasets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_som["SOM training"]
  node_som["SOM model<br/>[_som.py]"]
  node_cpu["CPU trainer<br/>[trainer.py]"]
  node_distance["Distance functions<br/>[distance.py]"]
  node_kernel["Neighborhood kernels<br/>[kernel.py]"]
  node_umatrix["U-Matrix<br/>[umatrix.py]"]
  node_cuda["CUDA trainer<br/>[trainer.py]"]
  node_graph["U-distance graph<br/>[graph.py]"]
  node_analysis["SOM analysis<br/>[analysis.py]"]
end

subgraph group_data["Molecular data"]
  node_creator["Dataset creator"]
  node_factory["Dataset factories"]
  node_store[("HDF5 datasets<br/>[datastores.py]")]
  node_loader["Dataset loading<br/>[loading.py]"]
end

subgraph group_explore["Visualization and exploration"]
  node_render["Map rendering<br/>[render.py]"]
  node_plot["Headless plotting<br/>[plotting.py]"]
  node_models["Viewer models<br/>[models.py]"]
  node_gui["Interactive viewer<br/>[gui.py]"]
end

subgraph group_entry["User interfaces"]
  node_api["Python API<br/>[__init__.py]"]
  node_cli["View command<br/>[cli.py]"]
end

node_user(("Researcher"))

node_user -->|"calls"| node_api
node_api -->|"exports"| node_som
node_api -->|"exports"| node_analysis
node_api -->|"exports"| node_plot
node_api -->|"exports"| node_gui
node_som -->|"selects backend"| node_cpu
node_som -->|"selects backend"| node_cuda
node_cpu -->|"uses"| node_distance
node_cpu -->|"uses"| node_kernel
node_som -->|"computes"| node_umatrix
node_som -->|"builds"| node_graph
node_creator -->|"uses"| node_factory
node_user -.->|"creates dataset"| node_creator
node_loader -->|"opens"| node_store
node_cli -->|"loads data"| node_loader
node_cli -->|"uses"| node_api
node_plot -->|"uses"| node_render
node_plot -->|"reads"| node_store
node_models -->|"uses"| node_render
node_models -->|"reads"| node_store
node_gui -->|"uses"| node_models
node_gui -->|"uses"| node_render
node_gui -->|"loads data"| node_loader
node_gui -->|"reads"| node_store
node_user -->|"opens viewer"| node_cli

click node_api "https://github.com/kochgroup/chi-som/blob/main/src/chisom/__init__.py"
click node_som "https://github.com/kochgroup/chi-som/blob/main/src/chisom/_som.py"
click node_cpu "https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/cpu/trainer.py"
click node_distance "https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/cpu/distance.py"
click node_kernel "https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/cpu/kernel.py"
click node_umatrix "https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/cpu/umatrix.py"
click node_cuda "https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/cuda/trainer.py"
click node_graph "https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/graph.py"
click node_creator "https://github.com/kochgroup/chi-som/blob/main/src/chisom/io/datastore_creation.py"
click node_factory "https://github.com/kochgroup/chi-som/blob/main/src/chisom/io/datastore_factories.py"
click node_store "https://github.com/kochgroup/chi-som/blob/main/src/chisom/io/datastores.py"
click node_loader "https://github.com/kochgroup/chi-som/blob/main/src/chisom/io/loading.py"
click node_analysis "https://github.com/kochgroup/chi-som/blob/main/src/chisom/analysis.py"
click node_render "https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/render.py"
click node_plot "https://github.com/kochgroup/chi-som/blob/main/src/chisom/io/plotting.py"
click node_models "https://github.com/kochgroup/chi-som/blob/main/src/chisom/_interface/models.py"
click node_gui "https://github.com/kochgroup/chi-som/blob/main/src/chisom/_interface/gui.py"
click node_cli "https://github.com/kochgroup/chi-som/blob/main/src/chisom/cli.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_som,node_cpu,node_distance,node_kernel,node_umatrix,node_cuda,node_graph,node_analysis toneBlue
class node_creator,node_factory,node_store,node_loader toneAmber
class node_render,node_plot,node_models,node_gui toneMint
class node_api,node_cli toneRose
class node_user toneIndigo
```

## Components

### SOM training

- [SOM model](https://github.com/kochgroup/chi-som/blob/main/src/chisom/_som.py): `src/chisom/_som.py`
- [CPU trainer](https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/cpu/trainer.py): `src/chisom/_core/cpu/trainer.py`
- [Distance functions](https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/cpu/distance.py): `src/chisom/_core/cpu/distance.py`
- [Neighborhood kernels](https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/cpu/kernel.py): `src/chisom/_core/cpu/kernel.py`
- [U-Matrix](https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/cpu/umatrix.py): `src/chisom/_core/cpu/umatrix.py`
- [CUDA trainer](https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/cuda/trainer.py): `src/chisom/_core/cuda/trainer.py`
- [U-distance graph](https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/graph.py): `src/chisom/_core/graph.py`
- [SOM analysis](https://github.com/kochgroup/chi-som/blob/main/src/chisom/analysis.py): `src/chisom/analysis.py`

### Molecular data

- [Dataset creator](https://github.com/kochgroup/chi-som/blob/main/src/chisom/io/datastore_creation.py): `src/chisom/io/datastore_creation.py`
- [Dataset factories](https://github.com/kochgroup/chi-som/blob/main/src/chisom/io/datastore_factories.py): `src/chisom/io/datastore_factories.py`
- [HDF5 datasets](https://github.com/kochgroup/chi-som/blob/main/src/chisom/io/datastores.py): `src/chisom/io/datastores.py`
- [Dataset loading](https://github.com/kochgroup/chi-som/blob/main/src/chisom/io/loading.py): `src/chisom/io/loading.py`

### Visualization and exploration

- [Map rendering](https://github.com/kochgroup/chi-som/blob/main/src/chisom/_core/render.py): `src/chisom/_core/render.py`
- [Headless plotting](https://github.com/kochgroup/chi-som/blob/main/src/chisom/io/plotting.py): `src/chisom/io/plotting.py`
- [Viewer models](https://github.com/kochgroup/chi-som/blob/main/src/chisom/_interface/models.py): `src/chisom/_interface/models.py`
- [Interactive viewer](https://github.com/kochgroup/chi-som/blob/main/src/chisom/_interface/gui.py): `src/chisom/_interface/gui.py`

### User interfaces

- [Python API](https://github.com/kochgroup/chi-som/blob/main/src/chisom/__init__.py): `src/chisom/__init__.py`
- [View command](https://github.com/kochgroup/chi-som/blob/main/src/chisom/cli.py): `src/chisom/cli.py`

### Other components

- **Researcher**

## Connections

- Researcher → Python API: calls
- Python API → SOM model: exports (evidence: `src/chisom/__init__.py`)
- Python API → SOM analysis: exports (evidence: `src/chisom/__init__.py`)
- Python API → Headless plotting: exports (evidence: `src/chisom/__init__.py`)
- Python API → Interactive viewer: exports (evidence: `src/chisom/__init__.py`)
- SOM model → CPU trainer: selects backend (evidence: `src/chisom/_som.py`)
- SOM model → CUDA trainer: selects backend (evidence: `src/chisom/_som.py`)
- CPU trainer → Distance functions: uses (evidence: `src/chisom/_core/cpu/trainer.py`)
- CPU trainer → Neighborhood kernels: uses (evidence: `src/chisom/_core/cpu/trainer.py`)
- SOM model → U-Matrix: computes (evidence: `src/chisom/_som.py`)
- SOM model → U-distance graph: builds (evidence: `src/chisom/_som.py`)
- Dataset creator → Dataset factories: uses (evidence: `src/chisom/io/datastore_creation.py`)
- Researcher → Dataset creator: creates dataset
- Dataset loading → HDF5 datasets: opens (evidence: `src/chisom/io/loading.py`)
- View command → Dataset loading: loads data (evidence: `src/chisom/cli.py`)
- View command → Python API: uses (evidence: `src/chisom/cli.py`)
- Headless plotting → Map rendering: uses (evidence: `src/chisom/io/plotting.py`)
- Headless plotting → HDF5 datasets: reads (evidence: `src/chisom/io/plotting.py`)
- Viewer models → Map rendering: uses (evidence: `src/chisom/_interface/models.py`)
- Viewer models → HDF5 datasets: reads (evidence: `src/chisom/_interface/models.py`)
- Interactive viewer → Viewer models: uses (evidence: `src/chisom/_interface/gui.py`)
- Interactive viewer → Map rendering: uses (evidence: `src/chisom/_interface/gui.py`)
- Interactive viewer → Dataset loading: loads data (evidence: `src/chisom/_interface/gui.py`)
- Interactive viewer → HDF5 datasets: reads (evidence: `src/chisom/_interface/gui.py`)
- Researcher → View command: opens viewer
