Design account system with cashback
Company: Coinbase
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Take-home Project
##### Question
Design an account management system that supports the following operations with correct return values and constraints:
1) createAccount(int timestamp, String accountId) – create an account, return false if account exists, otherwise true;
2) deposit(int timestamp, String accountId, int amount) – deposit into an existing account, return Optional.of(balance) on success, Optional.empty() if account does not exist;
3) transfer(int timestamp, String sourceAccountId, String targetAccountId, int amount) – transfer between two distinct existing accounts when source has sufficient balance, return Optional.of(newBalance) on success, Optional.empty() otherwise;
4) List<String> topSpenders(int timestamp, int n) – return the n accounts with the highest total outgoing transfer amounts (or all if fewer than n);
5) Optional<String> pay(int timestamp, String accountId, int amount) – deduct amount from an account, return unique paymentId on success, Optional.empty() on failure (account missing or insufficient funds), automatically schedule 2% cashback after 24 hours which does not count toward topSpenders;
6) Optional<String> getPaymentStatus(int timestamp, String accountId, String paymentId) – query payment status, returning IN_PROGRESS or CASHBACK_RECEIVED when applicable, or Optional.empty() for invalid account/paymentId.
Quick Answer: Design account system with cashback evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.