Skip to content

DevilsDev/NeuroViz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

294 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NeuroViz

CI/CD License

Interactive neural network decision-boundary visualiser. Build, train, and inspect small neural networks in the browser β€” watch the decision boundary evolve epoch by epoch, flip between 2D and 3D views, follow gradient flow, and export trained models. Built with Hexagonal Architecture (Ports & Adapters) so the ML core has no dependency on TensorFlow.js, D3, or the DOM.

πŸ”— Live Demo πŸ“˜ Feature Guide Β· Architecture Β· Roadmap

Status. All 9 feature phases and the 5-phase improvement roadmap are complete (99 features shipped, architecture consolidated). See docs/ROADMAP.md for the full delivery status and docs/archive/ for historical audit reports.


What ships today

Training & model

  • Optimizers β€” SGD (with momentum), Adam, RMSprop, Adagrad
  • Regularisation β€” L1, L2, dropout (per-layer), batch normalisation, gradient clipping
  • Learning-rate control β€” exponential / step / cosine schedules, warmup, cyclic LR (triangle + cosine), LR finder with sensitivity curve
  • Training flow β€” configurable batch size, epoch limit, FPS-capped training speed, early stopping on validation-loss patience, train/validation split, step-by-step single-epoch mode
  • Activations β€” ReLU, Sigmoid, Tanh, ELU, with per-layer selection
  • Multi-class classification up to 10 classes via softmax output

Datasets

  • Built-in patterns β€” Circle, XOR, Spiral, Gaussian clusters, N-cluster blobs
  • Real-world samples β€” Iris and Wine (PCA-reduced to 2D, bundled)
  • Custom input β€” draw your own points by clicking, or upload CSV
  • Controls β€” noise level, sample count, class-imbalance ratio, feature normalisation + standardisation toggles, train/test split visualisation

Visualisation

  • Real-time decision boundary with colour-scheme presets (default, viridis, plasma, cool, warm), heatmap opacity and contour-count sliders, misclassified-point highlighting, confidence circles
  • Interactive chart β€” zoom, pan, hover tooltips, click-for-prediction details
  • 3D view (Three.js) β€” height encodes prediction confidence
  • Network diagram β€” interactive D3 node graph with weight-magnitude colour coding
  • Activation heatmaps β€” per-layer neuron activations in real time
  • Voronoi overlay β€” alternative boundary view
  • Gradient flow animation β€” backprop visualisation
  • Boundary evolution recording β€” record and replay training

Metrics & analysis

  • Loss chart β€” training loss + dashed validation loss overlay
  • Accuracy, precision, recall, F1 (macro-averaged)
  • Confusion matrix heatmap
  • ROC curve with AUC (binary classification)
  • Training history with JSON + CSV export
  • Weight histograms and model-complexity metrics
  • Overfitting / underfitting detection with suggested fixes

Export & persistence

  • Model download / upload β€” TensorFlow.js JSON + weights format
  • ONNX export for cross-platform use
  • Python codegen β€” produces a matching Keras/TensorFlow script
  • Image export β€” PNG, SVG, and screenshot-with-metadata overlay
  • Session save/load β€” auto-save to localStorage
  • Shareable config code β€” copy/paste Base64 string

UX & modes

  • Learn / Experiment / Advanced mode selector (persisted) β€” progressively reveals controls as the user graduates between surfaces
  • Preset configurations β€” five quick-start templates + bookmarkable named presets
  • Guided tutorials and challenge mode for self-directed learning
  • ELI5 tooltips on hyperparameters
  • Keyboard shortcuts β€” Space, S, R, F, Escape
  • Dark / light theme, fullscreen mode, responsive mobile layout
  • Browser notifications on training completion

Advanced & research

  • Model comparison (A/B) panel β€” side-by-side training runs
  • Model ensemble voting visualisation
  • Feature importance (permutation), LIME-style explanations, saliency maps
  • Adversarial examples (FGSM), Bayesian NNs (MC Dropout), neural architecture search
  • Web-Worker-backed training for a non-blocking UI
  • WebGL-accelerated rendering and progressive grid chunking
  • REST API via window.neurovizAPI, WebSocket live collaboration, plugin system for custom extensions

A full per-feature reference lives in docs/FEATURES.md. Delivery status by phase is tracked in docs/ROADMAP.md.


Architecture

NeuroViz follows Hexagonal Architecture (Ports & Adapters). Core business logic has zero dependency on TensorFlow.js, D3, Three.js, or the DOM β€” adapters live at the edges and are wired up in a composition root.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Presentation                             β”‚
β”‚        (controllers, modals, toast, workflow UI)                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Composition Root                           β”‚
β”‚                (main.ts + ApplicationBuilder)                    β”‚
β”‚         Wires adapters to ports via dependency injection        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β–Ό                   β–Ό                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   TFNeuralNet   β”‚ β”‚    D3Chart      β”‚ β”‚ DatasetRepo     β”‚
β”‚  (TensorFlow.js)β”‚ β”‚ (D3 + Three.js) β”‚ β”‚  (mock + real)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ implements        β”‚ implements        β”‚ implements
         β–Ό                   β–Ό                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ INeuralNetwork  β”‚ β”‚  IVisualizer    β”‚ β”‚ IDatasetRepo    β”‚
β”‚    Service      β”‚ β”‚    Service      β”‚ β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          Core                                   β”‚
β”‚   Domain (entities)  Β·  Ports (interfaces)  Β·  Application      β”‚
β”‚   TrainingSession facade β†’ SessionStateStore,                    β”‚
β”‚   DatasetPreparationService, ExperimentService, LRFinderService  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

See docs/ARCHITECTURE.md for the full layer breakdown, port contracts, and extension points.

Project structure

src/
β”œβ”€β”€ core/                    # Framework-agnostic business logic
β”‚   β”œβ”€β”€ domain/              # Point, Prediction, Hyperparameters, ...
β”‚   β”œβ”€β”€ ports/               # INeuralNetworkService, IVisualizerService, ...
β”‚   └── application/         # TrainingSession facade + extracted services
β”‚       └── training/        # SessionStateStore, DatasetPrep, Experiment, LRFinder
β”‚
β”œβ”€β”€ infrastructure/          # Framework-specific adapters
β”‚   β”œβ”€β”€ tensorflow/          # TFNeuralNet (TensorFlow.js)
β”‚   β”œβ”€β”€ d3/                  # D3Chart, Voronoi, gradient flow
β”‚   β”œβ”€β”€ three/               # 3D boundary view (Three.js)
β”‚   β”œβ”€β”€ api/                 # Dataset repositories
β”‚   └── education/           # Tutorials, challenges, explain-this-moment
β”‚
β”œβ”€β”€ presentation/            # Controllers, modals, toasts, workflow UI
└── main.ts                  # Composition root

Key design decisions

Decision Rationale
Ports & Adapters Core logic never imports TensorFlow.js, D3, or Three.js.
Constructor injection All dependencies arrive via TrainingSession facade.
Service extraction TrainingSession delegates to four SRP services.
Async training loop Guard-rail pattern prevents overlapping GPU calls.
Immutable domain Point, Prediction, Hyperparameters are readonly.
Observer state fan-out Controllers subscribe via onStateChange, never poll.

Getting started

Prerequisites

  • Node.js 20+ (LTS recommended)
  • npm 10+

Installation

git clone https://github.com/DevilsDev/NeuroViz.git
cd NeuroViz
npm install
npm run dev

The app will open at http://localhost:3000.

Available scripts

Command Description
npm run dev Start development server with hot reload
npm run build Build for production
npm run preview Preview production build locally
npm run typecheck Run TypeScript type checking
npm test Run unit tests (Vitest)
npm run test:coverage Run tests with coverage report
npm run test:e2e Run E2E tests (Playwright)
npm run test:e2e:ui Run E2E tests with interactive UI

How to use

  1. Pick a dataset β€” Circle, XOR, Spiral, Gaussian, Clusters, Iris, Wine, or draw your own.
  2. Pick a preset (optional) β€” five quick-start configurations cover common learning scenarios.
  3. Configure the network β€” set optimizer, learning rate, hidden layers (e.g. 8, 4), activation, regularisation, batch size.
  4. Initialise β€” creates the model with the chosen hyperparameters.
  5. Train β€” click Start to run the training loop, or Step to advance one epoch at a time.
  6. Observe β€” watch the boundary, loss chart, confusion matrix, activation heatmaps, and gradient flow update in real time.
  7. Analyse β€” flip to the Analyze tab for confusion matrix, precision / recall / F1, and model-complexity metrics.
  8. Export β€” save the model, the session, an image, or generate Python code.

New users should stay in Learn Mode (the default) to see a calm subset of controls. Experiment and Advanced modes progressively reveal regularisation, LR-schedule, gradient flow, and research tools.


Tech stack

Layer Technology
ML framework TensorFlow.js
2D visualisation D3.js
3D visualisation Three.js
Styling CSS variables + Tailwind CSS
Build tool Vite
Unit testing Vitest
E2E testing Playwright
Language TypeScript 5.6

Testing strategy

Unit tests (Vitest)

npm test

Coverage focuses on:

  • TrainingSession orchestration and lifecycle transitions
  • Port contract compliance
  • Domain entity validation
  • Application-layer services (early stopping, LR scheduling, data split)
  • Presentation controllers (with mocked ports)

E2E tests (Playwright)

Full browser tests across Chromium, Firefox, and WebKit:

npm run test:e2e

Test categories:

  • Happy path β€” full training cycle, pause/resume, reset
  • Deterministic datasets β€” seeded mock repository
  • Mode switching β€” Learn / Experiment / Advanced
  • Export flows β€” model, image, session
  • Accessibility β€” keyboard navigation, ARIA labels

CI/CD pipeline

The GitHub Actions workflow runs on every push and PR:

  1. Lint & type check β€” ESLint + tsc --noEmit
  2. Unit tests β€” Vitest with coverage
  3. Build β€” Vite production build
  4. E2E tests β€” Playwright across Chromium, Firefox, WebKit
  5. Deploy β€” GitHub Pages (main branch only)

Roadmap

All 9 feature phases (99 features) and the 5-phase improvement roadmap are complete:

  • Phases 1–9 β€” Training, metrics, visualisation, data management, model capabilities, UX, education, performance, research features
  • Improvement Phase 2 β€” Repo hygiene, README reconciliation
  • Improvement Phase 3 β€” State cues (stale badge, validation badge, dataset source label, WebGL banner), Learn Mode data-min-mode expansion
  • Improvement Phase 4 β€” First-run onboarding modal, workflow spine (Prepare β†’ Configure β†’ Train β†’ Analyze), Learn Mode presets + captions
  • Improvement Phase 5 β€” TrainingSession extraction into SessionStateStore, DatasetPreparationService, ExperimentService
  • Improvement Phase 6 β€” LRFinderService extraction, docs polish

Full per-feature status lives in docs/ROADMAP.md. Historical audit reports are archived under docs/archive/.


Extending the application

Adding a new ML backend

  1. Create an adapter implementing INeuralNetworkService:
// src/infrastructure/onnx/ONNXNeuralNet.ts
export class ONNXNeuralNet implements INeuralNetworkService {
  async initialize(config: Hyperparameters): Promise<void> { /* ... */ }
  async train(data: Point[]): Promise<number> { /* ... */ }
  async predict(grid: Point[]): Promise<Prediction[]> { /* ... */ }
}
  1. Swap the adapter in ApplicationBuilder:
// const neuralNetService = new TFNeuralNet();
const neuralNetService = new ONNXNeuralNet();

No changes required in TrainingSession or any core logic.

Adding a new visualisation

  1. Implement IVisualizerService:
// src/infrastructure/canvas/CanvasChart.ts
export class CanvasChart implements IVisualizerService {
  renderData(points: Point[]): void { /* ... */ }
  renderBoundary(predictions: Prediction[], gridSize: number): void { /* ... */ }
}
  1. Inject in ApplicationBuilder:
const visualizerService = new CanvasChart('viz-container', 500, 500);

License

Apache 2.0 Β· DevilsDev

See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors