Scope: Rust frontend graph engine, using the existing WebGL renderer where practical. This specifies visualization and interaction, not database storage, graph semantics, or execution/simulation logic. Inspect the current renderer before refactoring; extend existing abstractions where possible.
1. Architecture
Separate (1) input graph/view data, (2) visual scene and layers, (3) layout/routing, and (4) rendering/picking. Stable semantic IDs must be distinct from visual-instance IDs: one entity may appear in multiple views or positions. Keep styles and viewport state separate from topology. Support incremental updates without rebuilding the entire scene.
2. Visual primitives
- Nodes: variable size, shape (circle, rectangle, diamond, polygon/custom), color, stroke, icon, label and optional expanded content. Support nested/compound nodes.
- Ports/channels: colored, typed-looking boundary markers with configurable placement, direction and multiple connections; expose independent hit targets.
- Edges: directed/undirected, self-loops, parallel edges, configurable color, width, opacity, dashes, arrowheads, labels and clickability. Routes: straight, curved/Bézier and orthogonal/grid-aligned; optional manually routed points.
- Animated edges: optional moving particle/pulse along a path with adjustable speed. Animation is presentation only; external simulation state may drive it.
- Higher-order connections: low-degree hyperedges (junction or enclosing region), simplicial faces (filled triangles, etc.), and highlighted cliques/subgraphs (hulls or tinted regions). Do not conflate a graph clique, hyperedge and simplex.
3. Layers and overlapping representations
One underlying edge/node can belong to multiple independently toggleable visual layers. Example: blue static function-call edges and a yellow stack-trace path; shared edges may show both using offset parallel strokes, dashed overlay or priority styling. Layers independently control style, visibility, labels and interaction. Support persistent layers and temporary overlays (debugging, selection, search, profiling).
A stack trace is an ordered sequence of frame/call occurrences, not just a set of edge IDs: recursion can revisit the same function or call edge. Preserve occurrence identity and order independently of semantic entity IDs. Layers must not mutate graph topology.
4. Hierarchy, grouping and zoom
- Support nested structural groups/modules, overlapping visual memberships (cliques/communities), and marked subgraphs.
- Distinguish structural expansion (revealing actual internals) from visual aggregation (LOD clustering).
- On zoom-out, replace dense groups with aggregate nodes and bundled/proxy edges; on zoom-in, reveal members, internal connections and ports. Preserve selection and cross-boundary connectivity through transitions.
- Allow layouts centered on one or multiple focal nodes.
5. Layout and interaction
Provide manual/fixed positioning plus pluggable automatic layouts (initially force-directed and hierarchical; orthogonal routing for flow diagrams). Support pan/zoom, selection and multiselection, dragging, hover, edge/port picking, collapse/expand, and optional edge clicks. Keep graph exploration and flow/canvas editing as distinct interaction modes over the same renderer; do not implement a separate graph renderer for each domain.
6. Level of detail and performance
Decide visibility from projected pixel size, local density and frame budget, not zoom alone. Progressively suppress tiny labels/ports, disable tiny hit targets, stop barely visible animations, simplify edges, bundle connections, and cull off-screen geometry. Prefer batched/instanced WebGL drawing, reused geometry, cached text and partial buffer updates. Picking may use spatial indexing and/or GPU ID picking. Avoid mounting rich UI components for every node; reserve them for selected/expanded nodes.
7. Domain compatibility
The frontend engine should be configurable for RDF/ontology graphs, code/dependency/call graphs, no-code/low-code flows, Simulink/ModelingToolkit-style port diagrams, factor graphs, low-degree hypergraphs/simplicial complexes, and spatial hardware layouts. Domain-specific validation and simulation remain outside the renderer. Preserve meaningful coordinates when a spatial layout requires them.
8. Acceptance checks
- Render nodes of different shapes/sizes/colors/icons, with colored ports and independently selectable edges.
- Render multiple parallel edges and straight/curved/orthogonal routes, arrowheads and variable-speed moving particles.
- Toggle blue call-graph and yellow stack-trace layers; shared edges display both, and recursive trace occurrences retain order.
- Show nested groups, overlapping highlighted cliques, a hyperedge and a filled 2-simplex without treating them as equivalent.
- Collapse/expand a group across zoom levels while keeping external connections and stable selection.
- At low zoom/dense scenes, suppress subpixel detail and animation while preserving responsive navigation.
- Switch graph-exploration and flow-editing modes without duplicating rendering infrastructure.
Implementation guidance: First map these requirements onto Moonkale’s current Rust/WebGL architecture. Propose minimal interfaces and a staged plan before broad rewrites. Prefer incremental, testable changes; do not introduce a new rendering backend solely for this specification.
Mapped onto the current renderer, with minimal interfaces and a staged plan: Frontend Graph Engine Mapping. The flow editor’s move onto the same engine is ADR-0018.