# Exercise 2: Strangler Fig Extraction — Northwind's Loyalty Module

## Scenario

Six months after Exercise 1's boundary work, Northwind's `loyalty` module (now cleanly bounded, with a narrow public API: `awardPoints(customerId, amount)`, `getTier(customerId)`, `redeemPoints(customerId, amount)`) has become a real extraction candidate:

- Loyalty point calculations now run a nightly batch job over 40 million bookings that takes 5 hours and regularly runs into the same CPU contention as the daytime booking API, causing checkout latency spikes every night at 2 AM.
- The Growth team (which owns loyalty + notifications) wants to redeploy loyalty independently, multiple times a day, without waiting for the Stays team's release train.
- Three call sites exist today: `booking/createBooking.ts` calls `awardPoints` after a stay completes; `checkout/applyDiscount.ts` calls `getTier` to decide discount eligibility; and an admin dashboard calls `redeemPoints` when support manually issues a refund-as-points.

## Your Task

### Deliverables

1. **Strangler fig plan, step by step.** Using the theory's three-step pattern (direct in-process call → public API reimplemented as a thin HTTP client → delete the old module), write out the concrete sequence of changes for Northwind's loyalty extraction. Name what changes at each step and, critically, what does NOT change at each call site (`createBooking.ts`, `applyDiscount.ts`, the admin dashboard) — and explain why that's possible only because of the boundary work done in Exercise 1.
2. **New failure modes.** Once `awardPoints` is an HTTP call instead of a function call, `booking/createBooking.ts` can fail in ways it couldn't before. List at least three (referencing the "Under the Hood" section of the *Monolith vs Microservices* theory file by name) and, for each, state whether checkout should block on it or proceed without loyalty points being awarded.
3. **The 2 AM problem, precisely.** Explain exactly why extracting loyalty into its own service fixes the nightly CPU contention issue — what resource is no longer shared once loyalty runs as a separate process — and why a modular monolith's in-process boundary (from Exercise 1) was *not* enough to fix this on its own, even though the code-level coupling was already gone.
4. **Was extraction justified?** Using the Decision Guide table from the *Monolith vs Microservices* theory file, argue whether Northwind's loyalty extraction was triggered by a "proven, specific reason" (as the theory recommends) or premature — cite which specific signal(s) from the scenario support your answer.
