PrepZone Logo
PrepZone

Design an ATM System

Card session, PIN, cash dispensing, and ledger updates.

Read these first

Why this matters

  • Customer inserts card and enters PIN to start authenticated session
  • Scope — what "Session lifecycle" covers inside ATM System and what it does not
  • Scope — what "Dispenser chain" covers inside ATM System and what it does not
  • Scope — what "Concurrency" covers inside ATM System and what it does not
  • Machine problems test State, Strategy, and facade coordination.
Client / API
FacadeSingle entry point
EntitiesDomain objects
State / Strategy
Most LLD machines expose a facade that coordinates entities and state transitions.

CampusOS context

CampusOS is the fictional smart-campus platform used across this track. Treat this module as a real product slice:

Context

  • Belongs to CampusOS — same naming and design vocabulary as parking, library, and booking modules
  • Scope is one JVM — persistence is in-memory or behind a repository interface
  • Goal is a class diagram + core Java that an interviewer can follow in 35–45 minutes
  • Extension paragraph at the end links to System Design when scale exceeds one process

Requirements snapshot

Functional requirements

  • Customer inserts card and enters PIN to start authenticated session
  • Check balance, withdraw cash, deposit (optional), transfer between accounts
  • Cash dispenser tracks note counts per denomination
  • Session timeout ends authenticated context
  • Failed PIN attempts lock card after threshold
  • Print receipt for each successful transaction

Non-functional requirements

  • Single JVM, in-process design for this LLD article
  • Core flows testable with in-memory repositories
  • Extension points for new rules without editing central god classes
  • Clear public API on facade/service layer
  • CampusOS extension links to System Design when scale demands distribution

Overview

This CampusOS module designs ATM System as a production-ready in-process service. Read requirements point-by-point before drawing classes.

Requirements

Points to cover

  • Customer inserts card and enters PIN to start authenticated session
  • Check balance, withdraw cash, deposit (optional), transfer between accounts
  • Cash dispenser tracks note counts per denomination
  • Session timeout ends authenticated context
  • Failed PIN attempts lock card after threshold
  • Print receipt for each successful transaction

Session lifecycle

Points to cover

  • Scope — what "Session lifecycle" covers inside ATM System and what it does not
  • Classes — name 2–4 classes/interfaces responsible for this slice
  • Flow — step-by-step: trigger → validation → state change → side effect
  • Edge cases — invalid input, concurrent access, empty state, timeout
  • Pattern — Strategy, State, Observer, or Facade if it fits naturally
  • Test hook — one scenario an interviewer will ask you to walk through

Dispenser chain

Points to cover

  • Scope — what "Dispenser chain" covers inside ATM System and what it does not
  • Classes — name 2–4 classes/interfaces responsible for this slice
  • Flow — step-by-step: trigger → validation → state change → side effect
  • Edge cases — invalid input, concurrent access, empty state, timeout
  • Pattern — Strategy, State, Observer, or Facade if it fits naturally
  • Test hook — one scenario an interviewer will ask you to walk through

Concurrency

Points to cover

  • Scope — what "Concurrency" covers inside ATM System and what it does not
  • Classes — name 2–4 classes/interfaces responsible for this slice
  • Flow — step-by-step: trigger → validation → state change → side effect
  • Edge cases — invalid input, concurrent access, empty state, timeout
  • Pattern — Strategy, State, Observer, or Facade if it fits naturally
  • Test hook — one scenario an interviewer will ask you to walk through
Java
// CampusOS — AtmSystem facade (keep thin)
public final class AtmSystemService {
    private final AtmSystemRepository repository;

    public AtmSystemService(AtmSystemRepository repository) {
        this.repository = repository;
    }

    /** Orchestrate: validate → domain rules → persist → return result */
    public Result handle(Request request) {
        request.validate();
        var domain = DomainModel.from(request);
        domain.applyRules();
        return repository.save(domain);
    }
}

Quick recall

Everything you need if you only revisit this box.

  1. Requirements — review this slice before mock interviews.
  2. Session lifecycle — review this slice before mock interviews.
  3. Dispenser chain — review this slice before mock interviews.
  4. Concurrency — review this slice before mock interviews.

CampusOS extension

When this outgrows one JVM

  • Shard inventory or state by campus ID or geographic region
  • Push notifications, payments, and search to dedicated services (System Design track)
  • Use message queues for async side effects (email, analytics)
  • The class diagram you drew here becomes one box on the HLD architecture diagram

Test yourself

Answer these before moving on — recall is what makes it stick.