KatInterview

Design a Hospitality Platform Wallet with Authorizations and Payouts

System DesignModel answer
HardModel answerSystem Designsystem-designledgerfintech

Last updated

Design a robust multi-currency ledger and wallet architecture supporting holds, captures, host payouts, idempotent processing, and automated reconciliation.

Design an end-to-end wallet and ledger infrastructure for a two-sided marketplace (such as a lodging/rental platform).

System Scope and Requirements

  1. Account Structure & Ledger Core:

    • Implement an append-only, double-entry financial ledger.
    • Maintain total vs. spendable balances across multiple fiat currencies.
    • Never allow spendable balances to drop below zero.
  2. Transaction Lifecycle:

    • Holds / Authorizations: Reserve funds when a guest creates a booking request.
    • Captures: Settle held funds upon guest check-in.
    • Cancellations / Releases: Expire or release holds if a reservation is canceled.
    • Refunds: Support partial and complete post-capture refunds to guests.
    • Payouts & Split Clearing: Deduct platform service fees and taxes before executing host disbursements.
  3. Multi-Currency & FX:

    • Handle foreign currency conversions (e.g., guest pays in EUR, host receives USD).
    • Define exact handling for exchange rate lock-ins, fixed-point integer arithmetic, and currency rounding rules.
  4. Consistency & Reliability:

    • Ensure idempotency for all mutating requests using unique client-provided keys.
    • Maintain safety against high-concurrency race conditions (e.g., dual capture or double spend attempts).
    • Design a background reconciliation engine to verify mathematical integrity across accounts and sub-ledgers.
  5. Architecture Specifications:

    • Detail data models (tables, schemas, relational constraints, and database isolation levels).
    • Outline API interface definitions and state transitions for holds and captures.

Hints

Hint 1

Use double-entry bookkeeping rules: every movement of funds consists of balanced debit and credit entries across immutable entries. Never rely on mutating balance rows without an underlying ledger record.

Hint 2

Distinguish clearly between 'Total Balance', 'Pending Hold Amount', and 'Spendable Balance'. Spendable balance is calculated as (Total - Pending Holds).

Hint 3

Ensure idempotency at the database level by placing a UNIQUE constraint on (client_id, idempotency_key) paired with transaction-level locking (e.g., SELECT ... FOR UPDATE or serializable isolation).