~/systems
How these systems work.
Four diagrams from projects I’ve built. They cover missed sync records, uncertain payouts, multiplayer scoring, and database deadlocks.
Each diagram highlights an invariant: a condition the implementation needs to preserve.
trace
erp-sync --keyset-drain
§V · FIG.01failure modewatermark = MINUTE-resolution timestamp
>1000 rows in one minute → overflow stranded silently fix →- composite keyset cursor(timestamp, primary-key)
- drain a saturated minutepage-by-page
- restart at a 1-minute overlap floorre-reads in-place edits
- idempotent upsert
INVARIANTNever advance the watermark unless accepted + rejected == rows_sent. Every sent row must be accounted for.
trace
payouts --exactly-once
§V · FIG.02transfer.execute()
HTTP 400provably rejectedDEFINITIVE failuremoney never moved
RELEASE fundssafe to re-claim
timeout · 409 · 429 · 5xxmight have succeededAMBIGUOUSkeep PENDING
reconcilewebhook · status-check · admin
resolvepaid|failed
INVARIANTRelease funds only on a provable failure. Keep an uncertain transfer pending until its status is confirmed.
trace
realtime --server-authoritative
§V · FIG.03$token- client requests join
- gateauth + payment + room membership
- scoped tokensubscribe / presence only
⊘ the correct answer is never sent to clients during a live question
$answer- answer submit
- atomic compare-and-setfirst-answer-wins guard
- server-authoritative scoring
- broadcast6 → 100+ subscribers
$round- round advance
- coordinator electiondeterministic leader + liveness takeover
- idempotent phase claim
INVARIANTThe server calculates scores and withholds the answer key during live questions. Six-player rooms can broadcast updates to more than 100 subscribers.
trace
locks --one-global-order
§V · FIG.04AB-BA cycleflow Abillswaits for ↓payments
flow Bpaymentswaits for ↓bills
each holds what the other wants → 40P01 fix →one global order- billssorted by bill number
- then the payment row
data-dependent lock setunlocked discovery read→lock in global order→revalidate under lock
INVARIANTA single global lock ordering across every money path, so the cycle that caused 40P01 cannot form.
For the business context and the rest of each project, see the case studies.