Daniel Zhao
← Projects

ChordCraft

Piano score editor with an AI composing partner

Links
GitHubusechordcraft.vercel.app
Stack
React, TypeScript, VexFlow, Tone.js, FastAPI, PostgreSQL, Redis, LangGraph, Claude

Overview

ChordCraft is a piano score editor with a composing partner, like Cursor for sheet music. Select a few bars, describe the change you want, and review the AI's edit note by note before it lands. Only the bars you picked ever change.

Editing by describing it

Press ⌘K on a selection, or ask in the chat panel, and the edit comes back as a diff right on the staff: drafted notes in blue, the notes they replace in dashed orange. You can listen to it, then accept or reject the whole edit. I used blue and orange instead of green and red so the diff reads for colour-blind users too. Every accepted edit becomes a version you can undo or restore.

Pause at the end of a phrase and it suggests the next bar, shown faintly until you press Tab. You can start from a blank page, a chord progression, or an imported MusicXML or MIDI file.

The agent

Edits run through a LangGraph agent on Claude. It sees the selection plus two bars of context on either side, and edits through strict tools that map one-to-one to score operations (add, remove or update a note, set a chord). Anything outside the selection is rejected, and every tool call returns precise errors the model can act on.

Agent flowcontext → model ⇄ tools → validate ─pass─▶ proposal
             ▲                │ fail (≤ 2 repairs)
             └────────────────┘

Before you see anything, a deterministic music checker in Python reviews the edit. Bars whose rhythm doesn't add up, or chords wider than a hand can reach, go back to the model to repair, at most twice. Out-of-range notes, parallel fifths and odd spellings are flagged as warnings alongside the proposal.

Architecture

The front end is React and TypeScript, with VexFlow drawing the notation and Tone.js handling playback. Behind it, FastAPI queues each edit as a job in Redis. A worker runs the agent and publishes every step, which streams to the browser over server-sent events, so you watch the edit take shape and a dropped connection picks up where it left off. Scores, revisions and edit jobs live in PostgreSQL, with sign-in through Supabase.