Project Workshop — System Design Portfolio Doc
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important…
- What you are building
- Architecture
- Acceptance criteria
- Suggested repository structure
- Build plan: vertical slices
Architecture · System Design
Expected effort: 10–16 focused hours · Minimum meaningful tests: 12What you are building
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important design decision from the README.
Architecture
Critical interaction
Ownership table
| Boundary | Owns | Must not own |
|---|---|---|
| Interface | Parsing, protocol validation, identity extraction, status or presentation mapping | Core business invariants |
| Application/domain | Authorization inputs, state transitions, orchestration, transaction intent | Framework globals or raw transport objects |
| Repository/gateway | One persistence or external protocol, bounded retries, error translation | Product policy |
| Background/UI projection | Recoverable derived state and delivery progress | Hidden authoritative truth |
| Operations | Configuration, health, deployment, telemetry, recovery | Business decisions encoded only in dashboards |
Acceptance criteria
| ID | Required behavior | Evidence |
|---|---|---|
| AC-1.1 | vertical vs horizontal scaling limits produces the specified behavior inside Scalability & CAP theorem | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.2 | load balancing: Round Robin/LeastConn/Consistent Hashing produces the specified behavior inside Scalability & CAP theorem | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.3 | CDN + cache invalidation strategies produces the specified behavior inside Scalability & CAP theorem | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.4 | CAP theorem: CP (PostgreSQL) vs AP (Cassandra) systems produces the specified behavior inside Scalability & CAP theorem | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.5 | eventual consistency + conflict resolution produces the specified behavior inside Scalability & CAP theorem | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.1 | Saga pattern: choreography vs orchestration produces the specified behavior inside Distributed patterns | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.2 | Outbox pattern for reliable event publishing produces the specified behavior inside Distributed patterns | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.3 | CQRS: separate read/write models produces the specified behavior inside Distributed patterns | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.4 | Event sourcing: event log as source of truth produces the specified behavior inside Distributed patterns | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.5 | 2PC and why it's avoided produces the specified behavior inside Distributed patterns | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.1 | token bucket: burst handling produces the specified behavior inside Rate limiting algorithms | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.2 | leaky bucket: smooth output produces the specified behavior inside Rate limiting algorithms | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.3 | fixed window: boundary problem produces the specified behavior inside Rate limiting algorithms | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.4 | sliding window log: accurate produces the specified behavior inside Rate limiting algorithms | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.5 | sliding window counter: efficient produces the specified behavior inside Rate limiting algorithms | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.6 | Redis distributed rate limiting produces the specified behavior inside Rate limiting algorithms | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.1 | URL shortener (base62, DB sharding) produces the specified behavior inside 5 system design problems solved | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.2 | Chat system (WebSocket, message storage, presence) produces the specified behavior inside 5 system design problems solved | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.3 | Notification service (fan-out, APNs/FCM) produces the specified behavior inside 5 system design problems solved | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.4 | Rate limiter (Redis sliding window counter) produces the specified behavior inside 5 system design problems solved | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.5 | Job queue system (Kafka + workers + retry) produces the specified behavior inside 5 system design problems solved | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.1 | stateless vs stateful service instances produces the specified behavior inside Consistency & connection scaling | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.2 | PgBouncer session/transaction/statement pooling produces the specified behavior inside Consistency & connection scaling | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.3 | linearizability vs serializability produces the specified behavior inside Consistency & connection scaling | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.4 | read-your-writes and monotonic-read session guarantees produces the specified behavior inside Consistency & connection scaling | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.5 | replication lag and conflict resolution produces the specified behavior inside Consistency & connection scaling | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
Suggested repository structure
1portfolio/2├── README.md3├── requirements-and-estimates.md4├── designs/5├── algorithms/6├── failure-analysis/7├── tests-and-benchmarks/8└── interview-talk-track.mdBuild plan: vertical slices
| Milestone | Capability | First implementation | Exit condition |
|---|---|---|---|
| 1 | Scalability & CAP theorem | vertical vs horizontal scaling limits; load balancing: Round Robin/LeastConn/Consistent Hashing; CDN + cache invalidation strategies | Demonstration plus focused tests |
| 2 | Distributed patterns | Saga pattern: choreography vs orchestration; Outbox pattern for reliable event publishing; CQRS: separate read/write models | Demonstration plus focused tests |
| 3 | Rate limiting algorithms | token bucket: burst handling; leaky bucket: smooth output; fixed window: boundary problem | Demonstration plus focused tests |
| 4 | 5 system design problems solved | URL shortener (base62, DB sharding); Chat system (WebSocket, message storage, presence); Notification service (fan-out, APNs/FCM) | Demonstration plus focused tests |
| 5 | Consistency & connection scaling | stateless vs stateful service instances; PgBouncer session/transaction/statement pooling; linearizability vs serializability | Demonstration plus focused tests |
| 6 | Hardening and delivery | Security, recovery, telemetry, performance, documentation | Full acceptance suite and recorded demonstration |
For each milestone, first create a failing acceptance test or a reproducible command. Implement the thinnest path to an observable result, add the nearest durable invariant, inject one expected failure, and refactor only after evidence protects the behavior.
Reference vertical slice
1# Atomic Redis token-bucket decision (conceptual Python wrapper)2def allow(subject: str, now_ms: int, capacity: int, refill_per_ms: float, cost: int = 1):3 # Lua receives the key, current time, capacity, rate, cost, and TTL.4 allowed, remaining, retry_after_ms = redis.evalsha(5 TOKEN_BUCKET_SHA, 1, f"rate:{subject}", now_ms, capacity, refill_per_ms, cost, 120_0006 )7 return {8 "allowed": bool(allowed),9 "remaining": int(remaining),10 "retry_after_ms": int(retry_after_ms),11 }Expected result
1The distributed decision is atomic and returns enough metadata for 429 and Retry-After behavior.Code reading
| Line | Code | Explanation |
|---|---|---|
| 1 | # Atomic Redis token-bucket decision (conceptual Python wrapper) | Implements the next python statement in the example's data flow. |
| 2 | def allow(subject: str, now_ms: int, capacity: int, refill_per_ms: float, cost: int = 1): | Defines a function; its parameters form the explicit input boundary. |
| 3 | # Lua receives the key, current time, capacity, rate, cost, and TTL. | Implements the next python statement in the example's data flow. |
| 4 | allowed, remaining, retry_after_ms = redis.evalsha( | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 5 | TOKEN_BUCKET_SHA, 1, f"rate:{subject}", now_ms, capacity, refill_per_ms, cost, 120_000 | Implements the next python statement in the example's data flow. |
| 6 | ) | Implements the next python statement in the example's data flow. |
| 7 | return { | Returns the observable result to the caller and ends this invocation. |
| 8 | "allowed": bool(allowed), | Implements the next python statement in the example's data flow. |
| 9 | "remaining": int(remaining), | Implements the next python statement in the example's data flow. |
| 10 | "retry_after_ms": int(retry_after_ms), | Implements the next python statement in the example's data flow. |
| 11 | } | Implements the next python statement in the example's data flow. |
Risk register
| Area | Failure to reproduce | Required design response |
|---|---|---|
| Scalability & CAP theorem | PostgreSQL is not universally 'CP' and Cassandra is not universally 'AP'; configuration and operation semantics matter. | Begin with estimates, make services stateless where practical, and define stale/read-your-writes expectations. |
| Distributed patterns | Compensation is a new business action, not a magical rollback, and outbox publication remains at-least-once. | Use stable command/event IDs and design reconciliation paths. |
| Rate limiting algorithms | Application throttles are not a substitute for edge protection, and offset pagination drifts under concurrent writes. | Use deterministic unique ordering and return retry metadata. |
| 5 system design problems solved | Architecture diagrams without capacity, failure, and migration reasoning are decorative rather than actionable. | State SLOs and identify the first bottleneck before adding components. |
| Consistency & connection scaling | Calling a database 'strongly consistent' without isolation, replica-routing, and transaction scope is incomplete. | State the exact operation guarantee, use primary/sticky reads after writes where required, and size connection pools across every service instance. |
Engineering checklist for this stack
- To do: begin from requirements and quantitative SLOs
- To do: assign one owner to authoritative state
- To do: make consistency and ordering scope explicit
- To do: design degraded behavior and reconciliation
- To do: record decisions and migration boundaries
Test strategy
Implement at least 12 meaningful cases. A long list of shallow happy-path tests does not satisfy the requirement.
| Risk class | Minimum | Examples |
|---|---|---|
| Happy path and contract | 2 | Correct output, status/schema, durable state |
| Validation and boundaries | 2 | Empty, malformed, extreme, unsupported transition |
| Authorization or trust boundary | 1 | Missing identity, wrong tenant/role, injection or unsafe content |
| Failure and recovery | 2 | Timeout, retry, rollback, reconnect, dependency outage |
| Duplicate or concurrency | 1 | Same identity twice, racing update, redelivery |
| Performance and operations | 4 | Query bound, lag, p95, resource limit, telemetry |
Representative test scaffold
1Scenario: broker unavailable for 10 minutes2Given: writes remain valid in the source-of-truth transaction3When: the publisher cannot deliver outbox rows4Then: backlog age grows, an alert fires, retries use jitter, and recovery publishes each event at least once5Invariant: no committed aggregate is missing a durable outbox recordFailure drills
- Stop the primary external dependency during the critical path. Capture the failure, cleanup, telemetry, and recovery.
- Repeat the same operation with the same stable identity. Prove one logical outcome or document why repetition is forbidden.
- Crash after durable state changes but before the response, acknowledgement, or projection. Re-run and reconcile.
- Submit the largest supported input and one slightly larger input.
- Remove one permission and prove denial without state change or information leakage.
- Roll back the change or restore the dependency, then run a smoke test and reconciliation check.
Performance experiment
State the dataset, payload distribution, concurrency, rate, duration, cache state, and resource limits before measuring. Publish p50, p95, p99, throughput, error rate, and the technology-specific correctness signal such as query count, consumer lag, duplicate effects, rendered updates, token cost, or recall. Change one variable at a time and retain raw output.
Submission package
- Complete source with a locked/reproducible environment.
- README.md with problem, architecture, setup, commands, configuration, assumptions, and trade-offs.
- Acceptance and risk-focused tests with a short explanation of what mocks intentionally do not cover.
- One design record explaining the most consequential choice and a rejected alternative.
- Security notes, sample non-secret configuration, and cleanup commands.
- A demonstration record: terminal transcript, screenshots, trace, query plan, or metrics dashboard.
- A 5–8 minute walkthrough following input → validation → state → failure → evidence.
Grading rubric
| Dimension | Weight | Full-credit evidence |
|---|---|---|
| Product behavior | 25 | Acceptance criteria pass through real public boundaries |
| Architecture and ownership | 20 | Responsibilities and state authority are explicit |
| Tests and recovery | 20 | Important negative, duplicate, concurrent, and outage cases pass |
| Security and data correctness | 15 | Least privilege, validation, constraints, and secret handling are demonstrated |
| Performance and operations | 10 | Reproducible measurement, useful telemetry, and rollback/recovery |
| Documentation and explanation | 10 | A new reviewer can reproduce and defend the result |
Mastery check
How well can you recall this?
Finished this lesson?