← All articles

Where should a service boundary begin?

Use ownership, data, and the cost of change to reason about the boundaries inside a growing application.

Starter article · An example publication for your new blog. Replace or edit it before launch.

Service boundaries influence deployments, data ownership, and the way a team makes changes. A useful starting point is to understand which parts of the system need to change together.

Follow the business operation

Consider an ordering application. Creating an order, reserving inventory, and collecting a payment have different rules and failure conditions. Write down each operation before deciding how many deployable services to create.

Ask three questions for each capability.

  • Who owns the data and validates changes to it?
  • Which operations must succeed in the same transaction?
  • Which other capabilities need to know that something happened?

The answers describe responsibilities. You can express them as modules inside a single application while learning how the domain behaves.

Make ownership explicit

A module should expose operations that preserve its rules. Let an inventory module reserve stock through a public operation, and keep the details of stock accounting inside that module.

type ReservationResult =
  | { ok: true; reservationId: string }
  | { ok: false; reason: "insufficient-stock" };
 
interface Inventory {
  reserve(sku: string, quantity: number): Promise<ReservationResult>;
}

The contract makes expected failure visible. The caller must decide what to show when inventory is unavailable, and the inventory implementation controls how reservations are recorded.

Validate quantities and identifiers at the boundary. Define what happens when a request is retried, especially if a successful result may have been lost on the network.

Trace a real change

Take a recent feature and list the modules, database tables, and deployments it touched. Repeat this for several features. Areas that repeatedly change together deserve a closer look.

Shared changes can reveal a missing abstraction, unclear ownership, or a workflow that crosses several valid responsibilities. Inspect the actual dependency before reorganizing the code.

Separate deployment when it helps

An independent service adds network failures, deployment coordination, and operational work. It can also provide independent scaling or isolate a capability with a distinct release cycle.

Record the reason for a split and the outcome you expect. For example, a background image processor may need different resource limits from the main application. A measurable requirement makes it easier to evaluate whether the new boundary works.

Start with responsibilities you can explain. Let observed changes and operating requirements guide the next step.