PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/System Design/Coinbase

Design account system with cashback

Last updated: May 15, 2026

Quick Overview

This question evaluates concurrent system design competencies including atomic balance updates, delayed event scheduling (cashback), transactional correctness under concurrency, and leaderboard aggregation for transfer spenders.

  • medium
  • Coinbase
  • System Design
  • Software Engineer

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: This question evaluates concurrent system design competencies including atomic balance updates, delayed event scheduling (cashback), transactional correctness under concurrency, and leaderboard aggregation for transfer spenders.

Related Interview Questions

  • Design Crypto Order Routing - Coinbase (hard)
  • Design a crypto trading web frontend - Coinbase (hard)
  • Design query pagination for large datasets - Coinbase (medium)
  • Design a food delivery system - Coinbase (medium)
  • Design real-time crypto prices homepage - Coinbase (hard)
Coinbase logo
Coinbase
Jul 29, 2025, 8:05 AM
Software Engineer
Take-home Project
System Design
91
0

System Design: Account Management with Transfers, Payments, and Cashback

You are to design and implement an in-memory account management service that supports atomic balance updates, delayed cashback, and a leaderboard of top transfer spenders. Assume integer timestamps (e.g., seconds since epoch) and integer amounts in the smallest currency unit (e.g., cents).

Assumptions to make explicit:

  • Amounts must be positive integers; operations with non-positive amounts fail.
  • Timestamps are provided by the caller and should be used to determine due cashback.
  • 2% cashback is computed as floor(0.02 × amount) (integer math: (amount * 2) / 100 ).
  • Return Optional.empty() for any failure condition (e.g., missing account, insufficient funds, invalid input), unless otherwise stated.
  • Transfer spending for topSpenders counts only outgoing transfer amounts from the transfer operation and excludes pay and cashback.

Implement the following operations with the specified semantics:

  1. createAccount(int timestamp, String accountId)
    • Create a new account with 0 balance.
    • Return false if the account already exists; otherwise true.
  2. deposit(int timestamp, String accountId, int amount)
    • Deposit amount into an existing account.
    • Return Optional.of(newBalance) on success.
    • Return Optional.empty() if the account does not exist or amount ≤ 0.
  3. transfer(int timestamp, String sourceAccountId, String targetAccountId, int amount)
    • Transfer amount between two distinct existing accounts if the source has sufficient balance.
    • On success, return Optional.of(sourceNewBalance).
    • Return Optional.empty() if any precondition fails (missing accounts, identical accounts, amount ≤ 0, insufficient funds).
    • Increase only the source account's cumulative outgoing transfer total (used for topSpenders).
  4. topSpenders(int timestamp, int n)
    • Return a List <String> of up to n accountIds with the highest cumulative outgoing transfer totals.
    • If fewer than n accounts exist, return all.
    • Use a deterministic tie-break (e.g., lexicographic accountId ascending).
  5. pay(int timestamp, String accountId, int amount)
    • Deduct amount from the account if sufficient funds; return Optional.of(uniquePaymentId) on success.
    • Return Optional.empty() on failure (missing account, amount ≤ 0, insufficient funds).
    • Automatically schedule 2% cashback after 24 hours (86,400 seconds) from the provided timestamp.
    • The cashback credit must not affect topSpenders.
  6. getPaymentStatus(int timestamp, String accountId, String paymentId)
    • Return Optional.of("IN_PROGRESS") if the cashback has not yet been applied.
    • Return Optional.of("CASHBACK_RECEIVED") after the cashback is applied.
    • Return Optional.empty() if the account or paymentId is invalid or mismatched.

Additional requirements:

  • Ensure atomicity and correctness under concurrency (e.g., transfers must not lose or double-count funds).
  • Ensure each call first processes any due cashbacks up to the provided timestamp.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More Coinbase•More Software Engineer•Coinbase Software Engineer•Coinbase System Design•Software Engineer System Design
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.