- Chapter
- Chapter 1 — Integration Architecture
- Prerequisites
- Volumes VI–VII
- You will be able to
- Identify system boundaries of different kinds and align them, assign ownership of data, APIs, events and commands, design contracts that cover syntax, semantics, quality, evolution and security, map relationships between contexts, and detect and remove boundary violations such as shared databases
- Covers
- System boundaries; Ownership; Contracts
On this page
- 1. Concept / Definition
- 2. Why It Exists
- 3. Core Concepts
- 4. How It Works Internally — Context Maps
- 4A. Deep Dive — Detecting Boundary Violations
- 5. APIs / Features / Syntax
- 6. Practical Examples
- 7. Common Problems & Mistakes
- 8. Performance & Production Considerations
- 9. Architecture & Design Considerations
- 10. Interview Questions & Answers
1Concept / Definition
An integration boundary is the seam at which one system's internal model, data and decisions end and an explicit, agreed interface begins. Everything inside is owned and changed freely by one team; everything that crosses is governed by a contract.

| TOC concept | Definition |
|---|---|
| System boundaries | The dividing lines between systems — bounded contexts, deployables, data stores, teams, organisations — at which integration happens |
| Ownership | The assignment of each piece of data, interface and decision to exactly one accountable owner (system and team) |
| Contracts | The explicit, versioned agreement at a boundary: structure, meaning, quality of service, evolution rules and security obligations |
2Why It Exists
Enterprises consist of many systems built and changed by different teams at different speeds. Without explicit boundaries, systems reach into each other's tables, depend on undocumented behaviour and must be released together. Boundaries with owners and contracts let each side evolve independently and make integration failures diagnosable.

3Core Concepts
3.1 System boundaries

| Boundary alignment | Effect |
|---|---|
| Bounded context = service = team = database | Ideal: one owner, one model, independent release |
| One context split across services | Chatty integration, distributed transactions |
| One service spanning many contexts | Big ball of mud, coordination between teams |
| Database shared across services | Boundary exists only on paper |
// Spring Modulith: make module boundaries explicit and verified in tests
@ApplicationModule(allowedDependencies = { "shared", "catalog :: api" })
package com.shop.orders;
@Test
void verifiesModuleBoundaries() {
ApplicationModules.of(ShopApplication.class).verify(); // fails on illegal access
}3.2 Ownership

| Ownership rule | Consequence |
|---|---|
| Every data element has one system of record | Others hold copies, never masters |
| Publisher owns event schemas | Consumers request changes |
| Receiver owns command/API schemas | Callers adapt to provider |
| Owner guards invariants | No external writes to owned tables |
| Owner runs the SLA | On-call, capacity, deprecation |
3.3 Contracts

# AsyncAPI contract excerpt: syntax + semantics + quality + evolution
channels:
orders:
address: orders.v1
description: |
OrderPlaced/OrderPaid/OrderCancelled for all orders. Owner: Orders team.
Delivery: at-least-once via outbox; key = orderId (ordered per order).
Compatibility: BACKWARD; breaking changes only via orders.v2.
messages:
OrderPaid: { $ref: '#/components/messages/OrderPaid' }4How It Works Internally — Context Maps

| Relationship | Meaning | Integration consequence |
|---|---|---|
| Customer–supplier | Downstream needs are negotiated with upstream | Planned contract changes |
| Conformist | Downstream accepts upstream model as-is | Low effort, high dependency |
| Anti-corruption layer | Downstream translates upstream model | Protects own model (Chapter 8) |
| Open host service / published language | Upstream offers a general public protocol | Many consumers, stable contract |
| Shared kernel | Two teams share a small model | Tight coordination — use sparingly |
| Separate ways | No integration | Duplicate where cheaper |
4ADeep Dive — Detecting Boundary Violations
| Violation | Detection | Fix |
|---|---|---|
| Cross-schema SQL / DB links | DB grants audit, query logs | Replace with API/events |
| Shared JAR with domain entities | Dependency analysis | Publish contract DTOs/schemas |
| Undocumented field semantics | Consumer incidents | Contract docs + examples |
| Consumers depending on internal events | Topic naming, ACL audit | Separate internal/integration topics |
| Synchronous chains through many owners | Tracing | Async propagation, local copies |
-- Grant audit: which foreign service accounts can touch orders tables?
SELECT grantee, table_name, privilege_type
FROM information_schema.role_table_grants
WHERE table_schema = 'orders' AND grantee NOT IN ('orders_app', 'orders_migrations');5APIs / Features / Syntax
| Tool | Boundary role |
|---|---|
| Spring Modulith | Module boundaries inside a monolith; verify(), event-based module integration |
| ArchUnit | Package/layer rules in tests |
| OpenAPI / AsyncAPI | Contract specifications |
| Schema registry | Enforced compatibility |
| Spring Cloud Contract / Pact | Consumer-driven contract tests |
| Backstage / EventCatalog | Ownership catalogue |
6Practical Examples
6.1 The report that froze the schema
A finance reporting job read directly from the Orders database. When Orders split amount into net and tax, month-end reports were wrong for three weeks. The fix: Orders published OrderPaid events with explicit net/tax fields; finance built its own read model.
6.2 One service, three owners
A "customer service" was edited by marketing, billing and support teams; every release needed three sign-offs. Splitting it along bounded contexts (Profile, Billing Account, Support Case) with explicit contracts cut release lead time from weeks to days.
6.3 Worked example — defining a boundary
Scenario. ShopNow was splitting its monolith. The orders team was asked to define the boundary of their new service before writing any code, so other teams would know what to expect.

| Step | Orders example |
|---|---|
| Capability | Accept and manage customer orders |
| Data owned | Order, order lines, order status |
| Contract | REST /orders, events orders.v1, command queue orders.commands |
| Owner | Orders team, 99.9% SLO |
| Governance | Semantic versioning, 6-month deprecation |
What it shows. The boundary definition sheet answers five questions in a fixed order. The capability is to accept and manage customer orders. The data owned is orders, order lines and order status, which no other service may write. The contract is a REST API at /orders, events on orders.v1 and a command queue orders.commands. The owner is the orders team, committed to a 99.9% availability SLO. Governance follows semantic versioning with a six-month deprecation period. With the sheet agreed, other teams could build against the contract while the service was still in development.
Takeaway. Define every boundary explicitly before implementation: capability, owned data, contract, owner and governance. A one-page sheet prevents months of ambiguity about who owns what.
6.4 Worked example — system-of-record table
Scenario. Customer names, prices and stock levels appeared in several services, and when they disagreed, teams argued about which value was correct.
| Data | System of record | Copies held by |
|---|---|---|
| Customer profile | Customer service | Orders (name, tier), CRM |
| Price | Pricing | Catalog (display), Orders (at order time) |
| Stock level | Inventory | Catalog (availability flag) |
What it shows. The system-of-record table makes ownership explicit. The customer service masters customer profiles; orders and the CRM hold copies of the fields they need, such as name and tier. Pricing masters prices; the catalog holds copies for display, and orders copy the price at order time, which is a historical fact rather than a stale copy. Inventory masters stock levels; the catalog holds only an availability flag. Copies are read-only and refreshed from the system of record, usually through events.
Takeaway. Every piece of data has exactly one system of record. Distinguish copies held for convenience from facts captured at a point in time, such as the price on an order, and document both.
6.5 Worked example — contract checklist
Scenario. A new event published by the payments team broke two consumers in its first week: one misread an amount in minor units as rupees, and another failed on an unexpected error status.
| Item | Present? |
|---|---|
| Schema (OpenAPI/Avro) | ✔ |
| Field semantics & examples | ✔ |
| Error model | ✔ |
| SLO, rate limits, delivery guarantee | ✔ |
| Versioning & deprecation | ✔ |
| Data classification | ✔ |
What it shows. The checklist covers what a schema alone does not. Besides the schema in OpenAPI or Avro, a contract needs field semantics with examples, such as amounts in minor units with a currency; an explicit error model; quality-of-service details such as SLOs, rate limits and delivery guarantees; versioning and deprecation rules; and data classification, which tells consumers how to store and protect the data. Reviewing these items before publishing would have caught both problems.
Takeaway. Review contracts against a checklist before publishing them. Most integration bugs come from misunderstood meaning, errors and guarantees, not from syntax.
6.6 Worked example — consumer-driven contract
Scenario. The shipping team depended on the OrderPaid event but had no way of knowing when the orders team might remove or rename a field they used. They found out about breaking changes in production.
Contract.make {
description "shipping needs orderId, lines and address from OrderPaid"
label "order_paid"
input { triggeredBy("publishOrderPaid()") }
outputMessage {
sentTo "orders.v1"
body(orderId: "ord_5001", lines: [[sku: "SKU-1", qty: 2]],
shippingAddress: [city: "Kolhapur", pin: "416001"])
}
}What it shows. A consumer-driven contract, here written with Spring Cloud Contract, states what one consumer actually needs: an OrderPaid message on orders.v1 with an order ID, lines with SKU and quantity, and a shipping address. The contract lives in the producer's repository, and the producer's build runs it as a test, so any change that breaks the shipping team's expectations fails the orders team's pipeline before release. Consumers also get stubs generated from the same contract for their own tests.
Takeaway. Let consumers express their needs as executable contracts that run in the producer's build. That turns "please don't break us" into an automated check.
6.7 Worked example — internal vs integration topics
Scenario. The orders team published its internal domain events directly to a topic that other teams consumed. Every internal refactoring then required negotiating with several consumers.
| Topic | Audience | Contract strength |
|---|---|---|
orders.internal.domain-events | Orders team only | Loose, ACL-restricted |
orders.v1 | Everyone | Versioned, registry-enforced |
What it shows. Separating topics separates promises from implementation. orders.internal.domain-events is restricted by ACLs to the orders team and can change freely as the internal model evolves. orders.v1 is the published integration topic: versioned, enforced by the schema registry, and changed only according to the evolution policy. A small translator publishes integration events from internal events. Other teams subscribe only to orders.v1.
Takeaway. Keep internal events and published integration events separate. Publish only what you are willing to support as a contract, and protect internal topics with access controls.
6.8 Worked example — boundary and team alignment
Scenario. Shortly after splitting into services, ShopNow found that one team owned parts of three services while two teams shared another, and every change needed several teams to coordinate.
| Team | Owns |
|---|---|
| Checkout | Cart, checkout API |
| Orders | Order lifecycle, orders.v1 |
| Payments | Payment intents, PSP integration |
| Fulfilment | Shipments, carriers |
What it shows. Aligning boundaries with teams fixed the problem. Each stream-aligned team now owns one bounded context end to end: checkout owns cart and the checkout API; orders owns the order life cycle and the orders.v1 contract; payments owns payment intents and the payment provider integration; fulfilment owns shipments and carrier integrations. Team boundaries and system boundaries match, so most changes stay within one team.
Takeaway. Design system boundaries and team boundaries together. When they diverge, coordination costs rise and boundaries erode, as Conway's law predicts.
6.9 Worked example — contract evolution policy
Scenario. Producers and consumers disagreed about what counted as a breaking change. A new enum value for order status, added by the orders team as "non-breaking", crashed the shipping service.
| Change | Allowed in same version? |
|---|---|
| Add optional field | ✔ |
| Add enum value | ◆ only if consumers tolerate unknowns |
| Remove/rename field | ✘ → new version |
| Change meaning | ✘ → new event type |
What it shows. A written evolution policy settles these debates in advance. Adding an optional field is allowed in the same version. Adding an enum value is allowed only if consumers are required to tolerate unknown values, which must be part of the contract. Removing or renaming a field requires a new version. Changing the meaning of a field or event requires a new event type entirely. Publishing the policy, and checking it in the schema registry and contract tests, prevents surprises.
Takeaway. Write down which changes are compatible, including subtle cases such as enum values, and require consumers to be tolerant readers. Enforce the policy with tooling.
6.10 Worked example — partner boundary
Scenario. ShopNow opened its order API to marketplace partners. The internal API, used by ShopNow's own services, could not simply be exposed as it was.
| Aspect | Internal boundary | Partner boundary |
|---|---|---|
| Trust | Service identity | Contracts + legal agreements |
| Contract | AsyncAPI/Avro | Public OpenAPI, webhooks |
| Change notice | Weeks | Months |
| Security | mTLS, ACLs | OAuth, signatures, WAF |
What it shows. Partner boundaries need stronger contracts than internal ones. Trust rests on legal agreements as well as technical identity; contracts are public OpenAPI specifications and webhooks rather than internal AsyncAPI and Avro schemas; change notice is measured in months instead of weeks; and security adds OAuth, request signatures and a web application firewall on top of mutual TLS and ACLs. ShopNow therefore built a separate partner API that translates to internal services, with its own versioning and support process.
Takeaway. The further a consumer is from your team and organisation, the stronger the contract must be. Separate partner-facing APIs from internal ones, so internal evolution does not break external commitments.
6.11 Worked example — measuring boundary health
Scenario. The architecture team believed boundaries were improving after a year of work, but had no evidence beyond opinions in retrospectives.
| Metric | Signal |
|---|---|
| Cross-team change coordination per release | Coupling |
| Consumer-breaking incidents | Contract gaps |
| Direct DB grants to foreign accounts | Violations |
| Synchronous fan-out depth | Temporal coupling |
What it shows. They began measuring four signals. The number of cross-team changes needed per release shows coupling. Incidents in which a consumer was broken by a provider change show contract gaps. Database grants to accounts from other services show direct violations of data ownership. The depth of synchronous call chains, from tracing, shows temporal coupling. Tracked monthly, the metrics showed real improvement in grants and coordination but rising call-chain depth, which became the next focus.
Takeaway. Measure boundary health with a few concrete signals and review them regularly. Metrics turn architecture discussions into decisions about where to invest next.
6.12 Worked example — reference data ownership
Scenario. Country codes, currencies, product categories and tax rates were copied into many services, and they drifted apart: one service still used an old category name, another an outdated tax rate.
| Reference data | Owner | Distribution |
|---|---|---|
| Country/currency codes | Platform MDM | Compacted topic |
| Product categories | Catalog | Events + API |
| Tax rates | Finance/Tax | API with cache |
What it shows. Even reference data needs a single owner. Country and currency codes are owned by a platform master-data team and distributed through a compacted Kafka topic, so any service can rebuild the full set. Product categories are owned by the catalog service and distributed through events and an API. Tax rates are owned by the finance team and served through an API with caching, because they must be correct at the moment of calculation.
Takeaway. Treat shared reference data like any other data: give it an owner, a contract and a distribution mechanism. "Everyone's data" quickly becomes nobody's data.
6.13 Worked example — modular monolith boundaries
Scenario. Before splitting into microservices, ShopNow restructured its monolith into modules, so boundaries could be tested while everything still deployed together.
| Rule | Enforcement |
|---|---|
| Modules communicate via published API types or events | Modulith verify() |
| No shared JPA entities across modules | ArchUnit rule |
| Each module owns its tables | Schema per module |
What it shows. Three rules made the modules real boundaries. Modules communicate only through published API types or events, verified by Spring Modulith's verify() in a test. No JPA entities are shared across modules, enforced by an ArchUnit rule. Each module owns its own tables in a separate schema. Violations fail the build. When a module was later extracted as a service, its boundaries had already been proven in practice, so extraction took weeks instead of months.
Takeaway. Establish and enforce boundaries inside a modular monolith before splitting it. Boundaries that work in-process are far cheaper to fix than boundaries between deployed services.
6.14 Worked example — boundary ADR
Scenario. The billing service read the orders database directly to create invoices. When the orders team wanted to restructure their tables, the conflict escalated to the architecture board.
| Section | Content |
|---|---|
| Context | Billing reads Orders tables for invoicing |
| Decision | Orders publishes OrderPaid v1; Billing keeps its own copy |
| Consequences | Eventual consistency (seconds); Orders free to refactor schema |
What it shows. The board recorded its decision in an architecture decision record. The context explains that billing reads orders tables for invoicing. The decision is that orders publishes an OrderPaid v1 event and billing keeps its own copy of the data it needs. The consequences are stated honestly: billing becomes eventually consistent, with invoices delayed by seconds, and orders gains freedom to refactor its schema. Both teams accepted the trade-off because it was explicit.
Takeaway. Record boundary decisions in ADRs with their consequences, including the costs. Explicit trade-offs make decisions easier to accept now and to revisit later.
6.15 Worked example — contract tests in the pipeline
Scenario. Contract tests existed at ShopNow, but they ran only occasionally, so breaking changes still reached production between runs.
| Stage | Check |
|---|---|
| Producer PR | Schema compatibility + consumer contracts |
| Consumer PR | Stubs generated from producer contract |
| Release | Can-I-deploy check (Pact broker) |
What it shows. Wiring contracts into the pipeline makes them continuous. Every producer pull request runs schema compatibility checks against the registry and verifies all consumer contracts. Every consumer pull request uses stubs generated from the producer's published contract. At release time, a can-i-deploy check against the Pact broker confirms that the version being deployed is compatible with the versions of its partners currently in each environment.
Takeaway. Contract tests deliver value only when they run on every change and gate deployments. Automate them in the pipeline rather than relying on scheduled runs or manual checks.
7Common Problems & Mistakes
- Shared databases as integration mechanism.
- Leaking internal models (entities) across boundaries.
- No single owner for data or interfaces.
- Schema-only contracts without semantics or SLOs.
- Boundaries misaligned with teams.
- Breaking changes without versioning.
8Performance & Production Considerations
| Aspect | Guideline |
|---|---|
| Data | Private databases, published contracts |
| Ownership | Catalogue with owners and on-call |
| Contracts | Full contract: syntax, semantics, quality, evolution, security |
| Verification | Contract tests, schema registry |
| Monitoring | Boundary violations and breaking-change incidents |
9Architecture & Design Considerations
- Align bounded contexts, services, teams and data stores.
- Use context maps to choose relationship patterns.
- Treat contracts as products with owners and lifecycles.
- Prefer copies of data via events over shared databases.
10Interview Questions & Answers
What is an integration boundary?
An integration boundary is the line where one system's internal world ends and an explicit, agreed interface with other systems begins. Inside the boundary, a team owns its data, model and implementation and can change them freely. Across the boundary, other systems interact only through published contracts, such as APIs, events or commands, never through internal tables or classes. For example, the orders service's boundary includes its database and domain model, while orders.v1 events and the /orders API are what it exposes. Clear boundaries make independent change, testing and deployment possible.
What is a system of record?
A system of record is the one system that owns and masters a given piece of data: it is where that data is created and changed, and its version is authoritative when copies disagree. For example, the customer service is the system of record for customer profiles, while orders and CRM hold read-only copies of the fields they need. Other systems receive updates from it through APIs or events and never change their copies directly. Naming a system of record for each entity is the foundation of integration design and of resolving data quality disputes.
What does a good contract contain beyond a schema?
A schema describes the structure of messages, but consumers also need to know what the data means and what they can rely on. A good contract includes field semantics with examples, such as units, currencies, time zones and allowed values; an error model describing failure responses or events; quality of service, such as latency and availability targets, rate limits and delivery guarantees like at-least-once with possible duplicates; evolution rules for versioning and deprecation; and security and data obligations, such as classification and retention. Most integration bugs come from these areas rather than from syntax.
Why is a shared database a poor integration boundary?
A shared database exposes each system's internal schema to every other system that reads or writes it. Any table change can break another system, so changes require coordination and nobody can evolve independently. There is no single owner enforcing business rules, because any system can write data directly, bypassing validation. Load and failures are shared too: one system's heavy query slows the others. Database integration also hides dependencies, which only appear when something breaks. Explicit APIs and events, with each system owning its data, avoid these problems at the cost of some duplication.
Who owns the schema of an event vs a command?
Ownership follows who defines the meaning. An event announces something that happened in the publisher's domain, such as OrderPaid, so the publisher owns its schema and consumers adapt to it. A command or API request asks the receiver to do something, so the receiver defines what it accepts, and callers adapt to the receiver's schema. Mixing these up causes problems: consumers who expect publishers to shape events for them create coupling, and producers who dictate command formats to receivers take away the receiver's ownership. Consumer-driven contract tests still let consumers protect their needs.
What is an anti-corruption layer?
An anti-corruption layer is a translation layer at the boundary of a bounded context that protects its model from an upstream model it does not control, such as a legacy system, a SaaS product or another team's service with a very different language. It converts incoming data into the context's own concepts and translates outgoing requests back, so foreign terms, codes and structures never spread through the domain code. When the upstream system changes, only the translation layer needs to change. It is a key pattern from domain-driven design for keeping boundaries clean.
How do you detect boundary violations?
Combine automated checks and reviews. Audit database grants to find accounts from other services with access to a service's tables. Analyse code and build dependencies for imports of other modules' internal packages or shared entities. Use distributed tracing to find unexpected synchronous call chains and calls that bypass published APIs. Audit access-control lists on internal topics to find consumers of events that were never published as contracts. Review incidents where consumers broke after provider changes, because they reveal hidden dependencies. Turn recurring findings into automated rules in pipelines.
How would you define integration boundaries for a new platform?
Start from the business: identify bounded contexts and capabilities, and decide which system is the system of record for each important entity. Align each context with one owning team and its own database. Draw a context map showing relationships between contexts, such as customer-supplier, conformist or anti-corruption layer. For each boundary, define contracts, APIs, events and commands, with semantics, quality of service and evolution rules. Then govern boundaries with an integration catalogue, consumer-driven contract tests in pipelines, ADRs for boundary decisions, and regular measurement of coupling signals such as cross-team changes and database grants.
Test your knowledge on this topic →Flashcards from this topic's 8 questions, filtered by level and type.