How vyuh-tech/vyuh_node_flow works
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: node_flow_editor.dart NodeFlowEditor · vyuh_node_flow.dart Public API · connection.dart Connections · node_math_example.dart Node math
Components 21
Core package
Reusable node-flow editor framework in packages/vyuh_node_flow.
- Public API · Top-level exports for the reusable editor framework.
packages/vyuh_node_flow/lib/vyuh_node_flow.dart - Controller · Orchestrates graph, viewport, resize, dirty tracking, and plugin coordination.
packages/vyuh_node_flow/lib/controller.dart - Editor · Entry point for editor and viewer runtime widgets.
packages/vyuh_node_flow/lib/editor.dart - Model types · Exports graph, nodes, ports, connections, viewport, themes, and utilities.
packages/vyuh_node_flow/lib/nodes.dart - NodeFlowController · Boundary between UI events and graph mutations.
packages/vyuh_node_flow/lib/src/editor/controller/node_flow_controller.dart - NodeFlowEditor · Interactive editor shell handling gestures, selection, dragging, and painting.
packages/vyuh_node_flow/lib/src/editor/node_flow_editor.dart - NodeFlowViewer · Read-focused viewer surface for rendering graphs without full editing affordances.
packages/vyuh_node_flow/lib/src/editor/node_flow_viewer.dart - Graph model · Core graph, coordinates, and viewport data model.
packages/vyuh_node_flow/lib/src/graph/graph.dart - Nodes · Node widgets, shapes, container/data model, mixins, and special node types.
packages/vyuh_node_flow/lib/src/nodes/node.dart - Ports · Port geometry, widgets, and theming for typed node endpoints.
packages/vyuh_node_flow/lib/src/ports/port.dart - Connections · Connection styles, validation, endpoint logic, labels, effects, and caches.
packages/vyuh_node_flow/lib/src/connections/connection.dart - Spatial index · 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 · Grid, connections, labels, nodes, interaction overlays, and thumbnail layers.
packages/vyuh_node_flow/lib/src/editor/layers/layers.dart - Plugins · 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 · Standalone Flutter app exercising the library in browser, desktop, and workbench modes.
packages/demo/lib/main.dart - Example browser · Navigation and detail views for curated examples and workflows.
packages/demo/lib/example_browser.dart - Examples · Interactive example flows demonstrating editor features and graph behaviors.
packages/demo/lib/examples/simple.dart - Node math · 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.
Tooling
Repository-wide build, test, release, and workspace automation.
- CI/CD · Publish, deploy, and coverage workflows for the monorepo.
.github/workflows/publish.yml
Connections 31
- 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.