Blog
Notes from the build
Why Mainstay is shaped the way it is. Each article tells one entry in its decisions log: what was chosen, and what it was weighed against.
A token holds less than its account
The content API reads and writes over JSON and as MCP tools, behind tokens with capabilities of their own. A token never holds more than its account, and an agent given one that drafts cannot publish.
Read the articleCapabilities derived from your types
Mainstay's roles hold capabilities, computed from the content types you register rather than stored. Laravel's Gate enforces them, through one policy for each kind of content.
Read the articleDrafts beside what is live
The entry's row always holds what is live, so the site reads one row. A change waits as a draft of what differs, and publishing it keeps what it replaced as a revision.
Read the articleA relation is an id, read defensively
Mainstay stores a relation as a plain id, with no foreign key, and a read follows it to a depth. A target that is gone reads as missing rather than failing the read.
Read the articleEvery size written once, at upload
Mainstay writes every size an image field declares, as AVIF and WebP, the moment a file is uploaded, and serves them as plain files. Nothing is resized on request, and nothing ever needs invalidating.
Read the articleBlocks are data, and Blade draws them
A page's blocks are stored as data, each one a typed class with fields, inside the entry's content. Blade turns them into markup when the page is drawn, and never before.
Read the articleOne route for every page
An entry's address is declared on its type, and one fallback route answers every GET path the site's own routes do not. Here is why a fallback, and what it means for the routes you write yourself.
Read the articleOne query layer, and everything else a transport
A Blade template, a seeder, the admin and the API all read and write content through the same few calls, which ask Laravel's Gate before anything else. No consumer gets a different shape, or a weaker check.
Read the articleOne value, or one per language
In Mainstay a field says whether it is translated. A title gets a value per language, a date or a price keeps one, and the schema keeps them apart instead of a convention.
Read the articleSync in development, check in CI
Mainstay alters a development database to match the classes, and refuses to in production. There the migrations are written by hand, and a check fails the build when they and the classes disagree.
Read the article