An ATM (Automated Teller Machine) is a self-service banking machine that allows users to perform basic financial transactions such as withdrawing cash and checking account balances using a debit or credit card and a secure PIN, without needing to visit a bank branch.
They interface with backend banking systems to verify account details, authenticate users, and update balances in real-time.
In this chapter, we will explore the low-level design of ATM in detail.
Lets start by clarifying the requirements:
Before starting the design, it's important to ask thoughtful questions to uncover hidden assumptions, clarify ambiguities, and define the system's scope more precisely.
Here is an example of how a discussion between the candidate and the interviewer might unfold:
Candidate: What types of transactions should the ATM support?
Interviewer: The ATM should support cash withdrawal, deposit and balance inquiry.
Candidate: Should the ATM communicate with a central bank server to validate credentials, fetch account data, and perform transactions?
Interviewer: Yes, the ATM acts as a client. It should authenticate user card details and perform all account-related operations. For simplicity, you can assume this is a local call rather than a remote one.
Candidate: Can a user perform multiple transactions per session?
Interviewer: To keep things simple, assume only one transaction per session. The card should be ejected after each transaction.
Candidate: Do we need to support multiple account types per user, such as checking and savings?
Interviewer: No, let’s assume each user has only one account. However, a single account may be linked to multiple ATM cards.
Candidate: Should the ATM maintain an inventory of cash by denomination?
Interviewer: Yes. The ATM must maintain an internal inventory of cash and should only allow withdrawals if sufficient cash is available in the appropriate denominations.
Candidate: When dispensing cash, should the ATM prioritize certain denominations—for example, prefer higher denominations first?
Interviewer: Yes, it should try to dispense the requested amount using the highest available denominations first.
Candidate: Should we enforce daily transaction or withdrawal limits per user?
Interviewer: Let’s skip that for now. Assume there are no limits on the number or amount of transactions per day.
After gathering the details, we can summarize the key system requirements.
After the requirements are clear, lets identify the core entities/objects we will have in our system.