blogs/SystemDesign
View on GitHub
C#

System Design Interview Preparation — MAANG Complete Guide

40 system design problems with full High-Level Design documents, .NET Low-Level Design implementations, Mermaid architecture diagrams, practice questions, and interview tips.


How to Use This Repository

  1. Study a problem — Read the HLD doc, understand requirements, architecture, and trade-offs
  2. Review the code — Walk through the .NET implementation to internalize the algorithms
  3. Practice — Answer the 5 practice questions at the end of each problem without looking
  4. Mock interview — Pick a random problem, design it on a whiteboard in 35 minutes

Phase 1: Foundation Systems (Problems 1-5)

Core building blocks that appear as components inside every larger system.

#ProblemHLD Docs.NET CodeKey Patterns
1API Rate LimiterPart 1 / Part 2 / Part 3TokenBucket, SlidingWindow, Middleware, RedisStoreToken bucket, sliding window, Redis counters
2Unique ID GeneratorPart 1 / Part 2 / Part 3Snowflake, MachineIdProvider, LeaseRenewalSnowflake IDs, clock skew, machine lease
3Web Cache (CDN)Part 1 / Part 2 / Part 3MultiLevelCache, InvalidationL1/L2 cache, write-through, cache stampede
4Distributed CounterPart 1 / Part 2ShardedCounter, FlushWorkerSharded writes, eventual read, flush worker
5Load BalancerPart 1 / Part 2LeastConnections, ConsistentHash, HealthCheckL4/L7, consistent hashing, health checks

Phase 2: Queue, Events & Reliability (Problems 6-10)

Asynchronous processing, reliable delivery, and distributed coordination.

#ProblemHLD Docs.NET CodeKey Patterns
6Distributed Task SchedulerPart 1 / Part 2TaskScheduler, DispatcherDelay queues, cron, idempotent execution
7Webhook Delivery ServicePart 1DeliveryWorkerExponential backoff, circuit breaker, DLQ
8Distributed Messaging (Kafka)Part 1Partitions, consumer groups, exactly-once
9Distributed LockingPart 1RedisLockRedlock, fencing tokens, lease expiry
10Batch Processing & AuditingPart 1AuditConsumer, BatchVerifierEvent sourcing, CDC, idempotent consumer

Phase 3: Social & Feed Systems (Problems 11-15)

Fan-out, ranking, and content delivery at social-media scale.

#ProblemHLD Docs.NET CodeKey Patterns
11Twitter / XPart 1 / Part 2Timeline, FanOut, ModelsFan-out on write vs read, celebrity hybrid
12InstagramPart 1Image pipeline, explore ranking, stories
13RedditPart 1Hot/Wilson ranking, nested comments, vote
14Facebook News FeedPart 1ML ranking, EdgeRank, pull-on-demand
15YouTube / NetflixPart 1ABR streaming, encoding pipeline, rec engine

Phase 4: Messaging & Real-Time (Problems 16-20)

WebSocket connections, presence, CRDTs, and real-time communication.

#ProblemHLD Docs.NET CodeKey Patterns
16WhatsApp / MessengerPart 1 / Part 2ChatService, ModelsWebSocket gateway, message queue, E2EE, presence
17Live CommentsPart 1Pub/sub, fan-out to WebSockets, throttling
18Slack / TeamsPart 1Channels, threads, search, workspace isolation
19Video Conferencing (Zoom)Part 1SFU vs MCU, WebRTC, simulcast, SRTP
20Google Docs (Collaboration)Part 1OT vs CRDT, operation transform, conflict resolution

Phase 5: E-Commerce & Payments (Problems 21-25)

Transactions, sagas, idempotency, and financial-grade consistency.

#ProblemHLD Docs.NET CodeKey Patterns
21Amazon E-CommercePart 1 / Part 2OrderSaga, ModelsSaga orchestration, compensating transactions
22Payment Service (Stripe)Part 1Idempotency keys, double-entry ledger, PCI
23Digital WalletPart 1Balance consistency, optimistic locking, audit
24Shopify Multi-TenantPart 1Multi-tenancy, tenant isolation, noisy neighbor
25Food Delivery (DoorDash)Part 1Real-time dispatch, geo-matching, ETA

Phase 6: Data, Analytics & Observability (Problems 26-30)

Stream processing, probabilistic data structures, and lambda architecture.

#ProblemHLD Docs.NET CodeKey Patterns
26Web Analytics (Google Analytics)Part 1Lambda architecture, HyperLogLog, rollups
27Metrics Monitoring (Prometheus)Part 1TSDB, Gorilla compression, PromQL, alerting
28Log Collection (ELK Stack)Part 1Kafka buffer, ILM tiered storage, trace correlation
29Ad Click AggregationPart 1Bloom + Redis dedup, watermarks, exactly-once
30Top-K Request AnalysisPart 1CountMinSketch + TopKTrackerCount-Min Sketch, Space-Saving, min-heap

Phase 7: Infrastructure & Distributed Systems (Problems 31-35)

The foundational distributed systems concepts that underpin everything.

#ProblemHLD Docs.NET CodeKey Patterns
31Distributed KV Store (DynamoDB)Part 1ConsistentHashRing, VectorClockConsistent hashing, quorum, vector clocks, Merkle trees, gossip
32Distributed File System (GFS)Part 1Master/chunk architecture, 64MB chunks, write pipeline
33Global CDN (CloudFront)Part 1GeoDNS, Anycast, origin shield, cache invalidation
34Distributed Tracing (Jaeger)Part 1Trace/span/context, tail sampling, OpenTelemetry
35Resource Allocation (K8s Scheduler)Part 1PodSchedulerFilter-Score-Bind, bin packing vs spreading, preemption

Phase 8: Boss Level (Problems 36-40)

Complex end-to-end systems that combine multiple patterns from previous phases.

#ProblemHLD Docs.NET CodeKey Patterns
36Uber/Lyft (Ride Sharing)Part 1GeoSpatialIndexGeoHash, driver matching, surge pricing, ride state machine
37Ticketmaster (Event Ticketing)Part 1Virtual waiting room, seat locking (FOR UPDATE), zero-oversell
38Google SearchPart 1Crawler, inverted index, PageRank, fan-out query serving
39Stock Trading PlatformPart 1OrderBookOrder book matching, price-time priority, event sourcing, double-entry ledger
40Container Orchestration (K8s)Part 1Control/data plane, reconciliation loops, etcd Watch, rolling updates

Key Algorithms & Data Structures (Code Index)

Quick reference for the most important implementations.

AlgorithmFileUsed In
Token Bucket Rate LimiterTokenBucketRateLimiter.cs#1 Rate Limiter
Sliding Window CounterSlidingWindowCounterRateLimiter.cs#1 Rate Limiter
Snowflake ID GeneratorSnowflakeIdGenerator.cs#2 Unique ID
Multi-Level Cache (L1/L2)MultiLevelCacheService.cs#3 Web Cache
Sharded CounterShardedCounterService.cs#4 Distributed Counter
Consistent Hash Load BalancerConsistentHashBalancer.cs#5 Load Balancer
Least Connections BalancerLeastConnectionsBalancer.cs#5 Load Balancer
Redis Distributed Lock (Redlock)RedisDistributedLock.cs#9 Distributed Lock
Fan-Out Timeline ServiceTimelineService.cs#11 Twitter
Chat Service (WebSocket)ChatService.cs#16 Messenger
Saga OrchestratorOrderSagaOrchestrator.cs#21 E-Commerce
Count-Min Sketch + Top-KCountMinSketch.cs#30 Top-K
Consistent Hash Ring (vnodes)ConsistentHashRing.cs#31 KV Store
Vector ClockVectorClock.cs#31 KV Store
Pod Scheduler (Filter-Score-Bind)SchedulerModels.cs#35 Resource Allocation
GeoHash Spatial IndexGeoSpatialIndex.cs#36 Uber
Order Book Matching EngineOrderBook.cs#39 Stock Trading

Repository Stats

MetricCount
System Design Problems40
HLD Documents52
.NET Implementation Files53
Practice Questions200 (5 per problem)
Architecture Diagrams80+ (Mermaid)

Study Plan

WeekPhaseProblemsFocus
1Foundation1-5Core building blocks (rate limiter, cache, load balancer)
2Queue & Events6-10Async processing, reliability, distributed coordination
3Social & Feed11-15Fan-out strategies, ranking, content delivery
4Messaging & RT16-20WebSockets, presence, CRDTs, real-time systems
5E-Commerce21-25Transactions, sagas, payments, multi-tenancy
6Analytics26-30Stream processing, probabilistic data structures
7Infrastructure31-35Distributed systems fundamentals (the theory)
8Boss Level36-40End-to-end complex systems (bring it all together)

Cross-Cutting Concepts

These patterns appear across multiple problems. Master them once, apply everywhere.

ConceptProblems Where It Appears
Consistent Hashing#3 Cache, #5 Load Balancer, #31 KV Store, #33 CDN
Fan-Out#11 Twitter, #14 Facebook, #17 Live Comments
Event Sourcing / CDC#10 Auditing, #21 E-Commerce, #39 Stock Trading
Saga / Compensating Transactions#21 E-Commerce, #22 Payments, #25 Food Delivery
Bloom Filter#29 Ad Click, #30 Top-K, #38 Web Crawler
HyperLogLog#26 Web Analytics
Count-Min Sketch#29 Ad Click, #30 Top-K
GeoHash / Spatial Index#25 Food Delivery, #36 Uber
Quorum (W + R > N)#31 KV Store, #32 File System
Leader Election#9 Distributed Lock, #32 File System, #40 Kubernetes
Circuit Breaker#7 Webhooks, #22 Payments
Backpressure#8 Kafka, #28 Log Collection, #29 Ad Click
Reconciliation Loop#35 Scheduler, #40 Kubernetes
Double-Entry Ledger#22 Payments, #23 Wallet, #39 Stock Trading