Architecture · Migration
Migrating a staff console off a monolith, one endpoint at a time
Replacing the Grails monolith behind the operations console with a Spring Boot 4 service — without a big-bang cutover, without changing the database underneath, and without breaking a single downstream event.
01 Problem
Staff in compliance, operations and client service run the business from an admin console backed by a large Grails monolith. Every change to it carried the risk of the whole system, and the codebase was increasingly hard to secure and observe.
A rewrite was the obvious temptation — and the classic way to stall for a year while the old system keeps changing underneath you.
02 Constraints
- The legacy database is shared and stays shared; schemas cannot fork.
- Other services consume the events the monolith emits and must not notice the switch.
- Tables are expected to grow toward a billion rows with hundreds of concurrent staff.
- Staff access must be revocable immediately, not at token expiry.
03 Architecture
- 01Angular consoleUnchanged UI; calls one API surface.
- 02Per-endpoint switchEach endpoint routed to legacy or new independently.
- 03New serviceSpring Boot 4 on Java 25; tenant resolved from the JWT.
- 04Keycloak checkStaff status verified on every request; revocation is immediate.
- 05Shared MySQLSame schema; query budgets and indexes for very large tables.
- 06Contract testsFail if a write emits different events than legacy does.
04 Decisions
Strangler, not rewrite
- Chose
- Move endpoints individually behind a switch that can be flipped back.
- Instead of
- Full rewrite with a single cutover date.
- Why
- Each slice ships and proves itself in production; rollback is a config change, not an incident.
Tenant from the token
- Chose
- Resolve the tenant from the authenticated JWT.
- Instead of
- Trust a tenant header sent by the client.
- Why
- A header can be forged; a signed token cannot. Tenant isolation should not depend on client honesty.
Event contract tests
- Chose
- Tests assert the new write paths publish exactly the messages legacy publishes.
- Instead of
- Rely on downstream teams to notice differences.
- Why
- Makes the invisible contract explicit, so the migration can't silently break consumers.
Explicit query budgets
- Chose
- Default query time limits, with heavier aggregates given their own, larger budget.
- Instead of
- Unbounded queries tuned only when they hurt.
- Why
- At this data size a single slow aggregate can saturate a pool; budgets make the cost of each query a design decision.
05 Implementation
- Recorded the architecture in 29 ADRs, a written specification and a role matrix before and during the build.
- Integrated Keycloak through a shared multi-tenant OAuth2 starter, with staff suspend and restore wired through to identity.
- Added Resilience4j breakers, bulkheads and rate limiters; credentials from a secret manager via External Secrets.
- Centralised SQL table references to clear static-analysis security hotspots.
- Shipped Grafana golden-signal dashboards and alert rules alongside the service.
06 Outcomes
- Endpoints move in reversible slices behind per-endpoint switches instead of a single cutover.
- Event-contract tests turn any divergence from legacy behaviour into a failing build instead of a production surprise.
- In the same console I fixed defects including a currency-unit conversion that overstated one market's deposits, and an identity-path crash triggered by email addresses in URLs.
Outcomes are limited to what I can verify and share. Internal names, partners, infrastructure details and production data are deliberately omitted.