Skip to main content
Back to track
Backend Engineer

API & low-level design

8 classic design questions, each answered with the same framework: requirements, entities and classes, API, core logic and edge cases. Try designing the classes and endpoints yourself before reading the answer.

01

Design a REST API for an online bookstore

EasyRESTPaginationStatus codesVersioning

Design the REST API for an online bookstore: customers browse and search books, read reviews, manage a cart and place orders; admins manage the catalog.

A typical framing: "Mobile and web clients and some partner integrations will use this API. Walk me through the resources and endpoints, what requests and responses look like, how you handle errors, pagination and versioning, and how you keep it safe to retry."

02

Design a parking lot system

EasyOOPSOLIDStrategy patternConcurrency

Design the classes for a parking lot system: a multi-level garage with different spot sizes, where vehicles get a ticket on entry, park in a suitable spot, and pay on exit.

A typical framing: "The lot has several floors with motorcycle, compact and large spots. Entry gates issue tickets, exit gates take payment. Show me the main classes, how a spot is assigned, how the fee is calculated, and how you'd extend it later."

03

Design an LRU cache

MediumHash mapLinked listTTLThread safety

Design an LRU (least recently used) cache: a fixed-capacity key-value store where get and put run in O(1), and when the cache is full, the entry that was used least recently is evicted.

A typical framing: "Implement the class, explain the data structures, then tell me how you'd add expiration (TTL), make it safe for many threads, and what changes if the cache has to be shared across servers."

04

Design a rate limiter

MediumToken bucketSliding windowRedisMiddleware

Design a rate limiter: a component that caps how many requests a client can make in a time window, for example 100 requests per minute per API key, and rejects the rest.

A typical framing: "Our public API gets abused by a few clients. Design a rate limiter we can put in front of every endpoint, with different limits per plan. First as a class in one process, then tell me what changes when we run 50 API servers."

05

Design a movie ticket booking system

MediumConcurrencyLockingTransactionsState machine

Design a movie ticket booking system like BookMyShow or a cinema chain's app: users pick a movie, a showtime and specific seats, hold them for a few minutes while paying, and get a confirmed booking.

A typical framing: "A popular premiere opens for booking at 10:00 and thousands of people try to grab the same seats. Two people must never get the same seat. Seats someone abandons mid-payment should become free again. Show me the classes, the API and how you handle the concurrency."

06

Design an expense-sharing app like Splitwise: friends and groups record shared expenses, the app tracks who owes whom, and suggests the fewest payments to settle up.

A typical framing: "Four friends go on a trip. Different people pay for the hotel, dinners and taxis, sometimes split equally, sometimes by exact amounts or percentages. Design the classes and API, show how balances are calculated, and how you'd simplify the debts."

07

Design an in-memory pub/sub message queue

HardPub/subMessage queueDelivery guaranteesBackpressure

Design an in-memory pub/sub message queue: producers publish messages to topics, and consumers subscribe to topics and process the messages, each at its own pace.

A typical framing: "Build a small message broker as a library, like a mini Kafka or RabbitMQ inside one process. Several producers and consumers run concurrently. Explain your classes, the delivery guarantees you offer, what happens when a consumer is slow or fails, and how you'd make it durable."

08

Design a payments API (like Stripe)

HardIdempotencyWebhooksState machineConsistency

Design a payments API like Stripe's: merchants create payments for their customers, the API charges cards through banks and card networks, and merchants learn the outcome, including refunds and failures.

A typical framing: "Merchants integrate with our API from their checkout. Networks time out, clients retry, banks answer late. Money must never be charged twice or lost. Design the resources, the payment lifecycle, the idempotency story and how merchants get notified."