Short answer: For most new and mid-sized AI-built apps, a monolith or modular monolith works better, because an agent can see the caller and the callee in one repository and change both together. Microservices still win when parts must scale or deploy on their own, or when separate teams own them, provided contracts are typed and the whole system runs locally.

You asked an agent to add a discount field to quotes. It did, neatly, in the quote service. The invoice service didn't hear about it. Nobody noticed until a customer got the wrong total.
This old architecture debate has a new reader: the agent. Agents read code through a context window, open one repository at a time in many tools, and trust whatever API docs they're given. That changes which structure is safer, and it doesn't always favor the answer architects gave a decade ago.
In this guide, you'll learn:
- Definitions
- Side by side for AI agents
- When to choose a monolith
- When to choose microservices
- Where an AI software factory fits
The sections build on each other, so read them in order.
Definitions
Monolith. One codebase, built and deployed as one unit. All modules share a process and usually a database. Martin Fowler's "Monolith First" (June 3, 2015) argues you should "build a new application as a monolith initially," partly because "any refactoring of functionality between services is much harder than it is in a monolith" (martinfowler.com).
Modular monolith. Still one deployable unit, but split into modules with enforced boundaries. Encore's 2026 guide suggests checking those boundaries in CI, for example with Python's import-linter (Encore, Oct 23, 2026).
Microservices. Many small services, each deployed on its own and talking over the network. Fowler's "Microservice Premium" warns, "don't even consider microservices unless you have a system that's too complex to manage as a monolith," because the approach "brings a high premium" (martinfowler.com).
The counterpoint. Stefan Tilkov replied that same month on Fowler's site: "starting with a monolith is usually exactly the wrong thing to do," because "the parts will become extremely tightly coupled to each other" (martinfowler.com, Jun 9, 2015). He also says microservices make most sense when you know the domain well.
The context window. The amount of text an agent can hold at once. Encore's guide cites Anthropic describing context as "a finite resource with diminishing returns" and Chroma's 2025 report that models get less reliable as input grows (Encore).
Side by side for AI agents
| What the agent needs | Monolith | Modular monolith | Microservices in one repo | Microservices across repos |
|---|---|---|---|---|
| See caller and callee together | Yes | Yes | Yes | No; only API docs |
| Change both sides in one PR | Yes | Yes | Yes | No; coordinated PRs per repo |
| Catch a broken contract early | Compile or type check | Compile check plus CI boundary rules | Only if calls are typed | Often only in staging |
| Run the whole system locally | One process | One process | Needs a Compose file or similar | Usually a shared staging setup |
| Keep context small and focused | Gets harder as it grows | Modules help the agent find code | Small units, if the agent finds them | Small units, but blind to neighbors |
| Scale or deploy parts on their own | No | No | Yes | Yes |
| Separate team ownership | Weak | Moderate | Strong | Strongest |
Rows on contracts, local runs and coordinated PRs follow Encore's guide, written by a vendor that sells a platform for typed services in one repository.
Tool limits add to this. GitHub's Copilot cloud agent, for instance, can change only the one repository named at the start of an Actions-based session and opens one pull request per task (GitHub Docs). A change that spans three service repositories becomes three separate tasks, and nothing in that agent checks that they still agree.
What the early evidence says. A small open-source benchmark, ModulithBench, built four business domains twice, once as a modular monolith and once as microservices. One agent scored an average of 97.7 on the monolith versions and 70.7 on the microservice versions, with about 40% fewer tool calls on the monolith (DEV Community). Treat it as a signal, not proof: it tested one agent, the author built both architectures and argues for the monolith, and part of the scoring is self-reported.
What the cost evidence says. In a 2023 post, Prime Video's Video Quality Analysis team moved stream monitoring from distributed Step Functions and Lambda components into a single process on EC2 and ECS and cut infrastructure cost by 90%. The engineer's own caveat: the choice "has to be made on a case-by-case basis" (The New Stack, May 4, 2023).
When to choose a monolith
- The app is new. You don't yet know where the real boundaries are. Fowler's advice is to find them in one codebase first, where moving code is cheap.
- Agents do most of the writing. One repository lets an agent read every caller, change both sides of a call and run the whole app in one session.
- One team owns the product. A B2B quote tool, a permit tracker or a clinic booking app rarely needs separate deploys per feature.
- You want tests that cover whole journeys. A single process is easier to start locally and click through end to end.
- Cost matters more than scale. One process on one server avoids the network, orchestration and observability tooling services need.
Pick the modular version when several people or agents work in parallel. Clear module boundaries keep an agent's edits contained, and CI rules stop quiet cross-module imports.
When to choose microservices
- Parts have very different load. A video encoder and a settings page shouldn't scale together.
- Parts must deploy on their own. Regulated payments code with its own release process is a common case.
- Separate teams own separate domains and need independent repositories, permissions and release calendars.
- You already know the domain well. Tilkov's case for starting split depends on knowing the boundaries upfront.
- You can keep contracts typed and the system runnable locally. Encore's guide says services in one repository work for agents only under those two conditions.
If you go this way with agents, keep services in one repository where you can, generate clients from typed contracts, and make one command start everything locally.
Where an AI software factory fits
The architecture debate is really a debate about visibility: can whoever makes a change see everything it touches? Coding agents automate the developer. Devfab automates the development lifecycle, and visibility is built into how its agents work.
- Research before the plan. Devfab's Researcher maps the domain first: key terms, best practices for that kind of app and competitors. Then it suggests a prototype. That is where boundaries should be discussed, before any code.
- A plan a person approves. The Planner publishes the plan, and nothing gets ticketed until someone approves it. If you want a modular structure, that is where you say so.
- ChainFlow. Devfab's code-intelligence layer maps which functions and APIs call each other and what is deployed, so dev agents see the impact of a change and don't break connected features. In a shop app, changing checkout can affect payments, inventory, order confirmation and notifications. Whether ChainFlow spans several separate repositories is not stated.
- QA across journeys. The QA agent runs UI and flow tests (screens, buttons and user journeys clicked end to end) plus logic tests, which is where a broken quote-to-invoice handoff shows up.
- Your code, your server. Code lives in your own GitHub account, and Deploy ships to your own server.
By default Devfab picks a stack that fits the app, such as Next.js with TypeScript for a web app or Node or Python for an API, and you can choose languages yourself. Devfab is in Beta, with a smaller community and fewer integrations than mature platforms, and it needs a GitHub account.
FAQ
Do AI coding agents work better in a monolith?
Usually, for new and mid-sized apps. In one repository an agent can read the caller and the callee and change both in one pull request. Split across repositories, it sees other services only through API docs that may be out of date. Early benchmarks point the same way, but they are small.
Should a new AI-built app start with microservices?
Rarely. Martin Fowler's 2015 advice still holds: build a new application as a monolith first, because moving functionality between services is much harder than inside one codebase. Split later, once you know where the real boundaries are and a part needs to scale or deploy on its own.
What is a modular monolith?
One deployable app whose code is split into modules with enforced boundaries. Modules talk through defined interfaces, and CI checks block imports that cross the rules. It keeps the single-repository view agents benefit from while giving teams the separation they would otherwise get from services.
How do I stop an agent's change from breaking another service?
Make the impact visible before the change merges. Typed contracts turn a broken call into a compile error. A map of which functions and APIs call each other shows what else a change touches. End-to-end flow tests then confirm the user journeys across those parts still work.
Read next
- What is an AI software factory?
- AI software factory vs AI coding tools
- How to stop AI coding agents from breaking existing code
- Single-agent vs multi-agent coding
Want every change mapped before it ships? Try Beta
Sources (checked November 2026): Martin Fowler: Monolith First (Jun 3, 2015); Martin Fowler: Microservice Premium (May 13, 2015); Stefan Tilkov: Don't start with a monolith (Jun 9, 2015); Encore: Microservices vs monolith for AI coding agents (Oct 23, 2026); DEV Community: Do AI coding agents reason better in monoliths? (ModulithBench); The New Stack: Return of the monolith (May 4, 2023); GitHub Docs: About Copilot cloud agent.
Frequently asked questions
Do AI coding agents work better in a monolith?
Usually, for new and mid-sized apps. In one repository an agent can read the caller and the callee and change both in one pull request. Split across repositories, it sees other services only through API docs that may be out of date. Early benchmarks point the same way, but they are small.
Should a new AI-built app start with microservices?
Rarely. Martin Fowler's 2015 advice still holds: build a new application as a monolith first, because moving functionality between services is much harder than inside one codebase. Split later, once you know where the real boundaries are and a part needs to scale or deploy on its own.
What is a modular monolith?
One deployable app whose code is split into modules with enforced boundaries. Modules talk through defined interfaces, and CI checks block imports that cross the rules. It keeps the single-repository view agents benefit from while giving teams the separation they would otherwise get from services.
How do I stop an agent's change from breaking another service?
Make the impact visible before the change merges. Typed contracts turn a broken call into a compile error. A map of which functions and APIs call each other shows what else a change touches. End-to-end flow tests then confirm the user journeys across those parts still work.



