Reading Mode
CH 14·Lesson 10
Phase 10 — System Design, Go & DSA — Checkpoint Answer Guide
This is a grading guide, not a script to memorize. Equivalent designs earn credit when their assumptions and evidence are correct.
advanced10 min read
Learning Objectives
- System Design Fundamentals
- Microservices & Advanced Architecture
- Go (Golang)
- DSA Mastery
- GRAND CAPSTONE: TradeFlow Fintech Platform
This is a grading guide, not a script to memorize. Equivalent designs earn credit when their assumptions and evidence are correct.
System Design Fundamentals
- Scalability & CAP theorem: Scalability increases useful throughput under load; CAP states that during a network partition a distributed system cannot guarantee both linearizable availability and consistency for the same operation. A strong answer also explains that load balancers distribute requests, caches shorten data paths, replication creates copies, and partition routing selects an owner. Consistency choices are operation-specific, not a label for an entire product. The main warning is: PostgreSQL is not universally 'CP' and Cassandra is not universally 'AP'; configuration and operation semantics matter.
- Distributed patterns: Distributed patterns coordinate state without pretending several services share one local transaction. A strong answer also explains that a saga commits local steps and compensates later; an outbox commits domain state and an event row together; CQRS separates write and read models; event sourcing derives state from an append-only history. The main warning is: Compensation is a new business action, not a magical rollback, and outbox publication remains at-least-once.
- Rate limiting algorithms: Throttling bounds request rate; pagination bounds response and query work. Cursor pagination advances from a stable ordering key rather than a row offset. A strong answer also explains that distributed limits use atomic counters or scripts. A cursor encodes ordering position and tie-breaker; Relay exposes edges, nodes, cursors, and pageInfo. The main warning is: Application throttles are not a substitute for edge protection, and offset pagination drifts under concurrent writes.
- 5 system design problems solved: A complete design ties APIs and data models to estimates, state ownership, critical paths, background flows, and failure recovery. A strong answer also explains that the write path establishes durable truth; derived indexes, caches, feeds, and notifications update synchronously or from logs according to latency and consistency needs. The main warning is: Architecture diagrams without capacity, failure, and migration reasoning are decorative rather than actionable.
- Consistency & connection scaling: A stateless service instance can handle a request using external durable/shared state, while a stateful instance owns local identity or data whose placement and recovery affect correctness. A strong answer also explains that load balancers can send independent stateless requests to any healthy replica. Stateful workloads require stable identity, attached/replicated storage, leader or partition ownership, and an explicit transfer/recovery protocol. The main warning is: Calling a service stateless while keeping sessions, queues, or files only in process memory creates lost state and load-balancing inconsistencies.
Microservices & Advanced Architecture
- Service decomposition & communication: Domain-driven service decomposition assigns a bounded context, aggregate invariants, data ownership, and explicit synchronous or asynchronous contracts to each independently changeable service. A strong answer also explains that rEST and gRPC couple caller latency to a callee; streams add backpressure and lifecycle; Kafka decouples time but introduces schema, ordering, replay, and duplicate-delivery concerns; discovery maps logical service identities to healthy endpoints. The main warning is: A bounded context is not GraphQL context, database-per-service is not React Server Component composition, and gRPC streaming is not an LLM response stream.
- Service mesh & event sourcing: A service mesh applies identity, encryption, telemetry, routing, and resilience at the transport layer, while event sourcing records domain changes and derives projections for reads. A strong answer also explains that envoy sidecars intercept traffic under mesh policy; mTLS authenticates workloads; canary routes shift traffic; an append-only event store rebuilds projections and snapshots shorten replay without replacing history. The main warning is: mTLS is not Kubernetes ingress TLS, automatic retries can duplicate side effects, and a snapshot without later events is not authoritative state.
- 5 advanced system designs: Advanced product designs combine workload-specific storage, partitioning, fan-out, media pipelines, geospatial or prefix indexes, and graceful degradation rather than relying on one universal architecture. A strong answer also explains that each design narrows expensive work: feed systems choose push/pull by follower skew, media services transcode immutable renditions, location services search nearby cells, distributed caches map keys to owners, and autocomplete traverses compact prefix structures. The main warning is: YouTube streaming is media delivery rather than an LLM stream; average throughput hides celebrity, viral, and geographic hotspots.
- Communication details: gRPC supports unary, client-streaming, server-streaming, and bidirectional-streaming RPCs over HTTP/2; asynchronous request-reply uses messages plus a correlation identity and deadline instead of holding a socket. A strong answer also explains that generated protobuf types encode numbered fields; deadlines and cancellation propagate through RPC context. Async replies route by correlation ID and may arrive after the requester timed out. The main warning is: Streaming increases lifecycle complexity, and retrying an RPC without idempotency can duplicate side effects.
Go (Golang)
- Go basics: Go's built-in and defined types have static method sets; structs compose fields, interfaces describe required methods implicitly, and embedding promotes selected fields or methods without creating subclass inheritance. A strong answer also explains that an interface value stores a dynamic type and value. A pointer and its value can have different method sets. Embedded fields participate in selector promotion, while name conflicts require explicit qualification. The main warning is: A typed nil pointer stored in a non-nil interface makes the interface itself non-nil, a frequent source of incorrect nil checks.
- Go for backend: Go HTTP handlers receive a request carrying cancellation context and write one response; gin layers routing, middleware, binding, and validation conventions over net/http. A strong answer also explains that the server runs handlers concurrently, so shared state requires synchronization. Middleware wraps handlers in registration order and request bodies must be bounded and closed where applicable. The main warning is: Using the default server with no timeouts or sharing mutable maps across handlers creates resource and race failures.
DSA Mastery
- Arrays, strings & trees (15 patterns): Array, string, and traversal patterns solve problems by maintaining a precise invariant over indices, a moving window, accumulated prefixes, a search interval, or an explicit graph frontier. A strong answer also explains that two pointers move monotonically, sliding windows add and remove boundaries, prefix sums answer range totals, binary search discards an infeasible half, and BFS or DFS advances a visited frontier. The main warning is: A DSA sliding window is not a distributed rate-limit window; the technique fails when its monotonic restoration assumption does not hold.
- DP patterns (10 patterns): Dynamic programming defines the smallest state that preserves future decisions, a recurrence over smaller states, base cases, and an evaluation order. A strong answer also explains that memoization explores reachable states recursively; tabulation orders dependencies iteratively; interval and matrix-chain DP expand by subproblem length; bitmask, digit, tree, and partition variants encode different state dimensions. The main warning is: A matrix chain is an algorithmic cost problem, not a GitHub Actions matrix; irrelevant dimensions cause state explosion.
- Advanced DSA: Advanced structures preprocess or maintain order so repeated queries or nearest-element decisions become logarithmic or amortized linear. A strong answer also explains that segment trees aggregate intervals, Fenwick trees encode binary-indexed partial sums, monotonic structures discard dominated candidates, and tries branch by symbols. The main warning is: Off-by-one indexing and an incorrect merge identity are the dominant segment/Fenwick bugs.
- Additional interview patterns: Interview patterns are recognized by invariants: frequency lookup, pointer rewiring, frontier ordering, interval overlap, reversible choices, exchange arguments, or cut/shortest-path properties. A strong answer also explains that hash maps give expected O(1) lookup; heaps maintain an extremum; backtracking explores a decision tree with undo; multi-source BFS seeds all distance-zero nodes; Kruskal grows an MST through DSU-safe edges. The main warning is: Memorizing a template without its precondition selects sliding windows for negative sums, Dijkstra for negative edges, or greedy steps without an exchange proof.
GRAND CAPSTONE: TradeFlow Fintech Platform
- 6 microservices: TradeFlow decomposes identity, market ingestion, order execution, portfolio projection, notification delivery, and edge routing into services with separate state ownership and versioned contracts. A strong answer also explains that trade commands establish authoritative state and an outbox record in one transaction; Kafka partitions preserve required per-account ordering; projections and notifications tolerate replay; the gateway performs edge policy without owning business truth. The main warning is: Splitting services without database ownership, idempotent events, and operational autonomy creates a distributed monolith.
- Data flows: The platform separates high-volume market ticks from lower-volume, correctness-sensitive trade commands and publishes committed events through an outbox relay. A strong answer also explains that a local transaction writes state and outbox row; a relay publishes with a stable event ID; consumers deduplicate and update projections. WebSockets fan out derived views rather than becoming the source of truth. The main warning is: Publishing before commit creates phantom events; committing before an unrecorded publish loses events.
- LangGraph AI trading assistant: The AI assistant may analyze and propose, but a deterministic risk policy and explicit human approval gate control execution. A strong answer also explains that langGraph persists the query, retrieved evidence, analysis, risk result, approval identity, and proposed command. The execution node validates all facts again against current market and account state. The main warning is: Never let natural-language approval bypass authenticated transaction confirmation or suitability controls.
- Infrastructure & performance: TradeFlow infrastructure converts service-level objectives into deployable capacity, autoscaling signals, immutable delivery, correlated observability, and reproducible load evidence. A strong answer also explains that eKS schedules six services, KEDA responds to Kafka pressure, managed data services expose separate limits, GitHub Actions promotes artifacts, and metrics, traces, logs, and domain counters reveal the critical path. The main warning is: A matrix in a benchmark or algorithm is not a CI matrix, and one headline trades-per-minute number without latency and correctness is not a capacity result.
Professional standard
A complete response identifies the boundary, guarantee, state owner, lifecycle, failure, and proof. Award less credit to answers that name tools without explaining why their guarantees fit the requirement.
Mastery check
How well can you recall this?
Finished this lesson?