The Schema Layer: Your Most Stable Code
The Schema layer is LVD's lowest and most stable layer. See what belongs in it, how to pick a schema language, and how to lay out its folders.
A tour of every layer from Schema at the bottom to the UI at the top.
The Schema layer is LVD's lowest and most stable layer. See what belongs in it, how to pick a schema language, and how to lay out its folders.
Per-field checks miss rules that span fields, and shared schemas can lose them between languages. Two fixes for a Schema layer used by several services.
The Utils layer holds pure functions grouped by business domain. See what purity buys you, why technical folders fail, and the complexity cap the book sets.
One small feature carried through the two bottom layers: a rental schema with a cross-field rule, and pure fare utilities that import its types.
Trace three kinds of change through a tool that uses Schema, Utils and Resources, and see why the two bottom layers earn the heaviest testing.
Repository, Adapter, Facade and Anti-Corruption Layer are four ways the Resources layer translates between outside systems and your domain model.
A retry loop can prolong an outage it was meant to ride out. Here is a capped, jittered backoff you can prove correct, and the layers LVD gives each part.
Caching and error translation both hide something from callers: where data came from and how a vendor fails. See how the Resources layer handles each.
Resources code talks to slow, stateful systems. Mocks, containers and contract tests each answer a different question about it, and 80% coverage is the target.
Where to put the vendor-neutral contract so that a hospital switching EHR systems becomes a contained change in the Resources layer.
Every LVD tool comes out of one factory with five named parts. Here is what they are, why validation stays out of the handler, and what a two-part result buys.
One tool per directory, names that read as commands, and a registry that discovers tools at startup: how LVD keeps Layer 4 easy to navigate as it grows.
Inside a tool, resource calls and pure functions combine in four ways: in sequence, in parallel, by condition, and with a plan for failure. How to choose.
Why the tool, not the repository, owns the transaction boundary, and when a workflow that spans services needs a saga with compensating steps instead.
Axiom A5 forbids tools from depending on other tools. Here is why that small rule keeps a business-logic layer testable, acyclic and easy to change.
How LVD tools are tested with injected resources, which four behaviours to pin down, where integration tests take over, and what the TradeX trading tools show.
The API layer has one job: protocol translation. What a thin REST route looks like, how domain errors become status codes, and how to pick a versioning style.
GraphQL and gRPC are extra adapters over the same tools, and OpenAPI docs can come straight from Schema-layer definitions. Where each concern belongs in LVD.
Why LVD puts authentication and authorization in a sublayer of the API layer, not in tools, and how JWT, OAuth, API keys, roles and rate limits fit together.
What the Model Context Protocol layer (L6) does in LVD: a standard adapter that lets AI agents find, understand and call tools without knowing your internals.
How to authenticate AI agents at an MCP server without a classic middleware bug, and how to report tool failures so a model can act on them.
REST routes and MCP tools are adapters, so their tests check contracts, not business rules. The kinds of test LVD uses, and what one end-to-end check proves.
Skills are the one LVD layer made of documents, not code. See what a skill file contains and why its error-handling section carries the most weight.
How LVD keeps skill documents honest: versioned beside the code, linked to tool schemas, validated in the build and tested through their example conversations.
In LVD an agent is an explicit configuration, not just a prompt. How its parts fit together and how it picks, sequences and recovers tool calls.
How LVD watches an AI agent in production and limits what it may do: metrics, anomaly alerts, confirmations, tool-level authorisation and human oversight.
Skills score 0.95 and Agents 0.97. Why the order matters, what drives change in each layer and how a change in the upper layers stays local.
The book's customer-service agent lists its limits in its own configuration. Here is why a limit that matters should also be enforced one layer down.
Why the second edition promotes the UI from outside client to Layer 9, and how a simple inheritance rule for volatility puts it above Agents.
One import rule keeps a front end changeable: features never import each other. Why it holds, and what to do when two features need the same thing.
How to decide whether a rule belongs in a component or behind the API, and why server data should be treated as a cache instead of copied into a store.
Two jobs belong at the seam between a screen and the API: assembling the data a screen needs, and turning failures into outcomes a user can act on.
A screen that shows an AI agent should depend on the agent's event contract rather than its prompts, and approvals must be enforced by the host, not the page.
Why accessibility is cheapest in the UI's shared components, and how tests that find elements by role and name double as an accessibility check.
The book's storefront example shows a button and a chat assistant reaching the same business rule. Why that shared path is the best test of a UI layer.