Quick revision
The short answer
We give sales and billing each their own Customer model inside their own bounded context, holding only the attributes that context needs, and each context stores and owns its own data. The two models share only a common customer id; anything one context needs from the other arrives through events or APIs and is translated at the boundary by an anti-corruption layer. We avoid a single shared Customer service that every team must change, and we write down which context is the source of truth for each attribute.
What to remember
In this answer, we saw that sales and billing each get their own Customer model in their own bounded context, holding only the attributes that context needs and storing its own data. A common customer id ties the models together, data flows between contexts through events or APIs and is translated by an anti-corruption layer, and we avoid a shared Customer service that every team must change. Finally, we record which context is the source of truth for each attribute.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
We give sales and billing each their own Customer model inside their own bounded context, holding only the attributes that context needs, and each context stores and owns its own data. The two models share only a common customer id; anything one context needs from the other arrives through events or APIs and is translated at the boundary by an anti-corruption layer. We avoid a single shared Customer service that every team must change, and we write down which context is the source of truth for each attribute.
Why this question is asked
Customer is the classic example of a word that means different things to different parts of a business. To sales, a customer is a relationship with a contact person and an account owner; to billing, it is a legal entity with a tax id and payment terms. Trying to serve both with one model is one of the most common ways microservice designs go wrong. Interviewers ask this question to see whether we understand bounded contexts, a central idea of domain-driven design, and can turn it into concrete ownership decisions. In this answer, we will recap bounded contexts, design the two Customer models, see how they share identity and exchange data, look at why a shared Customer service is a trap, and record who owns what.
1A Quick Recap of Bounded Contexts
A bounded context is a part of the system inside which every term has one precise meaning and one model. Domain-driven design, the approach that introduced the idea, says that large businesses do not have one consistent model of everything; they have several, each valid within its own area. The boundary is where the language changes.
In sales, a customer has an owner (the salesperson responsible), contact preferences (email only, no calls on Fridays) and a pipeline stage. In billing, a customer has payment terms (30 days net), a tax id, a billing address and a credit limit. These are not two views of one record that happen to differ; they are two models that serve different rules, change for different reasons and are owned by different teams.
2Two Customer Models, Each With What It Needs
So we let each context define its own Customer. The sales service has a class with the fields sales needs, and the billing service has a class with the fields billing needs. Neither model contains the other's fields, and neither team needs permission from the other to add one.
| Attribute | Sales context | Billing context |
|---|---|---|
| Customer id | Yes (shared identity) | Yes (shared identity) |
| Display name, contacts | Owner, source of truth | Not stored |
| Sales owner, stage | Owner, source of truth | Not stored |
| Legal name, tax id | Not stored | Owner, source of truth |
| Payment terms, credit limit | Read-only copy if needed | Owner, source of truth |
Notice the names: sales talks about a display name, billing about a legal name. They can differ, for example Acme for sales and Acme Holdings GmbH for billing, and both are correct in their own context. Each service stores its own model in its own database, so each can change its schema freely.
The common customer id is what ties them together. It is created once, usually when the customer first appears, and both contexts use it as the key. Without a shared identity, matching records across contexts becomes guesswork based on names and emails.
3Exchanging Data Across the Boundary
Sometimes one context needs a fact from the other. Sales may want to warn a salesperson that a customer has overdue invoices before offering a new deal. Billing does not hand over its model for that; it publishes an event such as CustomerCreditStatusChanged, or offers an API like GET /customers/{id}/credit-status.
On the sales side, an anti-corruption layer receives that information and translates it into sales' own language. An anti-corruption layer is simply a small piece of code at the edge of a context whose only job is translation, so that the other context's terms and quirks do not leak inside. Here, billing's status OVERDUE_60 might become a simple boolean or a warning level in sales.
So if billing renames its statuses, only this translator changes, and the rest of sales is untouched. The same pattern works in the other direction: when sales signs a new customer, it can publish CustomerSigned with the id and basic details, and billing creates its own BillingCustomer from it, asking for the tax id in its own onboarding step.
4Why One Shared Customer Service Is a Trap
The tempting alternative is a single Customer service that holds every attribute any team needs. It looks tidy, but every team now depends on one service owned by one team. Sales wants a new contact field, billing wants a new tax rule, marketing wants consent flags, and all three queue up on the same backlog. The model grows into a wide record that no one understands, and every change risks breaking a field someone else relies on.
In other words, a shared Customer service recreates the shared database problem at the API level. The boundary that matters is not around the word customer but around each business capability that uses it.
5Writing Down the Source of Truth
Some attributes will exist in more than one context, such as an address that both sales and billing care about. For each such attribute, we decide which context is the source of truth, meaning the only place where it may be changed, and the others keep read-only copies updated by events. The table above is the kind of record we keep, in the service catalogue or an architecture decision record, so new team members and reviewers can check it.
This written decision prevents the slow drift where two services both start editing the same field and nobody knows which value is right.
6Follow-up questions
Who creates the customer id?
Usually the context where customers first appear, often sales or a small identity service whose only job is issuing ids and maybe a minimal shared record. The important point is that one place issues the id and every other context reuses it; we never generate separate ids per context and try to match them later.
What if billing needs the sales owner's name on an invoice?
Then billing keeps a read-only copy of that one field, received from a sales event, and treats sales as the source of truth for it. It does not get write access, and if the value is missing it shows a sensible default rather than calling sales synchronously during invoice generation.
Is an anti-corruption layer needed even between our own teams?
It is most valuable with legacy or external systems, but a light version helps between internal contexts too. It keeps each context's language clean and means a change in another team's event format touches one class instead of spreading through the code.
7Conclusion
In this answer, we saw that sales and billing each get their own Customer model in their own bounded context, holding only the attributes that context needs and storing its own data. A common customer id ties the models together, data flows between contexts through events or APIs and is translated by an anti-corruption layer, and we avoid a shared Customer service that every team must change. Finally, we record which context is the source of truth for each attribute.
Open with
I would model this as two bounded contexts, each with its own Customer model. The sales context has a customer with a display name, contact preferences, the sales owner and a pipeline stage.
Then, if they want more
The billing context has a customer with a legal name, tax id, payment terms and billing address. Each service stores and owns only its own model in its own database, so each team can change it without asking the other. What they share is identity: one customer id, issued once, used as the key in both contexts.
When one context needs information from the other, for example sales wanting to know a customer has overdue invoices, billing publishes an event or exposes an API, and sales translates it at the boundary with an anti-corruption layer into its own terms, like a simple credit warning. That way a change in billing's statuses touches only the translator.
I would deliberately avoid a single shared Customer service holding every attribute, because every team would queue on one backlog and the model would keep growing. For attributes that exist in both contexts, like an address, I would write down which context is the source of truth, record it in the catalogue, and keep read-only copies elsewhere updated by events.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Cloud documentation, Resilience4j documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Two teams both need a Customer model: sales needs contact preferences and the sales...": https://scrivio-interview-library.netlify.app/spring-boot/microservice-design/ae7a840370/