ADRs, 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.
Learning outcomes
- Explain architectural decisions through their context, chosen approach and consequences.
- Document technical failures in a blameless postmortem with a timeline, root cause and verifiable follow-ups.
- Use a project retro to identify delayed work, explain why it slipped and improve future planning.
- Connect engineering decisions and debugging stories to a README that another engineer can follow.
Your food-delivery backend has accumulated architectural decisions, operational failures and implementation trade-offs across eight weeks. The code shows how MySQL, Redis, Redpanda and the WebSocket hub work together, but it does not always explain why you chose those components or what happened when something failed.
Another engineer reading your repository should be able to understand those choices without reconstructing your entire development history. They should also be able to see how you investigated difficult failures and what you would change in the next project.
The documentation package solves this problem through three types of engineering records. Each one answers a different question: why the architecture looks this way, what caused a failure, and what you learned from delivering the project.
Architectural decision records
An architecture decision record (ADR) captures one architectural decision and the reasoning behind it.
A useful ADR explains the situation that required a choice, the constraints that influenced it, the selected approach and its consequences. It preserves information that implementation code might not contain, especially alternatives that were considered and rejected.
Store ADRs in docs/adr/. Give each decision its own Markdown file with a sequential number and descriptive filename.
For this project, the three core records cover these decisions:
0001-mysql-over-postgres.md0002-outbox-over-direct-publish.md0003-websocket-over-polling.md
The filename makes the subject identifiable before someone opens the document. The number gives you a stable way to reference decisions in discussions and other documentation.
The four ADR sections
Every ADR follows the same four-section structure.
Status identifies the current state of the decision. Common values include Accepted, Rejected and Superseded. A date can help establish when an accepted decision became part of the project.
Context explains why you needed to make the decision. Describe the requirements, constraints, evidence and alternatives that mattered at the time.
For the MySQL decision, the context includes the relational data model, transactions, foreign keys, indexes and the project's MySQL 8.4 development environment. PostgreSQL could also support these requirements. The important part is explaining why the project settled on one database engine rather than making an unsupported claim that one is universally better.
Decision states the chosen approach in its first sentence. Follow it with enough implementation detail to make the choice understandable.
Consequences records what became easier and what became harder. An ADR should describe costs as well as benefits.
Here is the structure:
# ADR 0001: MySQL over PostgreSQL
## Status
Accepted
## Context
Describe the requirements and alternatives.
## Decision
State the selected approach and implementation.
## Consequences
Explain the benefits and costs.Notice that the decision is separate from its justification. A reader should be able to identify what you chose from the Decision section without having to infer it from the Context.
The outbox decision
The order service provides a useful example because saving an order and publishing its event involve two independent systems.
The order API writes durable data to MySQL and publishes events through Redpanda. Publishing directly from the request would create a dual-write problem: MySQL and Kafka cannot participate in one atomic transaction in this architecture.
Consider the two possible failure orders:
- MySQL commits the order, but Kafka publication fails. The order exists without its event.
- Kafka accepts the event, but the MySQL transaction rolls back. Consumers receive an event for an order that does not exist.
The transactional outbox addresses this problem by recording the order and its publication intent in the same MySQL transaction.
The relay publishes committed outbox records asynchronously. This keeps order creation independent of broker availability during the HTTP request.
However, the relay has another failure case. It can publish an event successfully and crash before marking the corresponding outbox record as published. On restart, it may publish that event again.
That means event delivery is at-least-once delivery, not guaranteed exactly-once delivery. Consumers must handle repeated events safely.
Your ADR should record both sides of the decision. The outbox improves consistency between database changes and publication intent, but it introduces a relay, retry handling, monitoring and duplicate-processing requirements.
The WebSocket decision
The rider tracking system provides another useful architectural decision.
With polling, clients repeatedly send HTTP requests to check for updated order states or rider locations. Many of those requests return unchanged data.
The WebSocket hub provides a persistent connection through which the server can push relevant updates when they become available. The customer and rider applications can use this connection model for live tracking.
The trade-off is not that WebSockets are always better. They reduce repeated requests for live updates, but introduce connection management, authentication, subscriptions, reconnection handling and backpressure concerns.
A disconnected client also needs a recovery path. MySQL remains the durable source of order state, so the client can fetch the current state over HTTP after reconnecting.
Your ADR should explain both the need for timely updates and the operational cost of maintaining persistent connections.
Decision history
Treat accepted ADRs as historical records. Do not rewrite an old decision to pretend the project always used its newer architecture.
Suppose the project later replaces WebSockets with another communication mechanism. The original ADR still explains why WebSockets were selected under the earlier requirements.
Create a new ADR describing the replacement and its reasoning. Mark the earlier decision as superseded when appropriate, and reference the earlier record.
This gives future engineers a chronological account of the architecture. It also makes it possible to distinguish a decision that was reasonable under previous constraints from one that no longer fits the current system.
Blameless postmortems
A blameless postmortem analyzes an incident by identifying the system conditions that caused it and the changes that can reduce recurrence.
The distinction is between explaining a technical failure and assigning personal blame.
Week 6 provides a concrete incident. After Redis restarted during local testing, multiple restaurant browse requests encountered cache misses and independently loaded the same data from MySQL. The duplicate database work increased load and made browse responses slower while the cache recovered.
A useful postmortem explains what happened, what was affected, how the problem was investigated, which mechanism caused it and what should change.
Store the record in docs/ using a filename such as:
docs/postmortem-cache-stampede.mdThe postmortem sections
Summary gives a short account of the incident. Name the affected component and the observable failure.
For the cache incident, the summary should explain that a Redis restart emptied the cache and concurrent browse requests triggered duplicate database reads.
Timeline records observations and actions in chronological order. Include enough detail to show how the investigation progressed.
For example:
## Timeline
1. Redis restarted during local testing.
2. Browse requests encountered cache misses.
3. Concurrent requests loaded the same data.
4. Browse latency increased.
5. The investigation identified duplicate cache population.This timeline distinguishes what happened from what the investigation later concluded. That distinction matters because an initial suspicion can be wrong.
Root cause explains the technical mechanism responsible for the failure.
In this incident, the cache miss path allowed every concurrent request for the same key to execute its own database query. There was no effective per-key coordination to make other requests reuse the result of one cache load.
The Redis restart exposed the weakness because many previously populated keys became unavailable at once.
An insufficient explanation would be that Redis restarted and caused the problem. The restart triggered the incident, but it does not explain why the application generated duplicate database work. The missing coordination on concurrent cache misses explains that behaviour.
Follow-ups lists corrective actions that address the underlying system gap.
For example, coordinating cache population prevents concurrent requests for the same key from independently loading identical data. A concurrency test can verify that the database work remains bounded when many requests encounter the same missing key.
Make each follow-up actionable. Give it an owner and a check that establishes whether the work is complete.
## Follow-ups
- [ ] Coordinate cache population per key.
Owner: Backend developer.
Check: Concurrent misses reuse one database load.
- [ ] Add a Redis restart test.
Owner: Backend developer.
Check: Browse requests remain correct after restart.The owner establishes responsibility. The check describes observable evidence rather than relying on someone to say the task is finished.
Optional incident details
Impact and What went well are useful additional sections, even though the documentation package's required postmortem structure focuses on Summary, Timeline, Root cause and Follow-ups.
Impact describes the affected users or system behaviour. Include measured latency, errors or duration when available. Do not invent metrics to make the incident appear more serious.
For the Week 6 incident, distinguish local testing impact from production impact. The incident occurred during local testing, so do not claim production customer impact without evidence.
What went well captures the things that helped you investigate or recover. Reproducing the issue through a Redis restart, inspecting query timings and observing browse latency are useful details when they actually contributed to the investigation.
A postmortem is not a list of mistakes. It should explain how the system behaved, which safeguards were missing and how you can improve those safeguards.
Project retrospectives
A project retrospective records what happened during delivery and what you would change in the next project.
An ADR examines one technical decision. A postmortem examines one incident. A retro examines the wider development process.
Store it at docs/retro.md.
The project retrospective uses three sections: What slipped, Why and Next.
What slipped
Identify the weeks or deliverables that took longer than expected. Name the work that moved rather than saying that the whole project was delayed.
For example, Week 5 involved rider assignment and live tracking. WebSocket connection handling, Redis pub/sub and the exclusive rider claim introduced integration work beyond the initial implementation.
Week 6 also slipped because the Redis cache stampede required investigation and additional concurrency testing.
These observations connect the delay to specific engineering work. A statement such as "Week 5 was difficult" does not explain which part of the plan changed.
Why
Explain the reasons behind the schedule changes.
The original Week 5 estimate might have covered the WebSocket hub but excluded reconnection behaviour and Redis pub/sub integration. That is a useful finding because it identifies work that should be estimated separately next time.
Week 6 provides another example. An estimate focused on ordinary cache misses but did not account for simultaneous requests after a Redis restart.
Avoid explanations that assign the delay to poor effort or motivation. Those statements do not identify a repeatable planning or technical problem.
A useful explanation identifies the missing assumption, underestimated integration work or dependency that affected delivery.
Next
Translate the findings into changes for the next project.
If reconnection work was missing from the Week 5 estimate, include it as a separate milestone in the next project. If cache recovery was not tested early enough in Week 6, include restart and concurrent-miss scenarios in the initial failure-testing plan.
The point is to change how you plan and verify work, not to promise that every future estimate will be accurate.
Your retro should connect each improvement to an observation from the project. A list of generic goals such as "communicate better" or "write more tests" does not show what the project taught you.
The README as an engineering post
The ADRs, postmortem and retro provide detailed records. The repository-root README.md gives another engineer a starting point for understanding the whole project.
Treat the README as an engineering post rather than a short installation note. It should connect the product problem, architecture, measured behaviour, difficult debugging work and future improvements.
The Project documentation package exercise checks five required sections:
## Problemexplains the food-delivery problem and the responsibilities of the system.## Architecturedescribes the Go API, MySQL, Redis, Redpanda, workers, gRPC service and WebSocket hub.## Numbersreports local benchmark results with their test conditions.## Hardest bugscontains at least three debugging stories.## Next stepsdescribes realistic improvements to the project.
Each section needs at least 25 words of body text. A detailed Architecture section does not compensate for a short Problem section.
Architecture evidence
A useful architecture section gives the reader two complementary views.
A Mermaid flowchart explains component boundaries and their responsibilities. It should show how the customer and rider apps connect to the Go API, how MySQL and Redis support the backend, and how the outbox relay and Redpanda fit into event processing.
A Mermaid sequence diagram traces a specific operation. Order placement is a good example because it demonstrates the idempotency check, MySQL transaction, outbox insertion and asynchronous event publication.
Keep these diagrams separate. A component diagram explains the system's structure, while a sequence diagram explains the order in which a particular workflow happens.
The surrounding text should explain details that the diagrams cannot communicate clearly, such as why the relay runs asynchronously and why MySQL remains the durable source of order state.
Benchmark evidence
Numbers are useful only when another engineer can interpret the conditions under which you collected them.
For the Week 8 project, use your own local k6 measurements. Record the workload, relevant latency and throughput results, error rate and machine configuration for each run.
The Numbers section needs a Markdown table with a Hardware column. Every data row must identify the hardware and configuration used for that measurement. Keep the number of cells consistent and do not leave any cells empty.
A local comparison can show how a configuration change affected your workload. For example, limiting the API container to two CPUs provides a different test condition from running it without that limit.
However, a controlled local result does not establish production capacity. Traffic patterns, machine resources, database contention and deployment conditions all affect the result. State what the measurements demonstrate without claiming more than the test supports.
Debugging stories
The Hardest bugs section should contain at least three stories, each with its own ### heading and at least 40 words.
Write each story as a debugging investigation. Start with an observable symptom, describe what you inspected, identify the underlying mechanism, and explain the fix and its verification.
The project provides several useful examples.
Cache stampede after a Redis restart: Browse requests became slower after Redis restarted. The investigation should explain why increasing the database connection pool did not address the duplicate queries and how cache population coordination addressed the underlying problem.
Duplicate order from a retried request: A client retried an order request after a slow response. The investigation should explain why the server could not assume the first attempt had failed and how durable idempotency protection prevents the same logical operation from creating another order.
Rider claim racing: Concurrent assignment attempts could observe the same available order. The investigation should explain the gap between checking availability and storing a claim, and how Redis SET NX with an expiry makes the claim exclusive.
These examples are more informative than a list of bug names. They show how you reasoned about the system and verified the behaviour after a fix.
Durable links
Keep the detailed engineering records under docs/ and link them from the README.
For example, an Architecture decisions section can link to the MySQL, outbox and WebSocket ADRs. An incident review section can link to the Week 6 postmortem. A project retrospective section can link to docs/retro.md.
Use repository-relative Markdown links and verify that every target exists. A link that looks correct but points to a missing file makes the engineering post harder to use.
The README must also avoid em dashes and en dashes. Use ordinary punctuation instead.
Project documentation package
The Project documentation package exercise brings these records together. You will create the repository-root README, three core ADRs under docs/adr/, a Week 6 postmortem under docs/ and the project retro at docs/retro.md.
The README serves as the entry point. The ADRs explain the MySQL, outbox and WebSocket decisions. The postmortem explains the cache incident, while the retro records how work changed across the project.
Use your implementation, tests and actual development experience as evidence. Do not copy benchmark values or incident measurements from examples when you have not collected them yourself.
The resulting documentation also becomes source material for the next exercise, Two-minute project demo package. Its demo script and portfolio entry need a clear account of the product, architecture and engineering decisions.
Check your understanding
You accepted an ADR for using WebSockets for live rider tracking. Later, the project replaces WebSockets with another communication mechanism. How should you preserve the decision history?
References
Everything above is explained on this page; these are where it comes from.