Cross-Service Concerns Under LVD

The moment a second service appears, the questions change. Where does the code that calls the other service belong? Who owns the type both sides share? Which layer does a step in a multi-service workflow live in? The reassuring answer in LVD is that none of this needs new rules. It needs you to be strict about one thing: how traffic leaves and enters a service.

Shared types sit at the bottom of every consumer

Take a ride-hailing platform with Trip, Dispatch and Payment services. All three need the same idea of a Driver and a Money amount. LVD already puts entity definitions in Schema, so the cross-service extension is a shared schema package, imported into the Schema layer of each service that needs it.

That placement is safe for a precise reason. The package holds only type definitions and validation schemas, with no runtime behaviour and no external integrations, so importing it adds no upward dependency. Each service stays downward-only. Because many services consume it, the package follows strict semantic versioning: documentation and optional additions are patch-level, new schemas or fields with migration support are minor, and removals or type changes are major releases that require consumers to move together. The book also recommends consumer-driven contract tests, in which each consumer publishes the slice of the schema it relies on and the provider verifies that it still honours them.

The wire always goes through Resources

Synchronous calls are the clearest case. When Trip needs to ask Dispatch for an available driver, the HTTP or gRPC client is a Resource in the Trip service:

// trip-service/src/resources/dispatchClient.ts
export async function findDriver(zone: string): Promise<DriverOffer> {
  const res = await http.post("https://dispatch/api/v1/offers", { zone });
  return DriverOfferSchema.parse(res.data);   // L1 schema validates the reply
}

A Tool in Trip calls this like any other resource. On the Dispatch side, the request arrives at its API layer, which delegates to its own Tools. The book applies the same logic to events: the publisher is a Resource used by a Tool, and the consumer is a Resource on the receiving side. No service ever reaches into another's Tools. Everything leaves a service through its Resources, and everything it carries is typed by Schema.

Two infrastructure pieces fit in without friction. An API gateway is itself a service whose main layer is the API layer: routing, authentication and rate limiting, with no business logic. A service mesh works at the network level beneath all of the layers and is transparent to them; that relationship has its own article.

Sagas are just tools in different places

LVD does not solve distributed transactions, and the book says so plainly. What it does is give the known solutions a structure. In a saga, each local step is a Tool inside its own service. A booking might run requestTrip in Trip, assignDriver in Dispatch and authoriseCard in Payment, each reacting to the previous step's event. If payment fails, compensating tools run in reverse: releaseDriver, then cancelTrip.

Global consistency emerges from the composition of these local executions and the events between them, yet no service imports another's Tools, because all inter-service communication passes through Resources. The book extends the same mapping to event sourcing, where the event store is a Resource, and to CQRS, where the command and query sides share Schema and Utils but keep separate Resources and Tools, so neither depends on the other.

The takeaway

Crossing a network does not change the layer rules. It changes which layer is responsible for the crossing, and the answer is Resources on the way out and API (or an event consumer) on the way in. Hold to that, and distributed systems inherit the same one-way graph as the code inside them. Explore transaction boundaries and sagas, sharing types across languages, and event-driven design with LVD.

What the book covers

  • The layout and semantic-versioning policy for a shared schema package
  • Consumer-driven contract tests with a worked example
  • How an API gateway and a service mesh relate to the layers
  • Event sourcing and CQRS mapped onto the layers
  • A complete saga with compensation steps, tool by tool