# vyuh-tech/vyuh_node_flow architecture

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

- Interactive diagram: https://gitdiagram.com/vyuh-tech/vyuh_node_flow
- Repository: https://github.com/vyuh-tech/vyuh_node_flow

## Overview

1. **Repository shape**
   - This is a Dart/Flutter monorepo with three main surfaces: the reusable **`vyuh_node_flow`** library, the **`demo`** Flutter app, and a **VitePress documentation website**.
   - The core architectural boundary is that the demo and website consume the library; they do not define editor behavior themselves.

2. **Core product boundary: `packages/vyuh_node_flow`**
   - This package is the actual node-flow editor framework.
   - Its public API is organized around a small set of top-level entrypoints (`controller`, `editor`, `nodes`, `ports`, `connections`, `plugins`, `viewport`, `themes`, `utilities`) that re-export deeper implementation modules.

3. **Domain model**
   - The core graph model is split into **nodes, ports, connections, and viewport** under `lib/src/graph`, `lib/src/nodes`, `lib/src/ports`, and `lib/src/connections`.
   - Spatial concerns are first-class: there is a dedicated **spatial index/grid layer** for hit testing and large-graph performance.
   - Generated `.g.dart` files and JSON converters indicate that some model types are serializable and code-generated rather than handwritten.

4. **Editor runtime**
   - The heart of the system is `NodeFlowEditor` and `NodeFlowViewer` in `lib/src/editor`.
   - The editor layer owns interaction state: dragging, resizing, selection, viewport changes, auto-pan, keyboard actions, and hit testing.
   - A `NodeFlowController` acts as the orchestration boundary between UI events and graph mutations, with separate APIs for nodes, connections, groups, viewport, resize, and dirty tracking.

5. **Rendering pipeline**
   - Rendering is layered rather than monolithic: grid, connections, connection labels, nodes, interaction overlays, minimap/thumbnail, and attribution each live in separate editor layers.
   - Dedicated painters and caches exist for connection paths, endpoints, labels, selection, and spatial debug overlays, which is important for diagramming the runtime flow from state to paint.

6. **Nodes, ports, and connection system**
   - Node presentation is highly customizable through node shapes, resizable/groupable mixins, special nodes, and node themes.
   - Ports have their own widget/theme/geometry stack, while connections have multiple styles, endpoint calculators, path caches, validation rules, labels, and animated effects.
   - This means node-to-node wiring is not just visual; it is a typed, validated graph edge system with independent styling and behavior.

7. **Plugin architecture**
   - The library has an explicit plugin subsystem in `lib/src/plugins`.
   - Built-in plugins include **autopan, minimap, LOD, snap, stats, and debug**, each contributing overlays, behavior, or diagnostics through a plugin registry and layer-provider mechanism.
   - Event types are separated into their own plugin/event namespace, suggesting plugins observe editor lifecycle and interaction events instead of directly mutating internals.

8. **Performance and scale strategies**
   - Two architectural themes stand out: **level-of-detail** and **spatial culling/indexing**.
   - LOD reduces visual complexity as zoom changes, while spatial structures support large graphs, hit testing, and debug tooling.
   - Performance is treated as a product feature, not an implementation detail, and is heavily covered by dedicated performance tests.

9. **Demo application: `packages/demo`**
   - The demo is a standalone Flutter app that exercises the library in realistic scenarios: a browser, detail views, navigation, embedded examples, and an interactive workbench.
   - It includes many example flows and JSON assets for prebuilt workflows, showing that the editor can both create and load structured graph documents.
   - The `node_math` example is a smaller subdomain demo with its own model, evaluator, canvas, toolbox, validator, and stats widgets, illustrating how an application can build domain logic on top of the editor.

10. **Demo UI layer**
   - The demo has a small design system (`design_kit`) and shared responsive/UI helpers, which separate presentation concerns from editor logic.
   - The demo targets multiple Flutter runtimes, with web and macOS scaffolding present, so the same editor core is exercised in both embedded and desktop/browser contexts.

11. **Documentation website**
   - The `website` folder is a VitePress site, not part of the Flutter runtime.
   - It provides conceptual docs, API docs, theming guides, advanced usage, and example pages, plus rich marketing pages and embedded code samples.
   - The site also contains videos and interactive components, making it the external-facing knowledge layer for the library.

12. **Build, test, and release pipeline**
   - CI/CD is split into workflows for publishing the package, deploying the demo, deploying the website, and collecting coverage.
   - The repo has extensive tests in the core package: unit, widget, behavior, integration, edge-case, and performance suites, which reinforces that the library is expected to behave deterministically under interaction-heavy workloads.
   - Melos is used for workspace management, so package boundaries are intentional and maintained as a multi-package Dart workspace.

13. **How data flows through the system**
   - A typical flow is: user input in the editor UI → controller updates graph/viewport/selection state → plugins and behaviors react → layers/painters render the updated graph.
   - A second flow is: graph data loaded from JSON/assets or created interactively → serialized model objects in the core package → demo/example views and docs samples render the result.
   - That separation between **state management**, **interaction/behavior**, and **rendering** is the key architectural line for diagramming this repo.

Main entry points: [`packages/vyuh_node_flow/lib/src/editor/node_flow_editor.dart`](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/editor/node_flow_editor.dart) (NodeFlowEditor), [`packages/vyuh_node_flow/lib/vyuh_node_flow.dart`](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/vyuh_node_flow.dart) (Public API), [`packages/vyuh_node_flow/lib/src/connections/connection.dart`](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/connections/connection.dart) (Connections), [`packages/demo/lib/examples/node_math/node_math_example.dart`](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/demo/lib/examples/node_math/node_math_example.dart) (Node math)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core package"]
  node_vyuh_node_flow_api["Public API<br/>dart barrel"]
  node_controller_api["Controller<br/>orchestration API<br/>[controller.dart]"]
  node_editor_api["Editor<br/>runtime API<br/>[editor.dart]"]
  node_model_api["Model types<br/>domain API<br/>[nodes.dart]"]
  node_node_flow_controller["NodeFlowController<br/>state orchestrator"]
  node_node_flow_editor["NodeFlowEditor<br/>editor runtime"]
  node_node_flow_viewer["NodeFlowViewer<br/>viewer runtime"]
  node_graph_model["Graph model<br/>graph state<br/>[graph.dart]"]
  node_node_system["Nodes<br/>node system<br/>[node.dart]"]
  node_port_system["Ports<br/>port system<br/>[port.dart]"]
  node_connection_system["Connections<br/>edge system<br/>[connection.dart]"]
  node_spatial_index["Spatial index<br/>performance layer"]
  node_editor_layers["Render layers<br/>render pipeline<br/>[layers.dart]"]
  node_plugins["Plugins<br/>extension system"]
end

subgraph group_demo["Demo app"]
  node_demo_app["Demo app<br/>flutter app<br/>[main.dart]"]
  node_example_browser["Example browser<br/>demo surface"]
  node_examples_suite["Examples<br/>demo catalog<br/>[simple.dart]"]
  node_node_math_example["Node math<br/>domain demo"]
end

subgraph group_docs["Documentation site"]
  node_website_site["Docs site<br/>vitepress site<br/>[index.md]"]
  node_site_components["Site UI<br/>docs UI<br/>[index.ts]"]
end

subgraph group_tooling["Tooling"]
  node_workflows["CI/CD<br/>automation<br/>[publish.yml]"]
end

node_vyuh_node_flow_api -->|"exports"| node_controller_api
node_vyuh_node_flow_api -->|"exports"| node_editor_api
node_vyuh_node_flow_api -->|"exports"| node_model_api
node_controller_api -->|"wraps"| node_node_flow_controller
node_editor_api -->|"wraps"| node_node_flow_editor
node_editor_api -->|"wraps"| node_node_flow_viewer
node_node_flow_controller -->|"mutates"| node_graph_model
node_node_flow_controller -->|"notifies"| node_plugins
node_node_flow_editor -->|"renders"| node_editor_layers
node_node_flow_editor -->|"queries"| node_spatial_index
node_node_flow_editor -->|"hosts"| node_node_system
node_node_flow_editor -->|"hosts"| node_port_system
node_node_flow_editor -->|"hosts"| node_connection_system
node_node_flow_editor -->|"extends"| node_plugins
node_connection_system -->|"culls"| node_spatial_index
node_connection_system -->|"reads"| node_graph_model
node_node_system -->|"reads"| node_graph_model
node_port_system -->|"attaches"| node_node_system
node_plugins -->|"adds"| node_editor_layers
node_demo_app -->|"consumes"| node_vyuh_node_flow_api
node_example_browser -->|"navigates"| node_examples_suite
node_examples_suite -->|"showcases"| node_node_flow_editor
node_node_math_example -->|"builds on"| node_node_flow_editor
node_node_math_example -->|"uses"| node_port_system
node_node_math_example -->|"uses"| node_connection_system
node_website_site -->|"documents"| node_vyuh_node_flow_api
node_website_site -->|"renders with"| node_site_components
node_site_components -->|"embeds"| node_examples_suite
node_workflows -->|"deploys"| node_demo_app
node_workflows -->|"deploys"| node_website_site
node_workflows -->|"publishes"| node_vyuh_node_flow_api

click node_vyuh_node_flow_api "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/vyuh_node_flow.dart"
click node_controller_api "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/controller.dart"
click node_editor_api "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/editor.dart"
click node_model_api "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/nodes.dart"
click node_node_flow_controller "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/editor/controller/node_flow_controller.dart"
click node_node_flow_editor "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/editor/node_flow_editor.dart"
click node_node_flow_viewer "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/editor/node_flow_viewer.dart"
click node_graph_model "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/graph/graph.dart"
click node_node_system "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/nodes/node.dart"
click node_port_system "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/ports/port.dart"
click node_connection_system "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/connections/connection.dart"
click node_spatial_index "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/shared/spatial/graph_spatial_index.dart"
click node_editor_layers "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/editor/layers/layers.dart"
click node_plugins "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/plugins/plugin_registry.dart"
click node_demo_app "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/demo/lib/main.dart"
click node_example_browser "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/demo/lib/example_browser.dart"
click node_examples_suite "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/demo/lib/examples/simple.dart"
click node_node_math_example "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/demo/lib/examples/node_math/node_math_example.dart"
click node_website_site "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/website/index.md"
click node_site_components "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/website/.vitepress/theme/index.ts"
click node_workflows "https://github.com/vyuh-tech/vyuh_node_flow/blob/main/.github/workflows/publish.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_vyuh_node_flow_api,node_controller_api,node_editor_api,node_model_api,node_node_flow_controller,node_node_flow_editor,node_node_flow_viewer,node_graph_model,node_node_system,node_port_system,node_connection_system,node_spatial_index,node_editor_layers,node_plugins toneBlue
class node_demo_app,node_example_browser,node_examples_suite,node_node_math_example toneAmber
class node_website_site,node_site_components toneMint
class node_workflows toneRose
```

## Components

### Core package

Reusable node-flow editor framework in packages/vyuh_node_flow.

- [Public API](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/vyuh_node_flow.dart): dart barrel · Top-level exports for the reusable editor framework. · `packages/vyuh_node_flow/lib/vyuh_node_flow.dart`
- [Controller](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/controller.dart): orchestration API · Orchestrates graph, viewport, resize, dirty tracking, and plugin coordination. · `packages/vyuh_node_flow/lib/controller.dart`
- [Editor](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/editor.dart): runtime API · Entry point for editor and viewer runtime widgets. · `packages/vyuh_node_flow/lib/editor.dart`
- [Model types](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/nodes.dart): domain API · Exports graph, nodes, ports, connections, viewport, themes, and utilities. · `packages/vyuh_node_flow/lib/nodes.dart`
- [NodeFlowController](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/editor/controller/node_flow_controller.dart): state orchestrator · Boundary between UI events and graph mutations. · `packages/vyuh_node_flow/lib/src/editor/controller/node_flow_controller.dart`
- [NodeFlowEditor](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/editor/node_flow_editor.dart): editor runtime · Interactive editor shell handling gestures, selection, dragging, and painting. · `packages/vyuh_node_flow/lib/src/editor/node_flow_editor.dart`
- [NodeFlowViewer](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/editor/node_flow_viewer.dart): viewer runtime · Read-focused viewer surface for rendering graphs without full editing affordances. · `packages/vyuh_node_flow/lib/src/editor/node_flow_viewer.dart`
- [Graph model](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/graph/graph.dart): graph state · Core graph, coordinates, and viewport data model. · `packages/vyuh_node_flow/lib/src/graph/graph.dart`
- [Nodes](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/nodes/node.dart): node system · Node widgets, shapes, container/data model, mixins, and special node types. · `packages/vyuh_node_flow/lib/src/nodes/node.dart`
- [Ports](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/ports/port.dart): port system · Port geometry, widgets, and theming for typed node endpoints. · `packages/vyuh_node_flow/lib/src/ports/port.dart`
- [Connections](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/connections/connection.dart): edge system · Connection styles, validation, endpoint logic, labels, effects, and caches. · `packages/vyuh_node_flow/lib/src/connections/connection.dart`
- [Spatial index](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/shared/spatial/graph_spatial_index.dart): performance layer · Spatial grid and indexing for hit testing, culling, and large-graph performance. · `packages/vyuh_node_flow/lib/src/shared/spatial/graph_spatial_index.dart`
- [Render layers](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/editor/layers/layers.dart): render pipeline · Grid, connections, labels, nodes, interaction overlays, and thumbnail layers. · `packages/vyuh_node_flow/lib/src/editor/layers/layers.dart`
- [Plugins](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/vyuh_node_flow/lib/src/plugins/plugin_registry.dart): extension system · Plugin registry and built-ins for autopan, minimap, LOD, snap, stats, and debug. · `packages/vyuh_node_flow/lib/src/plugins/plugin_registry.dart`

### Demo app

Flutter application showcasing the library with examples and runtime surfaces.

- [Demo app](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/demo/lib/main.dart): flutter app · Standalone Flutter app exercising the library in browser, desktop, and workbench modes. · `packages/demo/lib/main.dart`
- [Example browser](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/demo/lib/example_browser.dart): demo surface · Navigation and detail views for curated examples and workflows. · `packages/demo/lib/example_browser.dart`
- [Examples](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/demo/lib/examples/simple.dart): demo catalog · Interactive example flows demonstrating editor features and graph behaviors. · `packages/demo/lib/examples/simple.dart`
- [Node math](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/packages/demo/lib/examples/node_math/node_math_example.dart): domain demo · A self-contained example subdomain with evaluation, toolbox, validator, and stats UI. · `packages/demo/lib/examples/node_math/node_math_example.dart`

### Documentation site

VitePress site for concepts, API docs, theming, and examples.

- [Docs site](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/website/index.md): vitepress site · Documentation and marketing site for concepts, API, theming, plugins, and examples. · `website/index.md`
- [Site UI](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/website/.vitepress/theme/index.ts): docs UI · VitePress theme components, code samples, and interactive marketing surfaces. · `website/.vitepress/theme/index.ts`

### Tooling

Repository-wide build, test, release, and workspace automation.

- [CI/CD](https://github.com/vyuh-tech/vyuh_node_flow/blob/main/.github/workflows/publish.yml): automation · Publish, deploy, and coverage workflows for the monorepo. · `.github/workflows/publish.yml`

## Connections

- Public API → Controller: exports · Public package API exposes controller entrypoints.
- Public API → Editor: exports · Public package API exposes editor/viewer entrypoints.
- Public API → Model types: exports · Public package API exposes core model and utility exports.
- Controller → NodeFlowController: wraps · Controller API surfaces the orchestration boundary.
- Editor → NodeFlowEditor: wraps · Editor API exposes the interactive editing runtime.
- Editor → NodeFlowViewer: wraps · Editor API exposes the read-only viewer runtime.
- NodeFlowController → Graph model: mutates · Controller applies graph and viewport changes to model state.
- NodeFlowController → Plugins: notifies · Controller emits lifecycle and interaction events to plugins.
- NodeFlowEditor → Render layers: renders · Editor composes the layered rendering pipeline.
- NodeFlowEditor → Spatial index: queries · Editor uses spatial structures for hit testing and culling.
- NodeFlowEditor → Nodes: hosts · Editor places and manipulates nodes.
- NodeFlowEditor → Ports: hosts · Editor renders and interacts with ports.
- NodeFlowEditor → Connections: hosts · Editor renders and validates connections.
- NodeFlowEditor → Plugins: extends · Editor behavior is augmented through plugins.
- Connections → Spatial index: culls · Connection rendering and hit testing benefit from spatial data.
- Connections → Graph model: reads · Connections are derived from graph state and endpoint data.
- Nodes → Graph model: reads · Nodes are instances of the underlying graph model.
- Ports → Nodes: attaches · Ports are bound to node geometry and presentation.
- Plugins → Render layers: adds · Built-in plugins contribute overlays and auxiliary layers.
- Demo app → Public API: consumes · Demo app depends on the reusable editor library.
- Example browser → Examples: navigates · Browser presents the example catalog and detail pages.
- Examples → NodeFlowEditor: showcases · Examples exercise the interactive editor runtime.
- Node math → NodeFlowEditor: builds on · Node math layers domain behavior on top of the editor core.
- Node math → Ports: uses · Domain demo uses port customization and wiring.
- Node math → Connections: uses · Domain demo uses connection semantics and validation.
- Docs site → Public API: documents · Docs site explains the library's public API and concepts.
- Docs site → Site UI: renders with · Site content is assembled from VitePress theme components.
- Site UI → Examples: embeds · Docs include live examples, code samples, and media around the editor.
- CI/CD → Demo app: deploys · CI deploys the demo application.
- CI/CD → Docs site: deploys · CI deploys the documentation website.
- CI/CD → Public API: publishes · CI publishes the library package.
