Skip to content
ENNO
← Back to blog
·3 min read·

Why I Reach for a Modular Monolith First

Why I start client backends as one deployable with hard boundaries inside, using a marketplace I'm building as the example, and the few reasons I'd split it.

Why I Reach for a Modular Monolith First

When someone asks me to "make it microservices", the first thing I ask is who's going to be on call for them. On the projects I take, the honest answer is usually one or two people, and sometimes just me.

A service boundary is a network call, and network calls fail halfway. Once a system is split you've signed up for retries, timeouts, partial failures, tracing to work out what happened, and an order things have to be deployed in. None of it is hard on its own. It's just work you now do on every feature, for good, instead of once.

You lose transactions as well. Two tables in one database update together or not at all, and two services don't. The patterns that cover the gap (outbox tables, sagas, compensating actions) are the parts of a codebase I've seen go wrong at two in the morning.

What I build instead

One deployable and one database, with hard boundaries inside it. The marketplace backend I've been building for a client since June is the clearest example. It's a single ASP.NET Core API on a single Postgres database, and it's had 391 commits so far without anyone suggesting a second deploy.

Diagram of one API container holding eleven feature areas, each with its interface: Listings (IListingService), Sellers, Sales, Messaging, Subscriptions, Identity, Uploads, Feedback, Content, Seo (ISitemapService) and Admin, plus a dashed slot for the next one. All of them use one PostgreSQL database with one migration history. Notes: inside the process it's a method call that can't time out halfway; the likes change was a new table, service and endpoints under Listings only.
Eleven feature areas so far, one process, one database.

The boundaries are folders and namespaces, not HTTP. Each feature area gets a folder in the application layer with an interface in front of it, and its domain types and implementation sit in matching folders further down:

text
src/ Marketplace.Domain/Listings/ ListingLike.cs, Listing.cs ... Marketplace.Application/Features/ Listings/ IListingService.cs IListingLikeService.cs IWatchlistService.cs Sellers/ ISellerService.cs Sales/ ISaleService.cs Messaging/ IMessageService.cs ... Marketplace.Infrastructure/Listings/ ListingService.cs ListingLikeService.cs Marketplace.Api/Controllers/V1/ one controller per area

I'm not a purist about reads. Messaging looks up who owns a listing with a query on the shared context, because in one process that's the simplest thing. Writes are different. Listing rows change through the Listings code and nowhere else, and that's the rule that keeps a later split possible.

The payoff came in the third milestone. Likes had started out as "follow this seller", and the client wanted them per listing instead, counted separately from the watchlist. That turned into one new entity, one interface, one service and one controller, all inside Listings:

csharp
namespace Marketplace.Application.Features.Listings; public interface IListingLikeService { Task AddAsync(Guid userId, Guid listingId, CancellationToken ct = default); Task RemoveAsync(Guid userId, Guid listingId, CancellationToken ct = default); Task<IReadOnlyList<Guid>> GetIdsAsync(Guid userId, CancellationToken ct = default); }

The migration added a table, a line got added to the DI setup, and no other feature area changed. In a split system the same change would have been a new endpoint on one service, a contract change on another, and a deploy order to think about.

When I do split

When one part needs ten machines and the rest needs one. When one component ships every day and everything else ships once a month. When there's a hard compliance line and the data can't live in the same place. Or when a third-party integration is so flaky that I'd rather it failed in its own process.

"It feels cleaner" isn't on that list.

Honest boundaries inside the monolith give you the clean part already, and if they stay honest, splitting later is mostly mechanical. You move a folder out, put a network call where the method call was and deal with the failure modes then, once there's a real reason and hopefully more than one person to run it.

#.NET#architecture#modular monolith#microservices#ASP.NET Core