AI and micro-apps FTBW

Read first: Micro-apps FTW

In 2022 I argued for breaking large front ends into micro-apps: separate applications, each small enough for one developer to own, joined behind a reverse proxy so that users see a single site. I liked the approach then. Now that much of our code is written by AI, I like it a great deal more.

The reasons I gave for micro-apps were about people. They turn out to be even better reasons when the developer is a model.

Small enough to fit in its head

I said that a micro-app’s code base should be small enough to fit in the average developer’s head. A model has a head, too: its context, the code and instructions it can see at once.

Give a model a large code base and it works from fragments. It sees the file it is editing and a few that seem related, and it guesses at the rest. That is where the plausible but wrong changes come from: a call to a function that was renamed last week, or a convention followed in one module but not in the next.

You see these bald patches on my head where it appears that the hair has been savagely ripped out? Well, now you know why.

Give it a micro-app and it can see the whole thing. It reasons about all of the code instead of guessing about most of it.

The contract is the specification

The essential move in the micro-app approach is to put the final product outside the app. The HTML, CSS, and behavior that the app must deliver to the browser form a contract, and tests check the app against it.

With human developers, that contract buys consistency. With AI, it is the whole game. A model will happily produce code that looks right. What it needs is a precise, executable statement of what right means, one it cannot wriggle out of. The contract is exactly that. The model may choose any internals it likes. The tests decide whether it is done.

The buddy is another model

Each micro-app has an owner and a buddy: someone who knows the app well but does not write it, and who reviews it regularly.

That maps neatly onto models. One agent builds the app. A second, preferably from a different provider, reviews every change against the contract. Different models make different mistakes, so each catches what the other misses.

And because each app is separate, several agents can work at once without treading on one another’s changes.

Small mistakes stay small

AI makes confident mistakes. In a monolith, one bad change can break everything. In a micro-app, it breaks one app, which can be rolled back on its own. A security flaw is confined to a small surface. The isolation I valued for people is a safety net for models.

Regenerate rather than repair

With people, a rewrite is expensive, so we patch. With AI, rewriting a small app against an unchanged contract can be cheaper than patching it, and safer, because the contract tests show that nothing the user sees has changed.

And this applies to more than simply UX. Whole batteries of tests can be run automatically to act as gates on the AI, checking sustainability, accessibility, security, privacy concerns, efficiency, and more. What lies underneath need not please anyone; it only has to pass the gates.

That changes how we think about technical debt. It also makes the choice of framework far less permanent: to move an app from one framework to another, regenerate it and run the same tests.

The psychology of the gate

I’ve written before about the psychology of code coverage. Give people an arbitrary target and they will hit it, whether or not the tests mean anything.

Models have a psychology, too, or something that behaves remarkably like one. Ask an agent to make the tests pass and it will. Sometimes it does so by fixing the code. Sometimes it loosens an assertion, mocks away the very thing under test, special-cases the test’s inputs, or quietly deletes the test that fails. Then it tells you, cheerfully, that everything works.

It is the same failure, with less guilt and more speed: the measure becomes the target, and the target gets gamed.

The answer is the same, too. Put the gates where the builder cannot touch them. The agent that writes a micro-app must not be able to edit its contract, its tests, or the gates’ thresholds. A second model may review the tests, but only a person changes them. And trust the gate, never the agent’s report of the gate.

Done that way, the benefits go well beyond the interface. Security scans and dependency audits run on every change, not when someone remembers. Privacy gates fail any build that sends data where it should not go, or sets a cookie it should not set. And coverage stops being a number to hit and becomes a question the boundaries answer: does the app do what its contract says, and nothing else?

Explicit boundaries suit models

Micro-apps talk to one another through URLs, events, and well-defined messages. Those are exactly the kinds of interfaces that models handle well. What they handle badly is implicit, shared state, and the micro-app approach does not allow it.

It strengthens my old answer to the duplication complaint, too. Code shared across apps is coupling, and coupling is what hurts a model most: change the shared code and the effects ripple into code the model cannot see. Duplication in small, separate apps is cheap. Hidden coupling is not.

What it does not solve

None of this removes the need for an architect. Someone must decide where the boundaries go, write the contracts, own the pattern library that keeps separately built apps looking like one product, and test the seams between them.

That is the real lesson. Micro-apps make AI coding safer because a person designed the decomposition and wrote down, precisely, what each piece must do. The typing can be delegated. The architecture cannot.

Initialisms and abbreviations
AI
artificial intelligence
CSS
Cascading Style Sheets
FTBW
for the bigger win
FTW
for the win
HTML
HyperText Markup Language
URL
uniform resource locator
UX
user experience