Part VI β The Blueprint Β· Lesson 11.14
HLD Kanban Board
In one lineDrag-and-drop with optimistic reordering β the design problem is what happens when the server says no.
Where you've seen itDropping a card into "Done" and having it snap back two seconds later because someone else already moved it.
Diagram
1β2 Β· SCOPE AND SCALE
in scope columns Β· cards Β· drag between and within columns Β·
real-time sync Β· filters
out reporting Β· automations Β· permissions admin
scale ~10 columns Β· up to 500 cards Β· 2β20 concurrent users3 Β· OPTIMISTIC REORDER β and the rollback that must exist
user drops card C3 into "Done" at index 1
β
βββΊ snapshot current state β without this,
β rollback is impossible
βββΊ move locally, render instantly 0ms, feels native
β
βββΊ PATCH /cards/c3 {column:'done', after:'c7'}
β
βββββββ΄βββββββ
200 OK 409 conflict
β β
reconcile RESTORE snapshot
with server + toast "Someone else moved this card"
response + refetch the column6a Β· DEEP DIVE β ORDERING WITHOUT REWRITING EVERY CARD
β integer positions 1,2,3,4β¦
insert between 2 and 3 β renumber every card after it
β 400 writes for one drag, and constant conflicts
β fractional / lexicographic keys
card A position "a"
card B position "n" insert between β "g"
card C position "z"
one write. Neighbours never change.
LexoRank / fractional indexing: always a value between
any two keys. Rebalance rarely, in the background.6b Β· DEEP DIVE β CONCURRENT MOVES
Alice moves C3 β Done[1] Bob moves C3 β Review[0]
ββββββββββ¬ββββββββββββββββββ
βΌ
server applies both; last write wins on POSITION
broadcast the resulting state to everyone (2.4)
each client: reconcile against its optimistic copy
if my optimistic position β server position,
animate to the server's answer β never leave
two clients showing different boardsHow it works
- Snapshot before the optimistic move, always β rollback is the feature, not the edge case.
- Fractional ordering keys so a drag is one write and neighbours are untouched.
- Broadcast moves over WebSocket (2.4) and reconcile every client to the server's state.
- Use a maintained drag library (
dnd-kit) β it handles keyboard dragging, touch, auto-scroll, and screen-reader announcements you would otherwise skip. - Virtualize long columns (10.7) once a column exceeds a few hundred cards.
Trade-offs
| Choice | Cost |
|---|---|
| Optimistic move | Instant feel; rollback UI required |
| Server-confirmed move | Always correct; feels sluggish |
| Fractional keys | One write per move; occasional rebalance |
| Integer positions | Simple to read; O(n) writes and conflicts |
Accessibility (8.2): drag-and-drop is unusable by keyboard unless you build the alternative β focus a card, press Space to lift, arrows to move, Space to drop, Escape to cancel, with each step announced via a live region. This is the most commonly skipped part of a Kanban implementation and a strong thing to raise unprompted.
Interview angle
"Two users drag the same card at once. What happens?"
- Both apply optimistically and locally, so both feel instant; the server resolves position by last write and broadcasts the result.
- Each client reconciles against its optimistic copy and animates to the server's answer, so no two boards disagree.
- The card that lost shows a toast explaining the move β silently snapping back is what makes users distrust the tool.
Recap
- Snapshot, move optimistically, reconcile or roll back.
- Fractional ordering keys turn a reorder into a single write.
- Keyboard-accessible dragging is a requirement, not an enhancement.