# lvlath/go architecture

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

- Interactive diagram: https://gitdiagram.com/lvlath/go
- Repository: https://github.com/lvlath/go

## Overview

lvlath is a deterministic, contract-driven Go algorithm library, not a single application. A typical workflow is a caller choosing a package and explicit policy, supplying validated inputs, invoking its algorithm, and receiving a result or classified error. The packages cover graph construction and analysis, time-series and statistical transforms, modeling, and reproducible simulation. The graph groups major capabilities rather than enumerating every package. Edges are limited to relationships evidenced by the excerpts or README; unsampled package internals and cross-package wiring are not inferred.

Main entry points: [`matrix/api.go`](https://github.com/lvlath/go/blob/main/matrix/api.go) (Dense graph algebra), [`rng`](https://github.com/lvlath/go/tree/main/rng) (Deterministic RNG), [`flow/api.go`](https://github.com/lvlath/go/blob/main/flow/api.go) (Network flow), [`ols/predict.go`](https://github.com/lvlath/go/blob/main/ols/predict.go) (Linear regression)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_graphs["Graphs and optimization"]
  node_core["Graph topology<br/>[methods_edges.go]"]
  node_builder["Graph builders"]
  node_traversal["Graph traversal"]
  node_routing["Weighted routing"]
  node_matrix["Dense graph algebra<br/>[api.go]"]
  node_flow["Network flow<br/>[api.go]"]
  node_networkopt["Network optimization"]
end

subgraph group_series["Series and symbols"]
  node_series["Series transforms"]
  node_paa["Fractional PAA"]
  node_sax["Symbolic SAX<br/>[encoder.go]"]
  node_tfsax["Retrieval audits"]
end

subgraph group_models["Statistics and models"]
  node_stats["Moments and autocorrelation"]
  node_regression["Linear regression<br/>[predict.go]"]
  node_ridge["Ridge regression<br/>[fit.go]"]
  node_pca["Covariance PCA<br/>[spectrum.go]"]
  node_hmm["Hidden Markov models<br/>[em_gaussian.go]"]
  node_timeseriesmodels["Time-series models"]
  node_lstm["LSTM inference"]
end

subgraph group_signals["Market indicators"]
  node_indicators["Causal market indicators"]
end

subgraph group_simulation["Randomness and simulation"]
  node_rng["Deterministic RNG"]
  node_bootstrap["Block resampling<br/>[api.go]"]
  node_montecarlo["Parallel Monte Carlo<br/>[worker.go]"]
  node_pathsim["Financial path simulation<br/>[poisson.go]"]
end

node_caller(("Go caller"))

node_caller -->|"builds graphs"| node_builder
node_caller -->|"transforms data"| node_series
node_caller -->|"analyzes data"| node_stats
node_caller -->|"fits or predicts"| node_regression
node_caller -->|"computes indicators"| node_indicators
node_caller -->|"resamples indices"| node_bootstrap
node_caller -->|"runs simulations"| node_montecarlo
node_caller -->|"runs inference"| node_lstm
node_flow -->|"reads graph"| node_core
node_flow -->|"builds capacity matrix"| node_matrix
node_sax -->|"encodes PAA"| node_paa
node_pca -->|"uses eigensolver"| node_matrix
node_ridge -->|"uses QR"| node_matrix
node_regression -->|"reads matrix"| node_matrix
node_hmm -->|"builds dense matrices"| node_matrix
node_bootstrap -->|"creates streams"| node_rng
node_montecarlo -->|"creates path streams"| node_rng
node_pathsim -->|"samples counts"| node_rng
node_networkopt -->|"uses distance matrix"| node_matrix

click node_core "https://github.com/lvlath/go/blob/main/core/methods_edges.go"
click node_builder "https://github.com/lvlath/go/tree/main/builder"
click node_traversal "https://github.com/lvlath/go/tree/main/bfs"
click node_routing "https://github.com/lvlath/go/tree/main/dijkstra"
click node_matrix "https://github.com/lvlath/go/blob/main/matrix/api.go"
click node_flow "https://github.com/lvlath/go/blob/main/flow/api.go"
click node_networkopt "https://github.com/lvlath/go/tree/main/tsp"
click node_series "https://github.com/lvlath/go/tree/main/series"
click node_paa "https://github.com/lvlath/go/tree/main/paa"
click node_sax "https://github.com/lvlath/go/blob/main/sax/encoder.go"
click node_tfsax "https://github.com/lvlath/go/tree/main/tfsax"
click node_stats "https://github.com/lvlath/go/tree/main/stats"
click node_regression "https://github.com/lvlath/go/blob/main/ols/predict.go"
click node_ridge "https://github.com/lvlath/go/blob/main/ridge/fit.go"
click node_pca "https://github.com/lvlath/go/blob/main/pca/spectrum.go"
click node_hmm "https://github.com/lvlath/go/blob/main/hmm/em_gaussian.go"
click node_timeseriesmodels "https://github.com/lvlath/go/tree/main/arima"
click node_indicators "https://github.com/lvlath/go/tree/main/donchian"
click node_rng "https://github.com/lvlath/go/tree/main/rng"
click node_bootstrap "https://github.com/lvlath/go/blob/main/bootstrap/api.go"
click node_montecarlo "https://github.com/lvlath/go/blob/main/montecarlo/worker.go"
click node_pathsim "https://github.com/lvlath/go/blob/main/jumpdiffusion/poisson.go"
click node_lstm "https://github.com/lvlath/go/tree/main/lstm"

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_core,node_builder,node_traversal,node_routing,node_matrix,node_flow,node_networkopt toneBlue
class node_series,node_paa,node_sax,node_tfsax toneAmber
class node_stats,node_regression,node_ridge,node_pca,node_hmm,node_timeseriesmodels,node_lstm toneMint
class node_indicators toneRose
class node_rng,node_bootstrap,node_montecarlo,node_pathsim,node_caller toneIndigo
```

## Components

### Graphs and optimization

- [Graph topology](https://github.com/lvlath/go/blob/main/core/methods_edges.go): `core/methods_edges.go`
- [Graph builders](https://github.com/lvlath/go/tree/main/builder): `builder`
- [Graph traversal](https://github.com/lvlath/go/tree/main/bfs): `bfs`
- [Weighted routing](https://github.com/lvlath/go/tree/main/dijkstra): `dijkstra`
- [Dense graph algebra](https://github.com/lvlath/go/blob/main/matrix/api.go): `matrix/api.go`
- [Network flow](https://github.com/lvlath/go/blob/main/flow/api.go): `flow/api.go`
- [Network optimization](https://github.com/lvlath/go/tree/main/tsp): `tsp`

### Series and symbols

- [Series transforms](https://github.com/lvlath/go/tree/main/series): `series`
- [Fractional PAA](https://github.com/lvlath/go/tree/main/paa): `paa`
- [Symbolic SAX](https://github.com/lvlath/go/blob/main/sax/encoder.go): `sax/encoder.go`
- [Retrieval audits](https://github.com/lvlath/go/tree/main/tfsax): `tfsax`

### Statistics and models

- [Moments and autocorrelation](https://github.com/lvlath/go/tree/main/stats): `stats`
- [Linear regression](https://github.com/lvlath/go/blob/main/ols/predict.go): `ols/predict.go`
- [Ridge regression](https://github.com/lvlath/go/blob/main/ridge/fit.go): `ridge/fit.go`
- [Covariance PCA](https://github.com/lvlath/go/blob/main/pca/spectrum.go): `pca/spectrum.go`
- [Hidden Markov models](https://github.com/lvlath/go/blob/main/hmm/em_gaussian.go): `hmm/em_gaussian.go`
- [Time-series models](https://github.com/lvlath/go/tree/main/arima): `arima`
- [LSTM inference](https://github.com/lvlath/go/tree/main/lstm): `lstm`

### Market indicators

- [Causal market indicators](https://github.com/lvlath/go/tree/main/donchian): `donchian`

### Randomness and simulation

- [Deterministic RNG](https://github.com/lvlath/go/tree/main/rng): `rng`
- [Block resampling](https://github.com/lvlath/go/blob/main/bootstrap/api.go): `bootstrap/api.go`
- [Parallel Monte Carlo](https://github.com/lvlath/go/blob/main/montecarlo/worker.go): `montecarlo/worker.go`
- [Financial path simulation](https://github.com/lvlath/go/blob/main/jumpdiffusion/poisson.go): `jumpdiffusion/poisson.go`

### Other components

- **Go caller**

## Connections

- Go caller → Graph builders: builds graphs (evidence: `README.md`)
- Go caller → Series transforms: transforms data (evidence: `README.md`)
- Go caller → Moments and autocorrelation: analyzes data (evidence: `README.md`)
- Go caller → Linear regression: fits or predicts (evidence: `README.md`)
- Go caller → Causal market indicators: computes indicators (evidence: `README.md`)
- Go caller → Block resampling: resamples indices (evidence: `README.md`)
- Go caller → Parallel Monte Carlo: runs simulations (evidence: `README.md`)
- Go caller → LSTM inference: runs inference (evidence: `README.md`)
- Network flow → Graph topology: reads graph (evidence: `flow/api.go`)
- Network flow → Dense graph algebra: builds capacity matrix (evidence: `flow/api.go`)
- Symbolic SAX → Fractional PAA: encodes PAA (evidence: `sax/encoder.go`)
- Covariance PCA → Dense graph algebra: uses eigensolver (evidence: `pca/spectrum.go`)
- Ridge regression → Dense graph algebra: uses QR (evidence: `ridge/fit.go`)
- Linear regression → Dense graph algebra: reads matrix (evidence: `ols/predict.go`)
- Hidden Markov models → Dense graph algebra: builds dense matrices (evidence: `hmm/em_gaussian.go`)
- Block resampling → Deterministic RNG: creates streams (evidence: `bootstrap/api.go`)
- Parallel Monte Carlo → Deterministic RNG: creates path streams (evidence: `montecarlo/worker.go`)
- Financial path simulation → Deterministic RNG: samples counts (evidence: `jumpdiffusion/poisson.go`)
- Network optimization → Dense graph algebra: uses distance matrix (evidence: `tsp/localsearch_3opt.go`)
