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.
Somewhere in your wiki is a diagram of the system's layers, drawn after a planning offsite and not touched since. It shows what the team intended. The code shows what the team did, and the two parted ways months ago. A diagram that has to be redrawn by hand is a diagram that will eventually lie.
The book's answer is lvd-diagram, one of the three companion tools alongside lvd-lint and lvd-metrics. Its layer diagrams are built from the same dependency graph that lvd-lint constructs, so what you see is the codebase as it stands rather than an aspirational model. Violations show up as dashed red arrows, which makes them hard to miss even in a large picture.
$ lvd-diagram --type layers --output architecture.svg
The practical consequence is a change in what the diagram is for. A hand-drawn one is a document that someone owns and updates. A generated one is a build artefact. Regenerate it whenever the graph changes and nobody has to remember to keep it honest, and a disagreement in a design review can be settled by looking at the output instead of arguing from memory.
LVD rests on a claim that layers differ in how fast they change, with Schema near the stable end and the upper layers near the volatile end. The heatmap checks that claim against your own history. It overlays change frequency, taken from git, onto the layer diagram, colouring each component from cool for rarely changed to hot for frequently changed. Any component whose measured change rate falls well outside what its layer predicts gets a highlighted outline.
$ lvd-diagram --type heatmap --git-history 90d --output volatility-heatmap.svg
To choose how far back to look, pass a duration to --git-history. The book's example uses 90 days, long enough to mean something yet recent enough to reflect current work. A shorter window reacts to recent work faster but is noisier, and a longer one smooths over the quarter when a team was busy somewhere unusual.
In a well-aligned codebase the picture shows a gradient: cool near the bottom, warmer towards the top. The interesting findings are the exceptions. According to the book, a hotspot in a lower layer can mean one of two things. The component may really belong in a more volatile layer, or it may have accumulated responsibilities beyond its original purpose.
Take a hypothetical date-formatting helper in Utils that glows hot. To tell the two readings apart, open its history and ask why it keeps changing. If every edit is a new locale or a new display rule from the product team, the rule is volatile and probably belongs higher up. If the edits are unrelated to each other (a rounding fix this month, a currency tweak the next), the helper has become a junk drawer, and the remedy is to split it.
It is also worth noticing what is not hot. If the layer where your business rules live barely changes in a product that ships weekly, ask where the changes are really being made.
A heatmap points at places to look; it does not decide anything. A one-off migration can heat a component for a quarter, and a large rename can colour half a layer. Read it next to a quantitative measure such as the alignment figure that lvd-metrics reports, and with the rules enforced by lvd-lint. The idea of measuring volatility from history is developed in measuring volatility and ordering components.
Generate the diagram instead of drawing it, and let the heatmap show where reality disagrees with the layer you chose. The book describes more output modes and a configuration file for these diagrams, and they are listed below.