Preparing your design workspace

Loading the problem and your saved attempt…

Design and Implement an ATM Machine

Design ATM authentication, balance enquiry, withdrawals, terminal transaction states, concurrency, idempotency, and fail-closed cash-delivery recovery.

Design and implement the low-level model for an ATM machine covering card validation and PIN authentication, balance enquiry, cash withdrawal, transaction status, insufficient balance, insufficient ATM cash, invalid PIN or blocked card, rollback, duplicate prevention, synchronization, and extension to new transaction types.

For this exercise, assume one physical ATM admits one card session at a time. A withdrawal is identified by (cardId, accountId, requestId); requestId is unique only within that card/account scope.

Its state machine is RECEIVED -> FUNDS_RESERVED -> CASH_DELIVERY_STARTED -> COMPLETED, with terminal alternatives FAILED_NO_DEBIT, COMPENSATED, or DELIVERY_UNKNOWN. Account reservation and cash inventory changes use idempotent operations.

If the dispenser definitively reports NOT_DELIVERED, release cash and compensate reserved funds. If delivery outcome is ambiguous after the command starts, enter DELIVERY_UNKNOWN: do not dispense again and do not compensate until reconciliation proves non-delivery.

As the authored extension pressure, add a mini-statement inquiry that returns a bounded list of recent account entries without reserving funds or cash. Deposits, transfers, denomination optimization, networking protocols, and settlement are outside scope.