Double-entry accounting atomicity and floors
Your task
Design the core write path for a double-entry accounting engine backing a neobank. Every money movement creates ≥2 postings that must sum to zero per transaction and per currency, and no account may go below its allowed floor (asset accounts ≥ 0; liability/clearing accounts can be negative). Peak is ~5,000 transactions/sec. Explain how you enforce the balance-to-zero and floor invariants atomically and how you keep it correct under concurrent transfers touching the same accounts.
It covers
- Debit credit balance
- Transaction atomicity
- Invariants