Assessing a Codebase Before You Migrate
Before moving any file, measure: extract the dependency graph, compute volatility from history, find the gaps against the target layers, and plan bottom-up.
Two teams want the same destination from different starting points. One has a single deployable with a decade of history and no internal walls. The other has forty services, each tidy from the outside and a tangle inside. The book treats these as different problems: the first needs boundaries, and the second needs to find out whether the boundaries it has are the right ones.
A monolith concentrates every concern in one unit, usually with little structure beyond folder names. The book's first move is to mine version-control history for natural volatility clusters, since components that change together at similar rates are candidates for the same layer.
The procedure is to compute each file's volatility, cluster the files on that measure, check each cluster for semantic sense, adjust and re-cluster if it does not make sense, and then map each cluster to the layer whose range fits best. Expect familiar shapes: a big stable group of types and constants that points to Schema, a medium group of helpers for Utils, a scattered group of external integration code for Resources, and large high-change groups of business logic for Tools.
The interesting files are the ones that fall between clusters or are tightly coupled to several of them. These are boundary components, and the book says they need careful manual classification rather than trusting the algorithm.
The extraction then follows four phases, strictly bottom-up. Foundation moves Schema and Utils first, because they have almost no upward dependencies and only import paths change. Integration extracts Resources, using branch by abstraction for each major dependency. Logic, the longest phase, decomposes the tangled business code into tools and builds the API. Intelligence adds MCP, Skills and Agents, which are additive and need no restructuring of existing code. The book walks through a full case study of a five-hundred-thousand-line monolith, which is worth reading for its sequencing and its candid account of a dip in feature delivery early on.
Here the service boundaries already exist, but individual services may have no internal structure, and the boundaries themselves may not reflect how things change. The least disruptive route is to apply LVD independently inside each service, giving every one its own schema, utils, resources, tools and API folders. It can proceed service by service, beginning with the ones in most pain, measured by Change Impact Radius, cycle count or poor coverage. The book estimates that a team can restructure one small service of under twenty thousand lines per sprint.
Two further ideas are specific to this starting point. The first is the shared schema package. In many microservice estates, the same entity, a customer or an order, is defined separately in several services, with subtle differences. Extracting those definitions into one versioned package removes the drift. The care needed is in versioning: breaking changes need a major version and coordinated upgrades, while additive changes can be adopted at each service's own pace.
The second is boundary refinement. Occasionally the analysis shows that two services share so many types and helpers that they probably belong together, or that one service contains components with very different volatility profiles and should be split. The book lists indicators, such as two services whose shared schemas make up over half of their combined schema surface, or services that always have to be deployed together. It also warns that this is a high-cost, high-reward activity to attempt only after the internal restructuring is finished, when you have clear data to justify it.
Monolith or microservices, the order of operations is the same: measure volatility, start at the bottom, and hold the structural moves until you have evidence. What changes is whether you are drawing boundaries or auditing them. For the techniques that keep either migration safe, see the migration patterns; for how the two architectures compare in general, read LVD vs. microservices, and for the inside-a-service view, LVD inside a single microservice.