Extract a module before extracting a service

Pulling a service out of a monolith is a distributed systems problem plus a refactoring problem at the same time, and the refactoring is the part that determines whether the result is any good.

src/
  Billing/          ← everything billing, including its own models
    Domain/
    Http/
    Infrastructure/
  Ordering/
  Shared/           ← the only thing both may import

# the rule enforced in CI:
#   Billing may not reference Ordering except through OrderingContracts

Once the boundary holds as a namespace rule with a linter enforcing it, extracting the service is mostly deployment work — and if the boundary cannot be made to hold in one process, it will not hold across a network either. The cheap enforcement is a static analysis rule or a test that greps imports; both are a morning’s work. The failure of the alternative is well known: a service is extracted, the coupling comes with it, and now the coupling is over HTTP.