# hedgehogdubz/riverml-machine-learning-pipeline architecture

> Architecture diagram of the GitHub repository hedgehogdubz/riverml-machine-learning-pipeline, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hedgehogdubz/riverml-machine-learning-pipeline
- Repository: https://github.com/hedgehogdubz/riverml-machine-learning-pipeline

## Overview

#### Purpose and Compatibility Contract
RiverML is a lightweight, visual ML training and inference pipeline with equivalent C++ and TypeScript implementations. Models are trained interactively, serialized to portable seed strings, then reconstructed for low-overhead inference in either runtime. Cross-language seed compatibility is the central contract.

- `README.md`
- `CPP Desktop Version/neuralnetwork.h`
- `Typescript Web Version/neuralnetwork.ts`

#### Two Application Entry Points
The repository ships two independently runnable visualizers rather than a shared service/backend.

- Native desktop application: `CPP Desktop Version/main.cpp`, built through `CPP Desktop Version/Makefile`; uses C++23 and raylib.
- Browser application: `Typescript Web Version/index.ts`, loaded by `Typescript Web Version/index.html` and styled via `Typescript Web Version/index.css`. Its checked-in bundle is `Typescript Web Version/dist/bundle.js`.

#### Interactive Training and Visualization Layer
Each entry point owns UI state, user-editable model architecture/training settings, live training iterations, and rendering of model/data views. The UI is a boundary around the model APIs: it creates, trains, exports, loads, and runs models, while model implementations remain usable without a visualizer.

- `CPP Desktop Version/main.cpp`
- `Typescript Web Version/index.ts`

#### Neural Network Engine
The neural-network implementation provides configurable layer shapes and activations, prediction, training methods, and seed serialization/deserialization. Construction from a seed parses once and retains model parameters, making subsequent `run()` calls arithmetic-only.

- `CPP Desktop Version/neuralnetwork.h`
- `Typescript Web Version/neuralnetwork.ts`

#### Tree and Boosting Engine
XGBoost-style ensembles are modeled separately from neural networks. Decision trees provide the structural prediction primitive; the boosting layer manages trees, output aggregation, training, and `XGBSEED1` serialization. The UI selects behavior based on the loaded seed type.

- `CPP Desktop Version/decisiontree.h`
- `CPP Desktop Version/xgboost.h`
- `Typescript Web Version/decisiontree.ts`
- `Typescript Web Version/xgboost.ts`

#### Seed Exchange and Inference Boundary
Seeds are the portable artifact between training and deployment: `NNSEED1` carries network topology/parameters, while `XGBSEED1` carries ensemble metadata and trees. Both language implementations expose model construction from a seed and `run(inputs)` inference, enabling headers or TypeScript modules to be embedded in other applications without the UI.

- `CPP Desktop Version/neuralnetwork.h`
- `CPP Desktop Version/xgboost.h`
- `Typescript Web Version/neuralnetwork.ts`
- `Typescript Web Version/xgboost.ts`

#### Runtime and Deployment
The desktop runtime depends on raylib and produces an `mlvisualizer` executable. The TypeScript runtime executes entirely in the browser, is package-managed through npm, and is intended for GitHub Pages deployment. GitHub Actions contains static-site workflow infrastructure.

- `CPP Desktop Version/Makefile`
- `Typescript Web Version/package.json`
- `.github/workflows/static.yml`

Main entry points: [`Typescript Web Version/dist/bundle.js`](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/dist/bundle.js) (Checked-in bundle), [`CPP Desktop Version/main.cpp`](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/CPP%20Desktop%20Version/main.cpp) (Desktop visualizer), [`CPP Desktop Version/xgboost.h`](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/CPP%20Desktop%20Version/xgboost.h) (C++ boosting ensemble), [`Typescript Web Version/index.ts`](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/index.ts) (Browser visualizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_native["C++ Desktop"]
  node_cpp_build["Desktop build<br/>C++23/raylib build"]
  node_cpp_ui["Desktop visualizer<br/>interactive application<br/>[main.cpp]"]
  node_cpp_nn["C++ neural network<br/>model engine<br/>[neuralnetwork.h]"]
  node_cpp_tree["C++ decision tree<br/>prediction primitive<br/>[decisiontree.h]"]
  node_cpp_xgb["C++ boosting ensemble<br/>model engine<br/>[xgboost.h]"]
end

subgraph group_browser["TypeScript Browser"]
  node_html_shell["Browser page shell<br/>HTML entry<br/>[index.html]"]
  node_ts_ui["Browser visualizer<br/>interactive application<br/>[index.ts]"]
  node_css["Browser styling<br/>stylesheet<br/>[index.css]"]
  node_bundle["Checked-in bundle<br/>browser bundle<br/>[bundle.js]"]
  node_ts_nn["TypeScript neural network<br/>model engine<br/>[neuralnetwork.ts]"]
  node_ts_tree["TypeScript decision tree<br/>prediction primitive<br/>[decisiontree.ts]"]
  node_ts_xgb["TypeScript boosting ensemble<br/>model engine<br/>[xgboost.ts]"]
  node_npm["Browser package runtime<br/>npm package manifest<br/>[package.json]"]
  node_pages_workflow["Static-site workflow<br/>GitHub Actions workflow<br/>[static.yml]"]
end

subgraph group_exchange["Portable Model Contract"]
  node_nn_seed["NNSEED1<br/>portable network seed"]
  node_xgb_seed["XGBSEED1<br/>portable ensemble seed"]
end

node_readme["Project contract<br/>documentation<br/>[README.md]"]

node_readme -.->|"defines compatibility"| node_nn_seed
node_readme -.->|"defines compatibility"| node_xgb_seed
node_cpp_build -->|"builds"| node_cpp_ui
node_cpp_ui -->|"trains and runs"| node_cpp_nn
node_cpp_ui -->|"trains and runs"| node_cpp_xgb
node_cpp_xgb -->|"manages"| node_cpp_tree
node_cpp_nn -->|"exports / imports"| node_nn_seed
node_cpp_xgb -->|"exports / imports"| node_xgb_seed
node_html_shell -->|"loads"| node_bundle
node_css -->|"styles"| node_html_shell
node_bundle -->|"contains"| node_ts_ui
node_npm -->|"packages"| node_bundle
node_ts_ui -->|"trains and runs"| node_ts_nn
node_ts_ui -->|"trains and runs"| node_ts_xgb
node_ts_xgb -->|"manages"| node_ts_tree
node_ts_nn -->|"exports / imports"| node_nn_seed
node_ts_xgb -->|"exports / imports"| node_xgb_seed
node_pages_workflow -->|"deploys"| node_bundle

click node_readme "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/README.md"
click node_cpp_build "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/CPP%20Desktop%20Version/Makefile"
click node_cpp_ui "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/CPP%20Desktop%20Version/main.cpp"
click node_cpp_nn "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/CPP%20Desktop%20Version/neuralnetwork.h"
click node_cpp_tree "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/CPP%20Desktop%20Version/decisiontree.h"
click node_cpp_xgb "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/CPP%20Desktop%20Version/xgboost.h"
click node_html_shell "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/index.html"
click node_ts_ui "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/index.ts"
click node_css "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/index.css"
click node_bundle "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/dist/bundle.js"
click node_ts_nn "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/neuralnetwork.ts"
click node_ts_tree "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/decisiontree.ts"
click node_ts_xgb "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/xgboost.ts"
click node_npm "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/package.json"
click node_pages_workflow "https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/.github/workflows/static.yml"

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_cpp_build,node_cpp_ui,node_cpp_nn,node_cpp_tree,node_cpp_xgb toneBlue
class node_html_shell,node_ts_ui,node_css,node_bundle,node_ts_nn,node_ts_tree,node_ts_xgb,node_npm,node_pages_workflow toneAmber
class node_nn_seed,node_xgb_seed toneMint
class node_readme toneNeutral
```

## Components

### C++ Desktop

- [Desktop build](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/CPP%20Desktop%20Version/Makefile): C++23/raylib build · Builds the mlvisualizer executable. · `CPP Desktop Version/Makefile`
- [Desktop visualizer](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/CPP%20Desktop%20Version/main.cpp): interactive application · Owns editable settings, training, rendering, seed import, and inference. · `CPP Desktop Version/main.cpp`
- [C++ neural network](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/CPP%20Desktop%20Version/neuralnetwork.h): model engine · Configurable network training, prediction, and NNSEED1 import/export. · `CPP Desktop Version/neuralnetwork.h`
- [C++ decision tree](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/CPP%20Desktop%20Version/decisiontree.h): prediction primitive · `CPP Desktop Version/decisiontree.h`
- [C++ boosting ensemble](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/CPP%20Desktop%20Version/xgboost.h): model engine · Manages trees, aggregation, training, and XGBSEED1 import/export. · `CPP Desktop Version/xgboost.h`

### TypeScript Browser

- [Browser page shell](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/index.html): HTML entry · `Typescript Web Version/index.html`
- [Browser visualizer](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/index.ts): interactive application · Owns editable settings, training, rendering, seed import, and inference. · `Typescript Web Version/index.ts`
- [Browser styling](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/index.css): stylesheet · `Typescript Web Version/index.css`
- [Checked-in bundle](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/dist/bundle.js): browser bundle · `Typescript Web Version/dist/bundle.js`
- [TypeScript neural network](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/neuralnetwork.ts): model engine · Configurable network training, prediction, and NNSEED1 import/export. · `Typescript Web Version/neuralnetwork.ts`
- [TypeScript decision tree](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/decisiontree.ts): prediction primitive · `Typescript Web Version/decisiontree.ts`
- [TypeScript boosting ensemble](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/xgboost.ts): model engine · Manages trees, aggregation, training, and XGBSEED1 import/export. · `Typescript Web Version/xgboost.ts`
- [Browser package runtime](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/Typescript%20Web%20Version/package.json): npm package manifest · `Typescript Web Version/package.json`
- [Static-site workflow](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/.github/workflows/static.yml): GitHub Actions workflow · Supports GitHub Pages deployment. · `.github/workflows/static.yml`

### Portable Model Contract

Seed formats keep trained models compatible across both runtimes.

- **NNSEED1**: portable network seed · Topology and learned neural-network parameters.
- **XGBSEED1**: portable ensemble seed · Boosting metadata and serialized trees.

### Other components

- [Project contract](https://github.com/hedgehogdubz/riverml-machine-learning-pipeline/blob/main/README.md): documentation · Defines the cross-language seed compatibility goal. · `README.md`

## Connections

- Project contract → NNSEED1: defines compatibility
- Project contract → XGBSEED1: defines compatibility
- Desktop build → Desktop visualizer: builds
- Desktop visualizer → C++ neural network: trains and runs
- Desktop visualizer → C++ boosting ensemble: trains and runs
- C++ boosting ensemble → C++ decision tree: manages
- C++ neural network → NNSEED1: exports / imports
- C++ boosting ensemble → XGBSEED1: exports / imports
- Browser page shell → Checked-in bundle: loads
- Browser styling → Browser page shell: styles
- Checked-in bundle → Browser visualizer: contains
- Browser package runtime → Checked-in bundle: packages
- Browser visualizer → TypeScript neural network: trains and runs
- Browser visualizer → TypeScript boosting ensemble: trains and runs
- TypeScript boosting ensemble → TypeScript decision tree: manages
- TypeScript neural network → NNSEED1: exports / imports
- TypeScript boosting ensemble → XGBSEED1: exports / imports
- Static-site workflow → Checked-in bundle: deploys
