Reading time: 6 min Tags: Modular Monolith, Architecture, Legacy Modernization, Maintainability, Engineering Strategy

Designing Service Boundaries Without Microservices

Learn a practical, small-team method for carving clear service boundaries inside a monolith so teams can ship faster, reduce bugs, and modernize safely without adopting full microservices.

Many teams inherit a monolith where every feature touches the same folders, the same tables, and the same handful of “utility” functions. Shipping gets slower not because engineers forgot how to code, but because the system no longer tells you where a change belongs or what it might break.

Microservices are often presented as the cure, but the operational overhead can be too expensive for a small team. There is a middle path: design service boundaries as if you might split later, then enforce them inside the monolith. You get most of the clarity benefits while keeping deployment, observability, and operations simple.

This post is a practical method for identifying boundaries, defining their contracts, and implementing them as a modular monolith. The goal is to reduce cross-cutting changes, prevent data coupling, and make modernization incremental.

Why boundaries beat more refactors

Refactoring without boundaries often turns into “cleanup theater”: code moves around, naming improves, but the same changes still require editing seven files across three domains. Boundaries change the shape of work. When boundaries are clear, a feature is more likely to fit within one module, with one team or owner responsible for it.

A useful boundary has three properties:

  • High cohesion: the module groups responsibilities that change together.
  • Low coupling: other modules interact through a small, stable surface area.
  • Clear ownership: it is obvious who approves changes to the module and its contract.

Notice that none of these require separate deploys. You can enforce them with repository layout, build-time checks, and disciplined data access rules.

Key Takeaways
  • Start boundaries from user workflows and business capabilities, not from existing classes and tables.
  • Define a boundary contract early: owned data, allowed operations, and integration style.
  • Enforce boundaries inside the monolith first; split into services only if the constraints remain helpful.
  • Prefer “one direction” dependencies: UI → Application → Domain → Infrastructure, and never the reverse.

Find good boundaries by following the work

The fastest way to discover boundaries is to follow a workflow that delivers value and map which parts of the system it touches. Pick 3 to 5 workflows that are frequent, revenue-critical, or historically buggy. For each, list the screens, jobs, and integrations involved, then identify which concepts are doing the heavy lifting.

Examples of workflow-centered candidates include “quoting,” “fulfillment,” “subscriptions,” “content publishing,” or “support ticket triage.” These are capabilities. They make better boundaries than technical slices like “controllers” or “database layer.”

Boundary discovery checklist (copy and use)

  1. Pick a workflow: name it in verbs and nouns (for example, “Refund an order”).
  2. List the core decisions: what rules determine success or failure (eligibility, pricing, inventory checks).
  3. Identify owned state: which records represent the “truth” for that capability.
  4. Find external dependencies: payments, email, warehouse systems, analytics.
  5. Draw the “happy path”: where should the core business logic live.
  6. List exceptions: cancellations, retries, manual overrides, back-office corrections.

If two workflows regularly require coordinated changes, they may belong in the same boundary. If one workflow often breaks because another area “helpfully” edited shared data, you likely need a stricter separation.

Write a boundary contract before you move code

A boundary without a contract is just a folder. A contract tells the rest of the codebase how to interact with the capability and what it must not do. In a monolith, your “contract” can be a combination of interface types, module public APIs, and conventions enforced by code review and tooling.

Keep the contract small and boring. The best contracts avoid leaking internal tables or internal rule engines. Instead, they expose operations in business terms and return stable results.

What a boundary contract should include

  • Owned data: which tables or collections are the source of truth for this capability.
  • Public operations: commands and queries other modules may call.
  • Integration style: synchronous calls, events, or scheduled jobs, and which direction dependencies go.
  • Invariants: rules that must always hold (for example, “a shipment cannot be created without a paid order”).
  • Extension points: the only supported way other modules can influence behavior (for example, “discount rules plug-in”).
{
  "module": "Fulfillment",
  "owns": ["shipments", "shipment_items"],
  "publicApi": {
    "commands": ["CreateShipment(orderId)", "CancelShipment(shipmentId)"],
    "queries": ["GetShipmentStatus(shipmentId)"]
  },
  "invariants": [
    "ShipmentItems must reference a Shipment",
    "A shipment cannot move to Shipped without a carrier label"
  ],
  "allowedDependencies": ["Orders (read-only view)", "Notifications (send)"]
}

This is not meant to be a framework. It is a shared understanding. Even a lightweight document like this can stop accidental coupling early.

Implement as a modular monolith first

Once you have a boundary and a contract, implement it inside the monolith in a way that makes “the right thing” easy and “the wrong thing” hard.

Here is a sequence that works well for small teams:

  1. Create module namespaces: group code by capability (not by technical layer) and define a “public” surface.
  2. Introduce data access rules: only the module can write its owned tables; other modules use a read model or query API.
  3. Move business rules next: prioritize domain logic (validations, state machines) before moving edge concerns (emails, logging).
  4. Replace direct calls with module calls: treat each replacement as a small migration with tests.
  5. Add a dependency check: even a simple static rule that prevents importing internal packages pays off quickly.

A practical “done” definition for a new boundary

  • Other parts of the codebase can accomplish required tasks using only the module’s public API.
  • No external code writes the module’s owned data directly.
  • The module has tests around core invariants (not necessarily full end-to-end coverage).
  • There is a clear owner for contract changes (a team, or a named maintainer).

Example: a commerce team carves out fulfillment

Imagine a small commerce company with one monolith. Over time, “orders” grew tentacles: shipment creation, carrier label generation, customer notifications, and warehouse handoff all live in one tangled service class. Bugs often happen when a feature in “support tools” updates an order status and accidentally triggers shipping behavior.

The team selects a workflow: “Ship a paid order.” They discover three concepts that change together: shipment state, label generation, and warehouse handoff. They create a Fulfillment module.

Key design choices:

  • Owned data: Fulfillment owns shipment records. Orders remain owned by the Orders module.
  • Read-only bridge: Fulfillment can read a stable view of paid orders (for example, order id, destination, line items), but cannot update orders directly.
  • Explicit commands: the only way to create a shipment is CreateShipment(orderId).
  • Notifications as a dependency: Fulfillment can request “send shipment confirmation,” but it does not format emails itself.

After moving the shipment logic behind this API, support tools can no longer “accidentally ship” by tweaking an order row. They must call the module command, which enforces invariants and produces a predictable audit trail. Shipping bugs decrease and the team can later split Fulfillment into a separate service if operationally justified.

Common mistakes that make boundaries leaky

  • Sharing tables for convenience: if two modules write the same table, you do not have a boundary. Use owned tables plus read models.
  • Public API that mirrors internals: if callers pass database ids for internal records they should not know about, you are exporting your schema.
  • Cross-module “helper” utilities: shared helpers often become a backdoor for mixing responsibilities. Prefer duplication over coupling for small, stable logic.
  • Big-bang migrations: moving everything at once makes it hard to prove safety. Migrate one workflow slice, then iterate.
  • Ignoring ownership: if everyone can change the contract, it will drift. Set clear reviewers or a module maintainer.

A good litmus test is: can a new engineer tell where to implement a change after reading the contract and the module’s public API? If not, your boundaries are still fuzzy.

When not to do this

Boundary work is an investment. It pays off when your change costs are rising, but it is not always the best next step.

  • Your product is still searching for fit: if workflows change weekly, hard boundaries may slow necessary experimentation.
  • One tiny team owns everything: if there is no coordination cost, focus on tests, logging, and simplifying hot spots first.
  • You cannot enforce the rules: if your environment or culture cannot support basic dependency checks or code review discipline, boundaries will erode.
  • The pain is operational, not architectural: if outages come from infrastructure limits, focus on scalability, caching, and observability before reorganizing code.

In these cases, use lighter-weight improvements (test coverage around critical paths, better monitoring, simplifying a few risky modules) and revisit boundaries when the system stabilizes.

Conclusion

You do not need microservices to get the core benefit people want from them: clear separation of concerns and predictable change. By discovering boundaries through workflows, writing a simple contract, and enforcing “owned data + public API” inside a modular monolith, small teams can modernize safely while continuing to ship.

If you later decide to split a boundary into a service, you will already have done the hardest part: designing the interface and reducing coupling.

FAQ

Is a modular monolith just “better folder structure”?

No. Folder structure helps, but modularity is about enforced rules: controlled dependencies, explicit public APIs, and data ownership that prevents accidental writes across domains.

How do we enforce “only this module can write these tables”?

Start with convention and code review, then add light tooling. Common approaches include restricting database access through module-specific repositories, using separate database schemas per module, and adding static checks that flag imports of internal packages.

Should boundaries match teams or business domains?

Prefer business capabilities first, then align ownership where possible. If boundaries only mirror org charts, they can shift every reorg. Capabilities tend to remain stable longer.

Do we need events and asynchronous messaging for boundaries to work?

No. Synchronous module calls can be fine inside a monolith. Introduce events when you need loose coupling, background processing, or auditability, not as a default.

How many boundaries should we create at once?

One. Pick the most painful workflow, create a boundary with a narrow contract, migrate a slice, and learn from it. Repeating a proven approach is faster than designing a perfect map upfront.

This post was generated by software for the Artificially Intelligent Blog. It follows a standardized template for consistency.