35 min read Architectural Framework Part 1 · Lesson 2 (2 / 12)
Course 11: Part 1 — System Design Mindset & Architectural Foundations

Lesson 11.2 — How to Approach and Design Any System

Escaping the technology-first trap to master a battle-tested 12-step framework for decomposing, scoping, calculating, and architecting any complex system from a blank canvas.

Core Competencies You Will Master

Avoiding the Tech Trap: Why jumping directly into Redis, Kafka, or Kubernetes on Day 1 is architectural malpractice.
Back-of-the-Envelope Math: Estimating DAU, read:write ratios, peak QPS, daily storage ingestion, and network egress without guesswork.
Data Modeling & API Contracts: Deconstructing core entities, isolating domain boundaries, and defining clean RESTful endpoints.
Failure-First Decoupling: Distinguishing synchronous paths from asynchronous message queues and designing for inevitable node crashes.
1

The Core Dilemma: The Technology Trap

In the previous lesson, we established what System Design is and why it matters. Now comes the most pivotal real-world question:

“When assigned to design a brand-new system from scratch—whether in a production architectural review or a senior engineering interview—where do we actually begin?”

Most novice engineers fall headfirst into the Technology-First Trap. The moment they are handed a prompt, their minds race through an index of trendy tools:

The Novice Engineer's Immediate Reaction (The Tech Trap):

  • “Should we use PostgreSQL or MongoDB for this?”
  • “Do we need a Redis caching cluster and Apache Kafka on Day 1?”
  • “Should we break this into 25 microservices running on Kubernetes?”
  • “Is AWS or Google Cloud better suited to scale this globally?”

Senior Principal Architects never begin this way. Their foundational axiom is simple:

“System Design does NOT begin with technology. System Design begins with deeply understanding the problem, defining its boundaries, and uncovering its operational constraints. Technology is merely the final implementation detail.”

Today, we will dissect the complete step-by-step thinking process using a tangible, real-world case study: “Design an On-Demand Food Delivery Platform (e.g., DoorDash, Uber Eats, or Foodpanda).”

2

Step 1 — Clarify and Scope the Problem

The prompt “Build a food delivery app” is catastrophically ambiguous. Jumping straight to sketching server diagrams is equivalent to building a foundation without knowing whether you are erecting a garden shed or a 50-story commercial tower.

Your first responsibility is to eliminate ambiguity by asking scoping questions:

Who are the actors?
Are we designing exclusively for hungry customers, or do we need portals for restaurant operators and delivery couriers as well?
What is the geographical scope?
Is this operating inside a single metropolitan city (e.g., Dhaka or New York), or is it a multi-country, planetary platform with geo-fencing?
How granular is tracking?
Does the user require real-time map GPS updates every 3 seconds, or are discrete status transitions (Cooking → Out for Delivery → Delivered) sufficient?
What payment mechanisms?
Cash on delivery, or synchronous tokenized credit card and mobile wallet integrations requiring strict PCI-DSS compliance?
The Golden Rule: The sharper your problem definition, the less wasted complexity your architecture will harbor.
3

Step 2 — Define Functional Requirements

Next, we explicitly enumerate: “What discrete capabilities must the system perform?”

Our food delivery system involves three primary human actors:

1. Customer Capabilities
  • Register and log in securely via mobile phone OTP or email credentials.
  • Browse and search nearby restaurants within a 5-kilometer radius.
  • Inspect restaurant menus, customize items, and manage an active cart.
  • Execute online payment and dispatch an order with delivery address coordinates.
  • Track live order status progression and view the courier's GPS location.
2. Restaurant Partner Capabilities
  • Manage restaurant profile, operating hours, and dish catalog availability.
  • Receive real-time incoming order alerts with Accept / Reject toggles.
  • Update cooking preparation progress and notify couriers when food is packed.
3. Delivery Rider Capabilities
  • Receive nearby delivery dispatch notifications and accept jobs.
  • Navigate turn-by-turn routes between restaurant pickup and customer drop-off.
  • Stream GPS coordinate telemetry every 5 to 10 seconds.
  • Confirm handoff and mark the order successfully delivered.
4

Step 3 — Establish Non-Functional Requirements (NFRs)

Now we define the operational boundaries and performance constraints under stress:

NFR Pillar Target Specification Architectural Impact
Latency (Speed) Restaurant search and catalog load must return in < 150ms. Mandates in-memory caching (Redis) and spatial indexing (PostGIS/GeoHashing).
Consistency (Integrity) Strict transactional ACID consistency on checkout; zero payment double-charges. Requires relational database transactions and idempotency keys on payment webhooks.
Availability (Uptime) 99.99% availability (< 52 minutes unplanned downtime per year), especially during lunch/dinner spikes. Requires stateless application clusters behind automated load balancers across multiple Availability Zones.
Scalability (Elasticity) Gracefully absorb 5x traffic surges during severe storms or major holiday evenings. Demands auto-scaling groups and decoupled asynchronous message queues.
5

Step 4 — Capacity Estimation: Back-of-the-Envelope Math

Engineering without estimation is guesswork. We do not need high-precision decimals; we need rough order-of-magnitude calculations to drive our structural decisions:

// CORE HYPOTHETICAL ASSUMPTIONS
Total Registered Users: 1,000,000 (1 Million)
Daily Active Users (DAU): 200,000 (200K)
Total Orders Per Day: 50,000 completed orders
Peak Order Window: 4 peak hours/day (12–2 PM lunch, 8–10 PM dinner)
// 1. THROUGHPUT & QPS (QUERIES PER SECOND)
Seconds in 1 Day = 86,400 seconds ≈ 86,000s
Average Write QPS (Orders) = 50,000 / 86,400 ≈ 0.58 QPS (Modest!)
Users browse menus far more than they buy: Read:Write Ratio = 20:1
Average Read QPS = 0.58 × 20 ≈ 12 QPS
Peak Traffic Multiplier:
80% of daily orders concentrate within the 4 peak hours (14,400 seconds):
Peak Write QPS = (50,000 × 0.80) / 14,400 ≈ 2.8 QPS ≈ 3 orders/sec
Peak Menu Read QPS = 3 × 20 ≈ 60 QPS
Live courier telemetry (1,000 riders pinging every 5s) = 200 QPS
Peak System API QPS ≈ 1,500 – 3,000 requests/sec
// 2. STORAGE ESTIMATION
Average Order Record Size (JSON, coordinates, lines) ≈ 2 KB
Daily Order Ingestion = 50,000 × 2 KB = 100,000 KB ≈ 100 MB/day
Annual Storage = 100 MB × 365 ≈ 36.5 GB/year
5-Year Total Storage = 36.5 GB × 5 ≈ 182.5 GB
✓ ARCHITECTURAL VERDICT: 182 GB easily resides on a single commodity NVMe SSD in a managed PostgreSQL instance! No expensive distributed NoSQL sharding cluster is necessary on Day 1!

Notice the power of this calculation: before doing math, you might have imagined needing a massive 50-node Cassandra cluster. Back-of-the-envelope math proved that your primary challenge is not storage capacity, but peak connection handling and memory caching.

6

Step 5 — Identify Core Data Entities & Relationships

Before writing code or configuring infrastructure, you must model the fundamental entities that form your system's data plane:

User Entity
id: UUID (PK)
name: String
phone: String (Indexed)
addresses: JSONB
created_at: Timestamp
Restaurant Entity
id: UUID (PK)
name: String
lat: Float, lng: Float (Spatial)
is_active: Boolean
rating: Decimal
Menu Item Entity
id: UUID (PK)
restaurant_id: UUID (FK)
title: String
price_cents: Integer
in_stock: Boolean
Order Entity
id: UUID (PK)
customer_id: UUID (FK)
restaurant_id: UUID (FK)
status: OrderStatusEnum
total_cents: Integer
Delivery Entity
id: UUID (PK)
order_id: UUID (FK, Unique)
rider_id: UUID (FK)
rider_lat, rider_lng: Float
status: DeliveryStatusEnum
Payment Entity
id: UUID (PK)
order_id: UUID (FK)
idempotency_key: String
gateway_ref: String
status: PaymentStatusEnum
7

Step 6 & 7 — Basic Data Flow & API Contracts

Clients interact with your backend via explicit interface contracts. Defining RESTful endpoints enforces clear separation between client presentations and domain business logic:

GET /api/v1/restaurants?lat=23.78&lng=90.41&radius_km=5
Discover active open restaurants within a 5km radius using spatial database queries.
GET /api/v1/restaurants/:id/menu
Fetch catalog categories and dish prices (cached in Redis with 15-minute TTL).
POST /api/v1/orders
Create an order with cart items, delivery coordinates, and an Idempotency-Key header to prevent double submission.
PATCH /api/v1/riders/:id/location
Stream courier GPS updates to an in-memory geo-store (Redis GEOADD).
8

Step 8 — Draft the Initial Architecture Blueprint

With our requirements, estimates, and data contracts established, we sketch our high-level architecture:

// HIGH-LEVEL ARCHITECTURAL BLUEPRINT
               [ Mobile Customers ]        [ Restaurant Portals ]        [ Courier Riders ]
                        │                          │                           │
                        └──────────────────────────┼───────────────────────────┘
                                                   ▼
                                      [ API Gateway / Reverse Proxy ]
                                                   │
                                                   ▼
                                    [ Food Delivery App Servers ]
                                                   │
                        ┌──────────────────────────┴──────────────────────────┐
                        ▼                                                     ▼
             [ PostgreSQL Database ]                                 [ External Services ]
        (Users, Orders, Menus, Payments)                           (Stripe, bKash, Maps API)
        

Now we possess a structural skeleton. The architect's true work begins: “Where will this break under real-world traffic?”

9

Step 9 & 10 — Identify Bottlenecks & Scale Each Tier

We systematically pressure-test every node:

1. App Server CPU Exhaustion (Peak Lunch Surge)

Vulnerability: 25,000 concurrent connection requests will exhaust thread pools on a single node.
Solution: Enforce Stateless Architecture (store sessions in Redis, not in process memory) and place an automated Load Balancer (NGINX / AWS ALB) in front to distribute traffic across 3 to 6 auto-scaling nodes.

2. Database Read Contention (Repetitive Menu Queries)

Vulnerability: Thousands of users repeatedly query the same top 50 restaurants, exhausting disk IOPS.
Solution: Introduce a Redis Cache-Aside Layer. Restaurant menus change only a few times per week. Caching active menus in RAM with a 15-minute TTL serves 95% of reads in 2 milliseconds, insulating the database.

10

Step 11 — Isolate Synchronous vs. Asynchronous Workflows

One of the most transformative architectural skills is recognizing what work must complete synchronously versus what work can be safely deferred asynchronously.

When a customer taps “Place Order”, they need immediate confirmation that their payment cleared and their order was recorded:

The Anti-Pattern: Blocking Synchronous Flow

Order saved → Payment charged → SMS gateway contacted → PDF invoice generated → Restaurant tablet alerted → Analytics logged → Customer finally gets a response.
Result: 3.5 seconds of spinning loading wheels! If the third-party SMS vendor is slow or down, the entire customer order fails!

The Modern Pattern: Decoupled Asynchronous Queue

Save order record → Emit an OrderCreated event into a Message Queue (Kafka / RabbitMQ) → Return HTTP 201 Created to the user in < 75ms!
Independent background worker fleets consume events from the queue to dispatch SMS, render invoices, and push alerts without blocking the user.

11

Step 12 & 13 — Failure-First Resilience & Day-One Security

In distributed systems, failures are not rare anomalies; they are normal operational occurrences:

“Assume everything will fail. Anything that can fail, will eventually fail in production.”
Application Node Death: If Node 2 suffers an out-of-memory crash, the Load Balancer health check probe evicts it in < 2 seconds, redirecting incoming requests to healthy instances.
Primary Database Outage: If the primary write database hardware burns out, an automated standby replica in another Availability Zone is promoted to primary within 30 seconds.
Broken Object-Level Authorization (BOLA / IDOR): If a user changes their browser URL to GET /api/v1/orders/5002, backend middleware must cryptographically verify that the order's customer_id matches the session token. Hiding a button in the frontend is not security.
12

Step 14 — Observability: Logs, Metrics, and Distributed Traces

Deploying without telemetry leaves your team flying blind during an outage:

Structured Logs
JSON-formatted event streams tagged with request IDs, user IDs, and stack traces.
Metrics Telemetry
Real-time time-series dashboards monitoring CPU utilization, error percentages, and P99 latency.
Distributed Tracing
OpenTelemetry spans mapping the exact millisecond path across Gateway → App → Cache → DB → Payment.

The Master 12-Step System Design Formula

01. Problem Scoping & Ambiguity Clarification
02. Define Functional Requirements (Actor Actions)
03. Define Non-Functional Constraints (Speed, Scale, SLA)
04. Back-of-the-Envelope Capacity Estimation (QPS & Storage)
05. Model Core Data Entities & Relationships
06. Draft API Contracts & Data Flow Sequences
07. Sketch the Initial High-Level Blueprint
08. Identify Bottlenecks & Scale the App Tier
09. Decouple Synchronous vs. Asynchronous Workflows
10. Analyze Failure Modes & Automated Failover
11. Security, AuthN/AuthZ, and BOLA Mitigation
12. Observability (Logs, Metrics, Traces)
14

Interactive Workbench: The System Architect's Toolkit

Navigate the 12-step blueprint, simulate real-world capacity estimates with dynamic math, and contrast synchronous vs. asynchronous execution latency.

System Design Methodology Quiz

Verify your grasp of architectural decomposition and estimation techniques

1. What is the most critical mistake when starting to design a new system?

2. Why should order-confirmation emails and SMS alerts be processed via an asynchronous message queue?

3. What is the primary purpose of Back-of-the-Envelope Estimation?

Next Step: Part 1 · Lesson 11.3

Core Building Blocks of Modern Systems

With the system design thinking framework mastered, we explore the internal mechanics of the 10 foundational building blocks—Clients, Servers, Load Balancers, In-Memory Caches, Databases, Message Queues, Object Stores, and CDNs—and see how they interconnect in modern architectures.