Design a software system for an ATM Machine that allows users to perform banking operations such as cash withdrawal, deposit, balance inquiry, and PIN management while ensuring security, concurrency, and consistency.
Functional Requirements (FR)
User & Account Management
•Authenticate users using ATM card number and PIN.
•Maintain account details: account number, balance, transaction history.
•Support multiple accounts per user.
Cash Withdrawal
•Allow users to withdraw cash in available denominations.
•Ensure sufficient balance in the account.
•Update account balance and ATM cash inventory.
Cash Deposit
•Accept cash deposits (may support cheque deposits optionally).
•Update account balance and ATM cash inventory.
Balance Inquiry
•Provide current account balance to the user.
PIN Management
•Allow users to change their PIN securely.
Transaction History
•Maintain transaction records: deposit, withdrawal, failed attempts.
Non-Functional Requirements (NFR)
•Security: PIN encryption, secure authentication, transaction authorization.
•Reliability: Ensure no loss of funds or inconsistent balances.
•Concurrency: Handle multiple ATMs accessing the same account simultaneously.
•Availability: ATM should handle downtime and network failures gracefully.
•Extensibility: Add support for multiple currencies, international cards, or mobile integration.
Core Entities & Attributes
Class / Entity Attributes / Methods
ATM atmId, location, cashInventory, dispenseCash(amount), acceptCash(amount)
Account accountId, userId, balance, transactions[], withdraw(amount), deposit(amount)
User userId, name, accounts[], authenticate(pin)
Card cardNumber, linkedAccountId, pin, validate(pin)
Transaction transactionId, accountId, type (withdraw/deposit), amount, timestamp, status
Bank bankId, accounts[], authorizeTransaction(transaction), updateBalance()
Key Operations / APIs
•authenticateUser(cardNumber, pin)
•withdrawCash(accountId, amount)
•depositCash(accountId, amount)
•checkBalance(accountId)
•changePin(cardNumber, oldPin, newPin)
•getTransactionHistory(accountId)
•replenishATM(atmId, cashAmount)
Design Considerations
Concurrency Handling
•Ensure atomic updates to account balances when multiple ATMs access the same account.
•Use locks or database transactions.
Security
•Encrypt PINs.
•Limit failed attempts (lock card after 3 attempts).
Cash Inventory Management
•Track denominations for withdrawal.
•Replenish ATM when cash is low.
Error Handling
•Handle insufficient balance, insufficient cash in ATM, network failures.
Design Patterns
•Command Pattern → Transactions as commands (execute and undo).
•Strategy Pattern → Different authentication methods (PIN, biometric).
•Singleton → ATM instance per location.
Example Workflow
1.User inserts card → ATM authenticates PIN.
2.User selects operation → withdraw 2000.
3.ATM verifies account balance and cash availability.
4.Dispense cash → update account balance and ATM cash inventory.
5.Record transaction and print receipt.
✅ This LLD problem tests:
•OOP class modeling (ATM, Account, Transaction, Card, User).
•Transaction safety, concurrency, and security.
•System extensibility for future features (multi-currency, biometrics, mobile integration).