System Design & Databases for PMs
From the whiteboard to the business: how an app like Zepto sells the last item safely. SQL, NoSQL, Cassandra, ACID, CAP, Paxos, vector databases, geolocation, queues and interview practice, in plain words.
System Design & Databases for PMs
From the whiteboard to the business: how an app like Zepto sells the last item safely. SQL, NoSQL, Cassandra, ACID, CAP, Paxos, vector databases, geolocation, queues and interview practice, in plain words.
In one line
System design is how an app's parts (screens, services, databases, payments, AI) work together so it stays fast, correct and affordable. PMs need it to ask the right questions, price trade-offs and explain decisions.
The 17 classes
The big picture: what happens when you tap Buy
See every box on the whiteboard in plain words.
- Every tap triggers many systems working together.
- Each box has one job; failures happen between boxes.
- You do not build it, but you must be able to question it.
Why PMs need this: the business view
Connect technical choices to money, trust and speed.
- Technical choices are business trade-offs.
- Protect money, stock and personal data first.
- Ask for p95/p99 and availability targets in every spec.
SQL databases in plain words
Understand tables, keys, joins and indexes without code fear.
- SQL = tables with keys, queried by joins.
- Indexes trade write speed for read speed.
- Default to SQL for money and orders.
ACID: why money and stock stay correct
Learn the four promises of a database transaction.
- Transaction = all-or-nothing group of steps.
- ACID protects money and stock.
- Isolation is the promise behind 'no double selling'.
NoSQL: the main types and when to use them
Pick between key-value, document, wide-column and graph stores.
- NoSQL has four main shapes plus vector.
- It trades some consistency for scale and flexibility.
- Most products use SQL and NoSQL together.
Cassandra explained for PMs
Understand a masterless, always-on database.
- Cassandra = equal nodes in a ring, data copied several times.
- You choose consistency per query.
- Great for high-volume writes, poor for joins and strict transactions.
- LWT adds safe check-then-write using Paxos, but is slow: use it sparingly.
Scaling data: replication, sharding, caching, CAP and BASE
Know how products stay fast and available as they grow.
- Replication, sharding, caching and indexing are the four scaling tools.
- CAP: during a network split you cannot have both perfect consistency and perfect availability.
- Use strong consistency only where wrong data costs money or trust.
Services and servers: what happens when volume grows
Follow the app from 100 users to 10 million without the jargon.
- Scale by adding identical stateless servers behind a load balancer.
- Protect the database with caches, replicas and queues.
- Find the next bottleneck with load tests before the sale, not during it.
The inventory problem: never sell the last item twice
Walk the whiteboard's qty = 1 problem and its fixes.
- The last-item problem is a race; fix it with one atomic step.
- Holds with a timeout balance sales and fairness.
- Idempotency keys stop double orders and double charges.
The full user journey: every step, system and risk
Follow one order from opening the app to delivery and refunds.
- Every journey step touches different systems and data stores.
- Each step has a named risk and a named protection.
- An order state machine keeps messy real life under control.
Payment checkout in detail
Understand how a payment really moves, and why it is asynchronous.
- The server-side webhook, not the app screen, decides success.
- Create the order first as PENDING, then confirm after verified payment.
- Reconciliation catches whatever the real-time flow misses.
Never twice: no repeated order, payment or customer
Use layered protections so duplicates cannot happen, even with retries.
- Idempotency key plus a unique database constraint is the core defence.
- Make every webhook and queue consumer idempotent.
- Protect customers too: unique verified phone, OTP, merge process.
Consensus: Paxos and Raft without the maths
Understand why servers must agree and how they do it.
- Consensus = servers agreeing on one value despite failures.
- Majority (quorum) is the core idea; odd numbers of nodes are best.
- Strong agreement costs latency, a trade-off PMs must price in.
Vector databases, geolocation and the AI parts
Add meaning search, location and chatbots to the design.
- Vector DBs search by meaning, not exact words.
- RAG uses a vector DB to ground chatbot answers.
- Geohash and H3 make 'nearest store' fast.
The supporting cast: APIs, queues, events and observability
Know the other terms that appear in every design review.
- Know the vocabulary: API, queue, event, webhook, cache, observability.
- Queues and events absorb spikes but add complexity.
- Estimate scale with simple arithmetic before debating tools.
Case study and PM interview answer: design inventory and checkout
Practise a complete answer from requirements to trade-offs.
- Answer in a fixed order: clarify, metrics, scale, design, deep dive, failures, trade-offs, rollout.
- Name the hard part and solve it.
- Tie every choice to a user or business outcome.
Final project: write a one-page system brief
Produce a PM-friendly design brief you can share with engineers.
- A good brief is short, numeric and honest about trade-offs.
- Engineers improve a draft faster than a blank page.
- Keep the brief updated as the product scales.
Further reading and tools
Interview questions
Why do PMs need to know SQL vs NoSQL?
Because the choice affects consistency, cost, speed and features. PMs should know SQL is best for money and orders, NoSQL for scale and flexibility, and most products use both.
Explain ACID to a non-technical person.
It is four promises that make a transaction safe: all-or-nothing, rules always hold, simultaneous users do not interfere, and confirmed data survives a crash.
What is the CAP theorem?
In a network split a system must pick between consistency (same truth everywhere, may refuse requests) and availability (always answer, maybe stale). Pick consistency for payments, availability for browsing.
What is Cassandra good at?
Very high write volume, multi-region and always-on use cases like messages, feeds and event logs. It is weak at joins and strict transactions.
What is Paxos and why does it matter?
An algorithm that lets servers agree on one value using a majority, even with failures. It underpins reliable leaders, locks and strongly consistent databases, at the cost of some latency.
Paxos vs Raft?
Both achieve consensus. Raft is simpler to understand and implement, with a clear leader and elections; Paxos is the older, more general form.
How do you prevent selling the last item twice?
Make check and decrement one atomic step, use holds with timeouts, add idempotency keys, and reconcile stock with vendors.
What is idempotency and why for payments?
Repeating a request has the same effect as doing it once. It stops double charges when users retry or a payment callback arrives twice.