# saehm/druidjs architecture

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

- Interactive diagram: https://gitdiagram.com/saehm/druidjs
- Repository: https://github.com/saehm/druidjs

## Overview

DruidJS is a JavaScript data-analysis library whose main workflow is to turn input data into a Matrix, run a dimensionality-reduction method, and return a lower-dimensional embedding. Its public API also exposes clustering, nearest-neighbor indices, metrics, and matrix operations. The graph preserves these documented capabilities and shows selected internal math and WebAssembly layers. Relationships are limited to those supported by the README or the supplied excerpts and source index; unsampled algorithms are represented at their existing directory paths.

Main entry points: [`src/matrix/Matrix.js`](https://github.com/saehm/druidjs/blob/master/src/matrix/Matrix.js) (Matrix Data), [`src/index.js`](https://github.com/saehm/druidjs/blob/master/src/index.js) (Public Exports), [`src/dimred/PaCMAP.js`](https://github.com/saehm/druidjs/blob/master/src/dimred/PaCMAP.js) (PaCMAP), [`src/dimred/UMAP.js`](https://github.com/saehm/druidjs/blob/master/src/dimred/UMAP.js) (UMAP)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_entry["Public Exports<br/>[index.js]"]
end

subgraph group_projection["Dimensionality Reduction"]
  node_dr_base["DR Framework<br/>[DR.js]"]
  node_dr_methods["Reduction Methods"]
  node_pca["PCA<br/>[PCA.js]"]
  node_mds["MDS<br/>[MDS.js]"]
  node_umap["UMAP<br/>[UMAP.js]"]
  node_pacmap["PaCMAP<br/>[PaCMAP.js]"]
end

subgraph group_analysis["Data Analysis"]
  node_knn["Neighbor Indices"]
  node_hnsw["HNSW<br/>[HNSW.js]"]
  node_clustering["Clustering Algorithms"]
  node_cluster_base["Clustering Base<br/>[Clustering.js]"]
  node_kmeans["K-Means<br/>[KMeans.js]"]
end

subgraph group_foundations["Numerical Foundations"]
  node_matrix["Matrix Data<br/>[Matrix.js]"]
  node_metrics["Distance Metrics"]
  node_linear["Linear Algebra"]
  node_random["Randomizer<br/>[randomizer.js]"]
  node_mst["Spanning Tree"]
end

subgraph group_acceleration["WebAssembly Acceleration"]
  node_wasm_api["Wasm Runtime<br/>[index.js]"]
  node_wasm_thresholds["Wasm Thresholds<br/>[thresholds.js]"]
end

node_user(("Library User"))

node_user -->|"imports"| node_entry
node_entry -->|"exports"| node_matrix
node_entry -->|"exports"| node_dr_methods
node_entry -->|"exports"| node_clustering
node_entry -->|"exports"| node_knn
node_user -->|"creates input"| node_matrix
node_user -->|"selects method"| node_dr_methods
node_dr_methods -.->|"extends framework"| node_dr_base
node_user -->|"runs transform"| node_pca
node_user -->|"runs transform"| node_umap
node_user -->|"runs transform"| node_pacmap
node_user -->|"runs transform"| node_mds
node_umap -->|"uses data"| node_matrix
node_umap -->|"uses indices"| node_knn
node_umap -->|"calls kernels"| node_wasm_api
node_pacmap -->|"uses data"| node_matrix
node_pacmap -->|"initializes with"| node_pca
node_pacmap -->|"initializes with"| node_mds
node_pacmap -->|"queries neighbors"| node_knn
node_hnsw -->|"implements index"| node_knn
node_clustering -->|"exports base"| node_cluster_base
node_clustering -->|"exports algorithm"| node_kmeans
node_kmeans -.->|"processes data"| node_matrix
node_matrix -->|"uses eigen solver"| node_linear
node_matrix -->|"uses generator"| node_random
node_matrix -->|"checks thresholds"| node_wasm_thresholds
node_matrix -->|"calls kernels"| node_wasm_api
node_wasm_api -.->|"configures dispatch"| node_wasm_thresholds
node_user -->|"runs algorithm"| node_clustering
node_user -->|"searches neighbors"| node_hnsw

click node_entry "https://github.com/saehm/druidjs/blob/master/src/index.js"
click node_matrix "https://github.com/saehm/druidjs/blob/master/src/matrix/Matrix.js"
click node_dr_base "https://github.com/saehm/druidjs/blob/master/src/dimred/DR.js"
click node_dr_methods "https://github.com/saehm/druidjs/tree/master/src/dimred"
click node_pca "https://github.com/saehm/druidjs/blob/master/src/dimred/PCA.js"
click node_mds "https://github.com/saehm/druidjs/blob/master/src/dimred/MDS.js"
click node_umap "https://github.com/saehm/druidjs/blob/master/src/dimred/UMAP.js"
click node_pacmap "https://github.com/saehm/druidjs/blob/master/src/dimred/PaCMAP.js"
click node_knn "https://github.com/saehm/druidjs/tree/master/src/knn"
click node_hnsw "https://github.com/saehm/druidjs/blob/master/src/knn/HNSW.js"
click node_clustering "https://github.com/saehm/druidjs/tree/master/src/clustering"
click node_cluster_base "https://github.com/saehm/druidjs/blob/master/src/clustering/Clustering.js"
click node_kmeans "https://github.com/saehm/druidjs/blob/master/src/clustering/KMeans.js"
click node_metrics "https://github.com/saehm/druidjs/tree/master/src/metrics"
click node_linear "https://github.com/saehm/druidjs/tree/master/src/linear_algebra"
click node_random "https://github.com/saehm/druidjs/blob/master/src/util/randomizer.js"
click node_mst "https://github.com/saehm/druidjs/blob/master/src/util/minimum_spanning_tree.js"
click node_wasm_api "https://github.com/saehm/druidjs/blob/master/src/wasm/index.js"
click node_wasm_thresholds "https://github.com/saehm/druidjs/blob/master/src/wasm/thresholds.js"

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_entry,node_user toneBlue
class node_dr_base,node_dr_methods,node_pca,node_mds,node_umap,node_pacmap toneAmber
class node_knn,node_hnsw,node_clustering,node_cluster_base,node_kmeans toneMint
class node_matrix,node_metrics,node_linear,node_random,node_mst toneRose
class node_wasm_api,node_wasm_thresholds toneIndigo
```

## Components

### Public API

- [Public Exports](https://github.com/saehm/druidjs/blob/master/src/index.js): `src/index.js`

### Dimensionality Reduction

- [DR Framework](https://github.com/saehm/druidjs/blob/master/src/dimred/DR.js): `src/dimred/DR.js`
- [Reduction Methods](https://github.com/saehm/druidjs/tree/master/src/dimred): `src/dimred`
- [PCA](https://github.com/saehm/druidjs/blob/master/src/dimred/PCA.js): `src/dimred/PCA.js`
- [MDS](https://github.com/saehm/druidjs/blob/master/src/dimred/MDS.js): `src/dimred/MDS.js`
- [UMAP](https://github.com/saehm/druidjs/blob/master/src/dimred/UMAP.js): `src/dimred/UMAP.js`
- [PaCMAP](https://github.com/saehm/druidjs/blob/master/src/dimred/PaCMAP.js): `src/dimred/PaCMAP.js`

### Data Analysis

- [Neighbor Indices](https://github.com/saehm/druidjs/tree/master/src/knn): `src/knn`
- [HNSW](https://github.com/saehm/druidjs/blob/master/src/knn/HNSW.js): `src/knn/HNSW.js`
- [Clustering Algorithms](https://github.com/saehm/druidjs/tree/master/src/clustering): `src/clustering`
- [Clustering Base](https://github.com/saehm/druidjs/blob/master/src/clustering/Clustering.js): `src/clustering/Clustering.js`
- [K-Means](https://github.com/saehm/druidjs/blob/master/src/clustering/KMeans.js): `src/clustering/KMeans.js`

### Numerical Foundations

- [Matrix Data](https://github.com/saehm/druidjs/blob/master/src/matrix/Matrix.js): `src/matrix/Matrix.js`
- [Distance Metrics](https://github.com/saehm/druidjs/tree/master/src/metrics): `src/metrics`
- [Linear Algebra](https://github.com/saehm/druidjs/tree/master/src/linear_algebra): `src/linear_algebra`
- [Randomizer](https://github.com/saehm/druidjs/blob/master/src/util/randomizer.js): `src/util/randomizer.js`
- [Spanning Tree](https://github.com/saehm/druidjs/blob/master/src/util/minimum_spanning_tree.js): `src/util/minimum_spanning_tree.js`

### WebAssembly Acceleration

- [Wasm Runtime](https://github.com/saehm/druidjs/blob/master/src/wasm/index.js): `src/wasm/index.js`
- [Wasm Thresholds](https://github.com/saehm/druidjs/blob/master/src/wasm/thresholds.js): `src/wasm/thresholds.js`

### Other components

- **Library User**

## Connections

- Library User → Public Exports: imports
- Public Exports → Matrix Data: exports (evidence: `src/index.js`)
- Public Exports → Reduction Methods: exports (evidence: `src/index.js`)
- Public Exports → Clustering Algorithms: exports (evidence: `src/index.js`)
- Public Exports → Neighbor Indices: exports (evidence: `src/index.js`)
- Library User → Matrix Data: creates input
- Library User → Reduction Methods: selects method
- Reduction Methods → DR Framework: extends framework (evidence: `src/dimred/PaCMAP.js`)
- Library User → PCA: runs transform
- Library User → UMAP: runs transform
- Library User → PaCMAP: runs transform
- Library User → MDS: runs transform
- UMAP → Matrix Data: uses data (evidence: `src/dimred/UMAP.js`)
- UMAP → Neighbor Indices: uses indices (evidence: `src/dimred/UMAP.js`)
- UMAP → Wasm Runtime: calls kernels (evidence: `src/dimred/UMAP.js`)
- PaCMAP → Matrix Data: uses data (evidence: `src/dimred/PaCMAP.js`)
- PaCMAP → PCA: initializes with (evidence: `src/dimred/PaCMAP.js`)
- PaCMAP → MDS: initializes with (evidence: `src/dimred/PaCMAP.js`)
- PaCMAP → Neighbor Indices: queries neighbors (evidence: `src/dimred/PaCMAP.js`)
- HNSW → Neighbor Indices: implements index (evidence: `src/knn/index.js`)
- Clustering Algorithms → Clustering Base: exports base (evidence: `src/clustering/index.js`)
- Clustering Algorithms → K-Means: exports algorithm (evidence: `src/clustering/index.js`)
- K-Means → Matrix Data: processes data
- Matrix Data → Linear Algebra: uses eigen solver (evidence: `src/matrix/Matrix.js`)
- Matrix Data → Randomizer: uses generator (evidence: `src/matrix/Matrix.js`)
- Matrix Data → Wasm Thresholds: checks thresholds (evidence: `src/matrix/Matrix.js`)
- Matrix Data → Wasm Runtime: calls kernels (evidence: `src/matrix/Matrix.js`)
- Wasm Runtime → Wasm Thresholds: configures dispatch
- Library User → Clustering Algorithms: runs algorithm
- Library User → HNSW: searches neighbors
