Where does a template get its content from? Two answers were ruled out. Eloquent models in the template give the site a code path of its own, different from the API's, and an API nothing on the site uses quietly rots. Asking the site's own API over HTTP is a round trip out of the process and back in, to read a row the process could have read.
So there is one query layer, and everything else goes through it. It is a local API: the call the REST endpoint takes, run against the database with no HTTP hop.
The calls
$latest = Mainstay::find(Article::class,
where: ['publishedOn' => ['<=' => now()->toDateString()]],
sort: '-publishedOn',
limit: 3,
);
$tagged = Mainstay::paginate(Article::class, where: ['tags' => $tag->id], perPage: 10);
$layout = Mainstay::global(Layout::class);
find, findById and paginate read, global reads a global, and create, update and delete write. A template, a seeder, an import command, the admin's forms and the API all make these calls, so there is one place where what an entry looks like as data is decided.
Data, not closures
where and sort are arrays and strings rather than closures over a query builder, so an HTTP query string can carry the same condition a template passes. A condition is a field and a value, or a field and operators: =, !=, <, <=, >, >=, in and not_in. Over the API the same read is ?where={"publishedOn":{"<=":"2026-11-03"}}&sort=-publishedOn.
A field marked internal is refused as a filter or a sort to a reader who may not see it, so its value cannot be read back off which entries match.
Typed objects, not models
A read hands back the declared class, hydrated through its field types: $article->publishedOn is a CarbonImmutable, $article->tags a list of Tag. The layer is written on Laravel's query builder rather than Eloquent, because an Eloquent model would hold the row in an attribute bag, a second object beside the typed properties a template reads. The current site and the trash are scoped in the one query every read starts from, so no read can be written that forgets either.
Access is opted out of, out loud
Every call asks Laravel's Gate first, about Mainstay's own signed-in user and never the default guard's, which on a site with members of its own would be a visitor. Without a user, reading is open, internal fields are not, and nobody writes. Code writing on its own authority, such as a seeder or an import, says so:
Mainstay::create(Tag::class, [
'title' => 'Architecture',
'slug' => 'architecture',
], overrideAccess: true);
Permissions are checked unless the caller passes overrideAccess: true, an argument you can search a codebase for.
Depth, the same on every path
depth says how far a read follows relations. The default is 1: the entries an entry points at are loaded, and their own relations are not. Because it is an argument of the call rather than something a transport decides, a template and an HTTP client asking the same question get data of the same shape, not one nested and one flat.
The transports
The admin is a transport over this layer: its forms validate what a seeder's write validates and are refused what Gate refuses. The REST API is another, and the MCP server a third, each a thin layer that finds the type, makes the call as the caller and turns the answer, or the refusal, into its own format. A rule written once in the layer holds on all of them.