Design ATM Machine
Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2023-10-26
Problem Statement
Designing the Low-Level Design of an ATM (Automated Teller Machine) system. The ATM should allow users to interact with their bank accounts through a physical machine that provides cash withdrawal, deposits, transfers, and balance inquiry while ensuring security and correctness.
Functional Requirements (FR)
Authentication
•Users insert an ATM card and authenticate with a PIN.
•If authentication fails (e.g., wrong PIN multiple times), the card should be blocked/ejected.
Account Operations
•Cash Withdrawal: Dispense requested amount if sufficient balance and ATM has enough cash.
•Cash Deposit: Accept cash and update account balance.
•Balance Inquiry: Show account balance.
•Fund Transfer: Transfer money between accounts.
ATM Operations
•Maintain cash inventory of different denominations.
•Dispense minimum number of notes during withdrawal.
•Reject invalid deposits.
•Print transaction receipts.
1.Session Management
•Each transaction session starts when the card is inserted and ends when the card is removed.
•Timeout/logout if no activity for a while.
2.Error Handling
•Handle cases like insufficient funds, insufficient ATM cash, network failure, invalid card, etc.
Non-Functional Requirements (NFR)
•Reliability: Must not lose transactions during failures.
•Security: PIN encryption, secure communication with bank servers.
•Availability: Should work 24/7 with fallback in case of server unavailability.
•Scalability: Support multiple ATM machines connected to central banking servers.
Core Entities & Attributes
ATM
•atmId, location, cashInventory (map<denomination, count>)
Card
•cardNumber, expiryDate, cvv, linkedAccount
User
•userId, name, accounts[], cards[]
Account
•accountId, accountType (savings/current), balance
Transaction
•transactionId, type (withdrawal, deposit, transfer, inquiry), amount, dateTime, status
Bank Server
•Validates card and PIN.
•Processes transactions and updates accounts.
Key Classes & Responsibilities
ATM
•Start/end session.
•Authenticate card & PIN.
•Interact with cash dispenser and deposit slot.
CashDispenser
•Holds notes inventory.
•Dispenses cash in denominations.
DepositSlot
•Accepts deposited cash.
Screen & Keypad
•User interface for instructions and inputs.
BankServerAPI
•Validate card & PIN.
•Execute transactions.
Transaction (abstract class)
•Subclasses: Withdrawal, Deposit, Transfer, BalanceInquiry.
APIs / Operations
•authenticateCard(cardNumber, pin)
•withdraw(accountId, amount)
•deposit(accountId, amount)
•transfer(fromAccountId, toAccountId, amount)
•getBalance(accountId)
•updateCashInventory(denomination, count)
Advanced Features (Optional / Bonus)
•Multi-currency support.
•Biometric authentication in addition to PIN.
•NFC/UPI-based cardless withdrawals.
•Fraud detection (e.g., unusual withdrawals).
•Remote monitoring of ATM health and cash levels.