# dhyeybuch/mlplayground architecture

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

- Interactive diagram: https://gitdiagram.com/dhyeybuch/mlplayground
- Repository: https://github.com/dhyeybuch/mlplayground

## Overview

mlplayground is a browser-based playground for exploring linear and logistic models. Users choose a regression or classification dataset, configure training parameters, run training, and inspect plots and results. The browser loads dataset metadata from the FastAPI backend; training requests are split into train/test sets, passed to the selected gradient-descent implementation, and returned with model-specific outputs. The frontend then visualizes the response and exposes generated example code. The README is brief, so the feature scope here is based mainly on the sampled frontend and backend source.

Main entry points: [`frontend/app.js`](https://github.com/dhyeybuch/mlplayground/blob/main/frontend/app.js) (Selection and controls), [`backend/main.py`](https://github.com/dhyeybuch/mlplayground/blob/main/backend/main.py) (Training endpoint), [`frontend/index.html`](https://github.com/dhyeybuch/mlplayground/blob/main/frontend/index.html) (Playground interface), [`backend/datasets.py`](https://github.com/dhyeybuch/mlplayground/blob/main/backend/datasets.py) (Dataset catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser experience"]
  node_interface["Playground interface<br/>[index.html]"]
  node_browser_logic["Selection and controls<br/>[app.js]"]
end

subgraph group_backend["API and data"]
  node_dataset_api["Dataset endpoint<br/>[main.py]"]
  node_dataset_catalog["Dataset catalog<br/>[datasets.py]"]
  node_training_api["Training endpoint<br/>[main.py]"]
end

subgraph group_learning["Model training"]
  node_splitter["Train-test split<br/>[main.py]"]
  node_gradient_models["Gradient descent models<br/>[models.py]"]
  node_result_builder["Model results<br/>[main.py]"]
end

subgraph group_results["Results display"]
  node_visualizations["Plots and curves<br/>[app.js]"]
  node_result_displays["Metrics and code<br/>[app.js]"]
end

node_user(("Playground user"))
node_plotly["Plotly"]

node_user -->|"uses"| node_interface
node_interface -.->|"hosts controls"| node_browser_logic
node_browser_logic -->|"loads datasets"| node_dataset_api
node_dataset_api -->|"loads catalog"| node_dataset_catalog
node_browser_logic -->|"submits training"| node_training_api
node_training_api -->|"finds dataset"| node_dataset_catalog
node_training_api -->|"splits data"| node_splitter
node_training_api -->|"trains selected model"| node_gradient_models
node_training_api -->|"builds response"| node_result_builder
node_browser_logic -->|"plots response"| node_visualizations
node_browser_logic -->|"updates results"| node_result_displays
node_visualizations -->|"renders plots"| node_plotly

click node_interface "https://github.com/dhyeybuch/mlplayground/blob/main/frontend/index.html"
click node_browser_logic "https://github.com/dhyeybuch/mlplayground/blob/main/frontend/app.js"
click node_dataset_api "https://github.com/dhyeybuch/mlplayground/blob/main/backend/main.py"
click node_dataset_catalog "https://github.com/dhyeybuch/mlplayground/blob/main/backend/datasets.py"
click node_training_api "https://github.com/dhyeybuch/mlplayground/blob/main/backend/main.py"
click node_splitter "https://github.com/dhyeybuch/mlplayground/blob/main/backend/main.py"
click node_gradient_models "https://github.com/dhyeybuch/mlplayground/blob/main/backend/models.py"
click node_result_builder "https://github.com/dhyeybuch/mlplayground/blob/main/backend/main.py"
click node_visualizations "https://github.com/dhyeybuch/mlplayground/blob/main/frontend/app.js"
click node_result_displays "https://github.com/dhyeybuch/mlplayground/blob/main/frontend/app.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_interface,node_browser_logic,node_user toneBlue
class node_dataset_api,node_dataset_catalog,node_training_api toneAmber
class node_splitter,node_gradient_models,node_result_builder toneMint
class node_visualizations,node_result_displays toneRose
class node_plotly toneIndigo
```

## Components

### Browser experience

- [Playground interface](https://github.com/dhyeybuch/mlplayground/blob/main/frontend/index.html): `frontend/index.html`
- [Selection and controls](https://github.com/dhyeybuch/mlplayground/blob/main/frontend/app.js): `frontend/app.js`

### API and data

- [Dataset endpoint](https://github.com/dhyeybuch/mlplayground/blob/main/backend/main.py): `backend/main.py`
- [Dataset catalog](https://github.com/dhyeybuch/mlplayground/blob/main/backend/datasets.py): `backend/datasets.py`
- [Training endpoint](https://github.com/dhyeybuch/mlplayground/blob/main/backend/main.py): `backend/main.py`

### Model training

- [Train-test split](https://github.com/dhyeybuch/mlplayground/blob/main/backend/main.py): `backend/main.py`
- [Gradient descent models](https://github.com/dhyeybuch/mlplayground/blob/main/backend/models.py): `backend/models.py`
- [Model results](https://github.com/dhyeybuch/mlplayground/blob/main/backend/main.py): `backend/main.py`

### Results display

- [Plots and curves](https://github.com/dhyeybuch/mlplayground/blob/main/frontend/app.js): `frontend/app.js`
- [Metrics and code](https://github.com/dhyeybuch/mlplayground/blob/main/frontend/app.js): `frontend/app.js`

### Other components

- **Playground user**
- **Plotly**

## Connections

- Playground user → Playground interface: uses
- Playground interface → Selection and controls: hosts controls
- Selection and controls → Dataset endpoint: loads datasets (evidence: `frontend/app.js`)
- Dataset endpoint → Dataset catalog: loads catalog (evidence: `backend/main.py`)
- Selection and controls → Training endpoint: submits training (evidence: `frontend/app.js`)
- Training endpoint → Dataset catalog: finds dataset (evidence: `backend/main.py`)
- Training endpoint → Train-test split: splits data (evidence: `backend/main.py`)
- Training endpoint → Gradient descent models: trains selected model (evidence: `backend/main.py`)
- Training endpoint → Model results: builds response (evidence: `backend/main.py`)
- Selection and controls → Plots and curves: plots response (evidence: `frontend/app.js`)
- Selection and controls → Metrics and code: updates results (evidence: `frontend/app.js`)
- Plots and curves → Plotly: renders plots (evidence: `frontend/app.js`)
