Advanced features and project documentation
5 modules · 5 lessons · 10 exercises · 15 available now
Week 8 overview
- Module 1 Inventory holds
- 8.1 Optimistic locking for stock (optional)Guarded UPDATE, Stock Hold, Overselling
- 8.2 Stock reservation service (optional)
- Module 2 Payment workflow
- 8.3 HMAC webhooks and payment sagas (optional)Webhook Signature, Payment Saga, Compensating Action, Forward-Only Transition, Reconciliation Loop
- 8.4 Payment processing service (optional)
- Module 3 App integration and capacity
- 8.5 Expo stretch integration
- 8.6 Tenfold capacity estimationFirst Bottleneck
- 8.7 Benchmark report package
- Module 4 Project documentation
- 8.8 Mermaid architecture diagramsMermaid Diagram, Flowchart Diagram, Sequence Diagram
- 8.9 ADRs, postmortems and retrosArchitecture Decision Record, Blameless Postmortem, Project Retrospective
- 8.10 Project documentation package
- 8.11 Two-minute project demo package
- 8.12 Engineering walkthrough package
- Module 5 Optional extensions
- 8.13 Timestamped webhook signature package (optional)
- 8.14 Mermaid sequence linter (optional)
- 8.15 Latency percentile package (optional)
Weekly learning objectives
Week 7 put the app in real hands. This week you complete the capstone by building stock holds and a payment workflow, connecting the stretch features to the Expo app, measuring capacity, and documenting the system.
- Inventory holds: reserve restaurant stock with optimistic locking and five-minute holds so concurrent carts cannot oversell.
- Payment workflow: create payment intents, verify signed webhooks, handle duplicate and out-of-order events, refund late captures, and reconcile unresolved payments.
- App integration and capacity: connect the stretch features to the Expo app, estimate the first bottleneck at ten times traffic, and verify the system with tests and a local k6 run.
- Project documentation: write an engineering post covering architecture, measured performance, the three hardest bugs, decisions, incident history, and next improvements.
- Demo and walkthrough: record a 2-minute demo video, create a portfolio entry, and rehearse the 5-minute walkthrough.
- Optional extensions: add webhook replay checks, Mermaid sequence diagram validation, and latency percentile tooling.
System architecture and changes
Inventory holds adds stock reservations guarded by an optimistic lock and backed by Redis holds. Payment workflow adds payment intents and a webhook-driven saga with refunds and reconciliation. The Expo app connects the new flows to the existing system. The remaining work measures and explains the system you have built.
How to complete the coursework
Complete Inventory holds and Payment workflow, then connect the stretch features through App integration and capacity. Run cd backend && make test W=W8 for the full graded backend suite, and run the app's Jest tests and npx tsc --noEmit in app/. Finish Project documentation, record the demo, and complete the walkthrough and rehearsals. Optional extensions add tooling beyond the core capstone.
Modules
Module 1: Inventory holds
2 itemsYou build a stock reservation service that holds restaurant inventory for an order and prevents concurrent carts from selling the same units.
8.1Optimistic locking for stock
You can use a version-checked update to detect competing stock changes and retry safely, which is the core of the stock reservation service.
Open lesson →8.2Stock reservation service
You build a stock reservation service that reserves cart lines and restores them on restock. Version-checked decrements prevent concurrent carts from overselling inventory.
Open exercise →
Module 2: Payment workflow
2 itemsYou build a payment workflow that creates payment intents, handles signed provider webhooks, refunds late captures, and reconciles unresolved payments.
8.3HMAC webhooks and payment sagas
You can verify raw provider callbacks and coordinate forward-only payment actions, giving the payment service safe rules for duplicate and late events.
Open lesson →8.4Payment processing service
You build a payment processing service that creates payment intents and settles them from signed provider webhooks. A reconciliation pass resolves old pending payments, while late captures after failure trigger refunds.
Open exercise →
Module 3: App integration and capacity
3 itemsYou build the Expo stretch integration, estimate the first bottleneck at ten times traffic, and verify the system with tests and a local k6 run.
8.5Expo stretch integration
You build
Open exercise →app/lib/stretch.tsand update one Expo screen to show inventory availability or simulate payment through the existing API client. The helpers must preserve server payment statuses and recognise only a 409sold_outerror.8.6Tenfold capacity estimation
You can estimate the first bottleneck at ten times current traffic and use that hypothesis to interpret the final local benchmark.
Open lesson →8.7Benchmark report package
You build
Open exercise →benchreport, a Go package that parses a k6 JSON summary export into a Markdown performance table with hardware recorded on every row.
Module 4: Project documentation
5 itemsYou build a project documentation package that explains the system's architecture, measured performance, hard bugs, decisions, incident history, and next improvements.
8.8Mermaid architecture diagrams
You can choose a [[flowchart-diagram]] for component boundaries and a [[sequence-diagram]] for order placement, so the engineering post explains both system structure and request flow.
Open lesson →8.9ADRs, postmortems and retros
You can record architectural choices as ADRs, analyze failures in a blameless postmortem, and capture project lessons in a retro so the engineering post links to durable context.
Open lesson →8.10Project documentation package
You build a project documentation package with an engineering-post README, three ADRs, a Week 6 postmortem, and a project retro. The README includes Mermaid diagrams, local k6 measurements with hardware, and three detailed bug stories.
Open exercise →8.11Two-minute project demo package
You build a two-minute project demo package with a timed customer-and-rider recording script, a README video link, and a portfolio entry.
Open exercise →8.12Engineering walkthrough package
You build a five-minute technical walkthrough and a rehearsal log that explain the backend's architecture, correctness guarantees, load limits, and rider assignment. The script gives the largest time budget to idempotency and outbox, and both recorded rehearsals must finish within five minutes.
Open exercise →
Module 5: Optional extensions
3 itemsYou build optional webhook replay checks, Mermaid sequence diagram validation, and latency percentile tooling without making any of them block the week.
8.13Timestamped webhook signature package
You build a Go package that signs timestamps with raw webhook bodies and verifies HMAC-SHA256 headers against an injected time and tolerance. It accepts any matching
Open exercise →v1signature and authenticates before checking freshness.8.14Mermaid sequence linter
You build a Go linter that accepts Mermaid sequence diagram source and returns line-numbered diagnostics for malformed declarations, messages, and blocks.
Open exercise →8.15Latency percentile package
You build a Go package that calculates nearest-rank percentiles and summary statistics from raw latency samples.
Open exercise →
Completion checklist
What should be true at the end of the week.
cd backend && make test W=W8passes, including the graded inventory, payment, reporting, documentation, demo, walkthrough, and optional-extension tests.- Inventory tests confirm that exactly ten of 500 carts reserve ten available units, duplicate reservations take stock once, and failed multi-line reservations release every hold.
- Payment tests confirm that missing or bad signatures change nothing, duplicate deliveries place an order once, late captures are refunded once, and reconciliation settles eligible pending payments.
- The Jest tests for
app/lib/stretch.tspass,cd app && npx tsc --noEmitsucceeds, and the k6 report parser and hardware-labelled numbers table pass their checks. - README and documentation checks pass: required sections and diagrams exist, relative links resolve, three ADRs follow the required structure, and the postmortem and retro meet their contracts.
- Demo and walkthrough checks pass: the demo script fits two minutes with customer and rider views in every beat, and two logged rehearsals plus the walkthrough fit five minutes.
Week requirements
Rules every piece of code this week must follow.
- Inventory reservations use an optimistic lock so concurrent carts cannot oversell; short stock returns
ErrSoldOut, a reservation keeps a five-minute hold, and reserving the same order twice takes stock once. - A failed multi-line reservation rolls back earlier lines and releases every hold; restocking restores the units and releases the holds.
- Payment intents store a pending payment with the provider reference; webhooks verify the signature before parsing the body, return 401 for missing or bad signatures without changing state, and return 404 for an unknown payment without consuming its event.
- Captures place the order once, failures cancel it, later failures cannot undo a capture, and captures arriving after failure are refunded once; duplicate deliveries and second captures do not repeat state changes, while reconciliation settles old pending payments without changing recent or provider-pending payments.
- The optional webhook signature tooling signs a timestamp and body with HMAC-SHA256, supports multiple v1 signatures, and distinguishes bad signatures, malformed headers, and stale requests; Mermaid sequence validation reports malformed diagrams and undeclared participants with their line numbers; percentile tooling uses nearest-rank results without reordering the caller's samples and refuses invalid or empty input.
ParseK6reads request rate, latency, and errors, rejects invalid JSON, and identifies missing metrics; the numbers table rejects empty runs and rows without hardware, and states hardware on every row.- The README contains the required engineering post sections, a Mermaid flowchart and sequence diagram, a hardware-labelled numbers table, three hardest bugs as stories, a Demo section, resolving relative links, and no em or en dashes; the three ADRs use Context, Decision, and Consequences, the postmortem covers timeline, cause, and follow-ups, and the retro identifies which weeks slipped.
- The demo script fits two minutes with every beat showing the customer and rider side by side, the portfolio entry has the required fields, and the README links the demo video; the walkthrough has five timed parts in order, spends the most time on idempotency, explains what breaks first at ten times traffic, and has two logged rehearsals under five minutes.