Skip to content
← back to projects

Case study · 2026 · Personal

Code Trace

A DSA visualiser where every problem is animated line by line. The design bet is that the animation should never be able to disagree with the code it is showing.

Stack
Next.js 16 · React 19 · TypeScript · Supabase · Tailwind
Live
codetrace.tejaverse.org ↗
Source
Private repository
Problems
119
Categories
13
Approaches
238
Visualisers
238

The problem

Reading an algorithm rarely tells you what it does. Watching a bar chart move does. The catch is that most visualisers are a second implementation living next to the real code, and the two quietly drift apart — the animation shows what the author meant, not what the code does. Code Trace takes the opposite position: the animation is generated from a simulation of the algorithm, and playback only ever walks that generated result.

Decisions

  1. 01

    Playback walks a precomputed trace

    Each approach has a trace builder that simulates the algorithm over the given input and returns an ordered list of steps. That list is memoised per approach, and the player does nothing but move through it. Because the steps are produced once, up front, the animation cannot desynchronise from the code mid-playback — the failure mode that makes most teaching visualisers untrustworthy simply isn't reachable.

  2. 02

    One shared step contract

    Every visualiser renders from the same shape: the active source line, a highlighted set of cells, named variables with a tone (ok, fail, info), a result, and a plain-English explanation of what just happened. Fixing that contract early is why 238 visualisers could be built without each one inventing its own vocabulary.

  3. 03

    A registry instead of one generic renderer

    Visualisers are looked up by problem and approach — getVisualizer(slug, versionId) — from a registry of 238 entries. Kadane's algorithm wants a running-total bar chart; a linked-list cycle wants nodes and arrows. A single generic renderer would have flattened all of them into something that fits none, so the cost of per-approach components was paid deliberately.

  4. 04

    Two approaches per problem, with the source beside them

    Every problem ships two approaches so you can see the naive version and the better one animate side by side, each tagged with its own time and space complexity. The source for each approach is stored as a string alongside its trace builder, so the code pane and the animation always come from the same place.

Where it stands