# Exercise 1 — Decide: Direct Call or Broker?

## Scenario

You're designing the backend for an e-commerce checkout flow. When a customer places an order, the system must:

1. Validate the payment with a third-party payment gateway and get an approve/decline result before telling the customer whether checkout succeeded.
2. Reserve stock for the ordered items in the inventory service.
3. Send a confirmation email to the customer.
4. Notify the warehouse system to begin packing the order.
5. Update a real-time analytics dashboard showing today's revenue.
6. Check whether the customer qualifies for a loyalty-tier upgrade, and if so, apply it.

## Deliverables

Answer directly under each heading.

1. **Classify each of the six steps** as "direct call" or "through a broker," and justify each in 1–2 sentences using the decoupling trade-offs from the theory file (does the caller need an immediate answer? can the work happen later? does more than one consumer care about this event?).

2. **Identify the one step most likely to cause customer-visible failure if implemented the wrong way** — i.e., if you accidentally made a broker-appropriate step synchronous, or a synchronous-appropriate step asynchronous. Explain the concrete failure mode (what actually breaks, and how a user or on-call engineer would notice).

3. **Design the event.** For whichever steps you routed through a broker, describe the single event message (name it, e.g. `OrderPlaced`) that would let all of those steps be handled by independent consumers. List the fields that message needs to carry so every consumer has what it needs without calling back to the checkout service.

4. **Failure isolation.** Suppose the email-sending service (step 3) has a 20-minute outage. Walk through, step by step, what happens to steps 1, 2, 4, 5, and 6 during that outage under your design — do they succeed, stall, or fail? Explain why, based on how you routed each one.

## Notes

- There is no single "correct" architecture — the goal is to demonstrate sound reasoning about which failure/latency trade-offs a broker helps with and which it doesn't.
- Keep answers concrete: name real fields, name a real event, don't just restate the theory file's definitions.
