Parent: #1
Depends on: #4
Goal
Build the visualization layer that turns canonical data-structure states and trace highlights into visible nodes, edges, labels, controls, and replay states.
React Flow is the recommended first choice because this app needs custom nodes, custom edges, viewport controls, minimaps, layouting, drag/pan/zoom, save/restore patterns, and graph/tree visualization support. Use it as the canvas engine, but keep it behind an adapter so the data-structure engine does not depend on React Flow types.
Core architecture
Data flow should look like this:
OperationCommand
-> data-structure engine
-> OperationTrace
-> current TraceStep
-> VisualizationAdapter
-> React Flow nodes/edges
-> Canvas render
Do not let the canvas mutate the canonical structure state directly.
Required modules
Adapter interface draft
interface VisualizationAdapter<TState> {
structure: StructureKind;
toFlowModel(input: {
state: TState;
highlights?: Highlight[];
viewportMode?: 'compact' | 'detailed';
}): {
nodes: Node[];
edges: Edge[];
};
}
The actual implementation can refine the types, but the adapter boundary should remain explicit.
Initial adapters
Canvas features
Layout requirements
- Linear structures should be stable and predictable; avoid physics/force layout for stacks/queues.
- Trees/heaps/graphs can use layout helpers later, but this issue should define a
layout module boundary now.
- Node positions should not jitter between trace steps unless movement is part of the teaching moment.
- Prefer deterministic coordinates in tests.
Accessibility requirements
- Canvas must have an accessible label explaining what is visualized.
- Current operation step must be available outside the canvas as text.
- Critical information must not be color-only.
- Keyboard focus should not get trapped in the canvas.
Tests required
Acceptance criteria
Non-goals
- Do not implement operation controls here; use fixed/mock states if needed.
- Do not implement persistence here.
- Do not implement every structure adapter here.
Reference docs
Parent: #1
Depends on: #4
Goal
Build the visualization layer that turns canonical data-structure states and trace highlights into visible nodes, edges, labels, controls, and replay states.
React Flow is the recommended first choice because this app needs custom nodes, custom edges, viewport controls, minimaps, layouting, drag/pan/zoom, save/restore patterns, and graph/tree visualization support. Use it as the canvas engine, but keep it behind an adapter so the data-structure engine does not depend on React Flow types.
Core architecture
Data flow should look like this:
Do not let the canvas mutate the canonical structure state directly.
Required modules
src/features/visualizer/types.tssrc/features/visualizer/VisualizationCanvas.tsxsrc/features/visualizer/adapters/**src/features/visualizer/nodes/**src/features/visualizer/edges/**src/features/visualizer/layout/**src/features/visualizer/highlights/**Adapter interface draft
The actual implementation can refine the types, but the adapter boundary should remain explicit.
Initial adapters
Canvas features
Layout requirements
layoutmodule boundary now.Accessibility requirements
Tests required
Acceptance criteria
Non-goals
Reference docs