Model a LIVE Gifting Wallet With Coins, Gifts and Diamonds

Last updated: November 29, 2026

Quick Overview

Design the classes for TikTok LIVE gifting: viewers buy coins, send catalog gifts priced in coins to a creator during a LIVE session, and creators accrue diamonds they can later cash out. Implement the core send_gift flow with validation and an auditable ledger.

TikTok
Software Engineering Fundamentals
Software Engineer
TikTok
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


Design the classes for TikTok LIVE gifting: viewers buy coins, send catalog gifts priced in coins to a creator during a LIVE session, and creators accrue diamonds they can later cash out. Implement the core send_gift flow with validation and an auditable ledger.

Object-oriented design rounds at TikTok often use LIVE gifting because it has clear entities, money-like invariants and a conversion rule between currencies. The interviewer checks class responsibilities, invariants such as non-negative balances, and whether every balance change is recorded in a ledger.

What the Interviewer Expects
  • Separates entities: Wallet, GiftCatalog, LiveSession, Ledger, GiftService
  • Keeps balances in integer minor units and never in floats
  • Records every balance change as an append-only ledger entry
  • Validates inputs: active session, known gift, sufficient balance, no self-gifting
  • Makes the conversion rule from coins to diamonds explicit and configurable
Key Topics to Cover
object-oriented design
invariants
ledger
encapsulation
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you make send_gift atomic across two wallets stored in a database?
  • How would you support combo gifts sent 50 times in a row efficiently?
  • How would you model refunds when a payment is charged back?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • Viewers hold coins; creators hold diamonds.
  • send_gift(viewer, creator, gift_id, session_id, count) debits coins and credits diamonds at a configured share.
  • Reject if the session is not live, t...
High-Level Design

Classes:

  • Wallet: owner, coin and diamond balances; only debit/credit methods mutate, and they enforce non-negativity.
  • GiftCatalog: gift_id to coin price.
  • LiveSession: id, creator, `is_...

Submit Your Answer
Markdown supported