Architecture

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Architecture is the set of decisions about how a backend system is divided and how its parts stay consistent. This subsection groups the two halves of that work, which read best in this order: first whether and how to split a system, then how a split system stays consistent. Both are written for backend developers and architects who have to choose between a monolith, a modular monolith and microservices, migrate a system one safe step at a time, and keep data consistent once every service owns its own database.

  • Architecture Decisions and Migration Paths covers what a monolith, a modular monolith and microservices are, the benefits and drawbacks of microservices, when a monolith is still the right call, how to isolate backend and frontend behind an API gateway or backends for frontends, the migration paths (legacy stack, monolith to modular monolith, monolith to microservices, single-tenant to multi-tenant SaaS) and how to start a new project.

  • Architectural Patterns covers domain-driven design applied to microservices: strategic design, the tactical building blocks (entities, value objects, aggregates, repositories), why distributed transactions do not work across services, sagas, domain events and event storming, the transactional outbox, CQRS and event sourcing, assembled into one worked example.

Both halves share one vocabulary (bounded contexts, business capabilities, database per service) and link into each other wherever a decision on one side has consequences on the other: every migration path that ends with "and now that transaction spans two services" hands over to the saga, outbox and CQRS pages, and every pattern page assumes the split it builds on was made for the reasons the decisions pages lay out.

Version baseline

The code in the pattern pages is written and verified against Java 21, Spring Boot 4.1.x (Spring Framework 7.0.x), Spring Data JPA, Spring Modulith 2.x and Spring for Apache Kafka 4.1.x; the domain model itself stays plain Java (records and sealed interfaces) and Spring appears only in the application and infrastructure layers. The decision and migration pages are mostly technology-neutral, and name a technology only where they show a Spring Boot or Quarkus realisation of a step.

What’s covered

Part What it covers

Architecture Decisions and Migration Paths

Architectural styles, benefits and drawbacks of microservices, choosing between a monolith and microservices, layering backend and frontend, API gateway and backends for frontends, the four migration paths, starting a new project and a cheat sheet.

Architectural Patterns

Strategic and tactical domain-driven design, why distributed transactions fail across services, sagas, domain events, event storming, the transactional outbox, listen-to-yourself, CQRS, event sourcing, a worked end-to-end flow and a cheat sheet.

Reading path

  1. Read Architectural Styles, Benefits and Drawbacks of Microservices and Choosing: Monolith or Microservices? to decide whether to split at all.

  2. Read Layering and API Gateway and BFF for the edge of the system.

  3. Pick the migration path that matches your situation, starting from Migration Overview, or read Starting a New Project for a greenfield system.

  4. Once the system is split, read Strategic Design and the tactical building blocks, then Why Distributed Transactions Don’t Work and the consistency patterns in the order listed above.

  5. Finish with The Place Order Flow and the two cheat sheets.

Running example

The two halves use different running domains. The decision and migration pages follow Bookshop, a fictional online bookstore shown first as a legacy Java EE and Struts monolith, then as a healthy Spring Boot monolith with five business capabilities (catalogue, orders, payments, shipping, customer accounts), and finally strangled into a modular monolith, a set of microservices and a multi-tenant SaaS product. The pattern pages follow an e-commerce Order, Inventory, Payment and Shipping set of bounded contexts, which the worked example assembles into the place-order flow.

  • Spring Boot documents the Spring Modulith module boundaries, Spring Cloud Gateway routes and Spring Data mechanics the examples build on, and its Architectural Patterns page is a shorter introduction to the same vocabulary.

  • Quarkus is the Kubernetes-native alternative named in the new-project guide, and its Datasources and Transactions page covers Narayana LRA as saga compensation.

  • Messaging documents the Kafka and RabbitMQ mechanics behind domain events, the outbox and data synchronisation, including Kafka Connect.

  • GraphQL and OAuth cover a GraphQL gateway and the token-based authentication that replaces session cookies behind a gateway or BFF.

  • Database Migration covers keeping a legacy database and a new one in sync with Debezium change data capture, and Choosing the Right Database covers CQRS from the storage-selection angle.

  • Hibernate multitenancy complements the multi-tenant SaaS migration path.

  • Web Development and Apps document the frontend frameworks and the native client used as examples.

Bibliography

Books

The books are consulted references: the concept narrative comes from them, never the code, and on any discrepancy the pattern authors' current online catalogues (microservices.io, the Fowler bliki, the Domain Language DDD Reference, the cloud-provider architecture guides) and the framework documentation are authoritative.

  • Chris Richardson, Microservices Patterns: With Examples in Java, Manning, 2019, ISBN 978-1-61729-454-9: publisher page. The main narrative source for the decomposition, migration, saga, domain-event, outbox, CQRS and event-sourcing pages.

  • Tod Golding, Building Multi-Tenant SaaS Architectures: Principles, Practices, and Patterns Using AWS, O’Reilly Media, 2024, ISBN 978-1-098-14064-9: publisher page. The source of the multi-tenant SaaS migration path.

  • Kyle Brown, Bobby Woolf and Joseph Yoder, Cloud Application Architecture Patterns: Designing, Building, and Modernizing for the Cloud, O’Reilly Media, 2025, ISBN 978-1-098-11690-3: publisher page.

  • Abel Avram and Floyd Marinescu, Domain-Driven Design Quickly, InfoQ / C4Media, 2006, ISBN 978-1-4116-0925-9: free download from InfoQ.

  • Vaughn Vernon, Domain-Driven Design Distilled, Addison-Wesley Professional, 2016, ISBN 978-0-13-443442-1: publisher page.

  • Further reading that the books above lean on: Eric Evans, Domain-Driven Design: Tackling Complexity in the Heart of Software, Addison-Wesley, 2003 (domainlanguage.com); Vaughn Vernon, Implementing Domain-Driven Design, Addison-Wesley, 2013 (publisher page); Sam Newman, Monolith to Microservices, O’Reilly Media (publisher page); Neal Ford, Rebecca Parsons, Patrick Kua and Pramod Sadalage, Building Evolutionary Architectures, O’Reilly Media (publisher page); Mark Richards and Neal Ford, Fundamentals of Software Architecture, O’Reilly Media (publisher page); and Scott W. Ambler and Pramod J. Sadalage, Refactoring Databases: Evolutionary Database Design, Addison-Wesley, 2006, ISBN 978-0-321-29353-4.

The online sources of each half are listed under the Architecture Decisions and Migration Paths and Architectural Patterns bibliographies.