Testing the Upper Layers: Contracts, the UI and a Few End-to-End Checks
API and UI code translate between worlds, so test the translation, not the business rules: contract tests, UI outcome tests and where end-to-end fits.
Every layer has its shortcuts, but the UI's are the most seductive because the reward is instant. Change a few lines, refresh the browser, and the screen looks right. That feedback loop is exactly why the top layer collects more architectural debt than any other, and why LVD names three specific ways it goes wrong.
Axiom A6 sets the boundary. The UI may depend on Schema and Utils, and on the published contracts of the API, MCP, Skills and Agents layers, such as a generated typed client. It may not depend on Resources or Tools, nor on the implementation of anything in the layers from API upward. The reasoning is practical: the UI runs on a device you do not control, so database clients, secrets and business rules must never ship to it.
Within the UI there is an ordering too. Features do not import each other, and only a dedicated services folder touches the network. The three anti-patterns below each break one of these rules.
Picture a ride-hailing app. The trip screen shows a fare estimate, and a developer, wanting it to feel instant, computes it in the component:
// ui/features/trip/components/FareBadge.tsx: the violation
const fare = base + km * perKm * (demand > 1.5 ? 1.5 : 1);
return <span>{formatMoney(fare, "EUR")}</span>;
The surge rule now lives in two places: the component, and the Tool that prices the real trip. Sooner or later the business adjusts the threshold, somebody edits one copy, and a rider is quoted one price then charged another. Every additional client, such as a mobile app or an AI assistant, needs its own copy of the rule as well.
The corrected component requests the estimate from the API and formats whatever number comes back. Formatting is the UI's job. Deciding the number is not.
This is the true dependency violation of the set. UI code imports a Resource or a Tool directly, or makes network calls from anywhere except the services folder. The first form pulls server code into the browser bundle: the Tool, the Resources beneath it, and the database drivers and credentials they need. In some frameworks, where the server-client line is blurred, it may even seem to work. Meanwhile it walks around everything the API layer provides, namely authentication, rate limiting and audit logging.
The second form respects the network boundary but builds a URL by hand and accepts whatever JSON returns. When the API changes, nothing stops the build, so the failure appears at runtime in front of a user. The remedy is a typed client from the services folder, generated from the API's specification.
The third pattern is the UI's version of the lateral coupling that Axiom A5 forbids between tools. Say a booking-confirmation feature imports a seat-map component and a store from the seat-selection feature. Now a tweak to how seats are drawn alters the confirmation screen, the seat-selection team cannot reorganise its state without breaking a screen it does not own, and each import makes the features a little more like one feature.
The book lists three exits. Shared presentational pieces move to the common components folder and receive data as props. Shared server data is read from the query cache through each feature's own hook. Features that truly belong together are composed at the page level.
The three are not equally easy to detect. Reaching past the API is a boundary violation, so a lint rule can make it build-breaking. Cross-feature imports are caught by a dedicated rule. Business logic in components is the one that is best caught in review, and the book offers a sharp question for it: would a second client have to repeat this rule?
The UI is the most volatile layer, so it is tempting to treat it as exempt from rules. The opposite is true: because it changes fastest and is edited under pressure, its boundaries need to be mechanical. For the foundations, read why the UI is its own layer and what it may import, and for the folder rules see the UI layer's structure.