This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
make install # Install npm dependencies
make dev # Start Vite dev server with HMR
make build # TypeScript check + production build to dist/
make lint # ESLint
make test # Vitest (run once)
make fmt # Prettier format
npm run test:watch # Vitest in watch modeRun a single test file: npx vitest run src/hooks/useAnimationController.test.ts
Interactive visualization tool for database internals. Each topic (indexing, encoding, replication, partitioning, transactions, consensus) has multiple visualizations rendered on HTML5 Canvas with step-through animation.
Every visualization lives in src/visualizations/<topic>/<algorithm>/ with two files:
-
engine.ts- Pure logic. DefinesConfig,State,Frametypes and exports agenerateFrames(config)function that produces an array of frame snapshots. Each frame contains the full simulation state plus metadata (annotation text, highlights, operation type). No React or Canvas code here. -
<Name>Visualization.tsx- React component. Wires the engine to the UI:- Holds config state, passes it to
generateFrames()viauseMemo - Uses
useAnimationController()for playback (play/pause/step/speed/scrub) - Uses
useCanvas()for Canvas ref and DPR-aware setup - Renders frames via a
renderFrame(ctx, frame)function using canvas-utils helpers - Wraps everything in
<VisualizationContainer>which provides animation controls, config panel, and keyboard shortcuts
- Holds config state, passes it to
- Create
src/visualizations/<topic>/<name>/engine.tswith types andgenerateFrames() - Create
src/visualizations/<topic>/<name>/<Name>Visualization.tsxfollowing the pattern above - Add a tab entry in the corresponding
src/routes/<topic>.tsxfile
- TanStack Router with file-based routing (
src/routes/). Route tree is auto-generated insrc/routeTree.gen.ts(do not edit). __root.tsxprovides the shell: sidebar + content area- Each route uses
<TopicPage>which renders tabs, one per visualization - Sidebar navigation is in
AppSidebar.tsx
src/lib/canvas-utils.ts- Drawing primitives (nodes, rects, arrows, labels, animated messages) and sharedCOLORSpalettesrc/hooks/useAnimationController.ts- Frame-based playback controller (play/pause/step/speed/reset/goToFrame)src/hooks/useCanvas.ts- Canvas ref with DPR-aware sizingsrc/hooks/useKeyboardShortcuts.ts- Keyboard controls bound to the animation controllersrc/components/VisualizationContainer.tsx- Standard wrapper composing animation controls + optional config panelsrc/components/ConfigPanel.tsx- Renders slider/select config fields from a declarative schema
- TypeScript, React 19, Vite 7, Tailwind CSS v4, shadcn/ui (new-york style), TanStack Router
- Path alias:
@/maps tosrc/ - shadcn components in
src/components/ui/, configured viacomponents.json - Tests: Vitest with jsdom, setup in
src/test/setup.ts