AI engineering / Recommendations / Case study
Harmonic Color Graph
Ground AI recommendations in inspectable evidence.
A recommendation system that combines corpus-backed ranking, typed domain tools, and a grounded LLM assistant to explain chord choices.
- My role
- Individual project · design and implementation
- Engineering focus
- Grounded explanations, streaming latency, model cost
- Evidence snapshot
- In production: full answer 2.6 s median (was 5.1 s), cost per answer −97%; 40/40 benchmark cases pass.
- Status
- Research and development workbench
Typed tools · Grounding · Evaluation · Python · FastAPI · Next.js · LangGraph · Claude · MCP · Recommendation ranking

The harmonic atlas on the live site, with the selected chord’s likely next moves and a route picker.
The problem
Musicians exploring a chord progression need more than a plausible next chord. They need to inspect the harmonic relationships and understand why a recommendation fits.
My contribution
Individual project. I built the harmonic workbench, recommendation pipeline, typed tools, grounded assistant, and evaluation workflow.
Evidence at a glance
Two measurements, both client-timed over SSE with live Claude Haiku 5.5 and Sonnet 5.5. Production (December 3, 2026): the live API and database, the same 19 requests with Sonnet and then Haiku drafting, 38 Haiku requests in all, plus 8 queries in the browser. Local latency study (November 29, 2026): the same 50 warm requests before and after six changes. Quality comes from the live 40-case benchmark.
| Check | Result | Conditions and limits |
|---|---|---|
| Full answer in production | 5.09 → 2.60 s median · 11.97 → 5.49 s p95 | Same 19 requests, Sonnet → Haiku drafting; Haiku was faster on 18 of 19. Across all 38 Haiku requests the p95 is 4.95 s. In the browser the median is 2.57 s. |
| Cost per answer in production | $0.027 → $0.00085 · −97% | Metered in the production audit log on the same 19 requests. The Sonnet repair never ran in 38 requests; 7 were answered from validated evidence with no model call. |
| Latency targets in production | 4 of 5 met | Over 38 requests. The miss: suggestions at 1.02 s median against 1 s, held back by generation requests (1.5–2.0 s). All five pass locally. |
| Full answer, local study | 5.03 → 2.27 s median · 8.63 → 3.99 s p95 | Six measured changes: claim-by-claim streaming, prompt caching, parallel lookup, a cited opening claim, a local parser, Haiku drafting. |
| First explanation after suggestions | 3.80 → 0.004 s median | A validated, cited opening claim is sent before the model call; 0.010 s in production. |
| Fallbacks | 13/40 → 2/40 · 0 of 38 in production | Benchmark: both remaining are by-design clarifications. Per-claim validation keeps valid claims instead of discarding the whole draft. |
| Quality held | 40/40 cases · 10/10 scores matched | Schema, tool, theory and fact-coverage checks at 100%; intent match 10/12 (83%), unchanged from before the speedups. |
Architecture
A Next.js interface connects to a Python/FastAPI backend for harmonic analysis, graph exploration, recommendations, and playback. Typed domain tools serve the interface, a LangGraph/Claude assistant, and MCP. Reusing the same deterministic services across these entry points keeps the underlying analysis consistent. Tool results carry fact IDs that connect explanations to their evidence.
- Progression + intent
- Deterministic harmonic tools
- Feature-weighted ranking
- Candidates + fact IDs
- Haiku draft, streamed per claim
- Grounding validation
A claim that fails validation is never shown. If none pass: one Sonnet attempt, then a labeled deterministic fallback. Cost reservations and request limits bound model use.
A consequential decision
- Constraint
- A fluent explanation can still invent a chord choice or misstate why it fits, and a slow one loses the user before it arrives.
- Alternative
- Let one large model generate and explain recommendations in a single unconstrained response, shown when complete.
- My choice
- Keep ranking in the recommendation pipeline. Give the assistant typed tools and fact IDs, validate each claim as it streams, and use a fast draft model with a stronger model only as repair.
- Consequence
- Every sentence shown is cited and validated. In production the answer completes in 2.60 s median at 97% lower cost per answer, with benchmark quality unchanged.
Guided walkthrough
Inspect a real harmonic relationship without needing to ask the assistant or run a paid model request. The atlas demonstrates domain tools; the evaluation table above is the evidence for assistant behavior.
01Start with context
The linked atlas opens D7 → G → C in C major. The current sketch and key stay visible beside the graph.
02Inspect a node
Select a harmonic function and read the chord inspector. Compare the musical identity with its connections; visual distance is not a similarity score.
03Trace a route
Choose endpoints and inspect available paths. Use the displayed chord sequence to connect a graph relationship to the original progression.
Current scope
Production meets four of five latency targets; suggestions for generation requests still take 1.5–2 seconds. Next: bring those under a second, remove the 6–8 second cold start after idle periods, and grow the intent evaluation beyond 12 scored cases with musician review.
Source evidence
Implementation and documentation pinned to the reviewed source revision.