Three Modules, One Process
DevMentors' ModularMonolith sample packs three conference-system modules, a mini-framework and one deliberately broken contract into eighty-four C# files - opening a series that reads all of it, defects included.
In reading order.
DevMentors' ModularMonolith sample packs three conference-system modules, a mini-framework and one deliberately broken contract into eighty-four C# files - opening a series that reads all of it, defects included.
ModularMonolith makes every controller internal and teaches MVC to find them anyway - compile-time module isolation from one feature provider, an InternalsVisibleTo chain, and the one place the wall has a hole.
Every module in ModularMonolith plugs in through the same Add/Use extension pair - a recipe small enough to memorise, complete enough to be a mini-framework, and visible even where a module registers nothing at all.
The last commit of ModularMonolith moves one line of Startup from first to last - and the whole cross-module event system depends on it. Assembly scanning, throwaway service providers and migrations inside ConfigureServices.
ModularMonolith builds its message broker from System.Threading.Channels and one BackgroundService - a textbook Message Channel and Event-Driven Consumer in miniature, with every missing enterprise-integration pattern visible by its absence.
ModularMonolith routes events between modules by class name and converts them by JSON round-trip - a one-line Message Translator that lets modules share contracts without sharing types, at a price the next part collects.
The last commit of ModularMonolith renames Name to ConferenceName in the subscriber's copy of its one integration event - and the JSON translator has delivered null into that field ever since. Anatomy of a silent contract break.
A single boolean in appsettings decides whether ModularMonolith's events run inside your HTTP request or on a background pump - and each setting fails differently. Delivery semantics, read honestly from a ternary.
One Postgres database, one schema per module, and entity configurations that are all empty bodies - what ModularMonolith's data layer declares about future service boundaries, and what its migrations quietly gave away.
Conferences registers in-memory and EF repositories for the same interfaces and lets last-registration-wins pick - a live lesson in DI as strategy selector, dead registrations as fossils, and a no-op UpdateAsync nobody deleted.
One middleware turns ConferenceNotFoundException into the wire code conference_not_found via Humanizer - a naming convention promoted to API contract, with a 400-versus-404 tension and Error-level logs it never resolved.
ModularMonolith's entities are public-setter data bags, its one immutability rule is a fixup with a comment, and its hardest domain question is asked in a comment and answered by nothing - a reading of domain modelling by annotation.
Conferences and Speakers disagree on layout, naming, id policy, exception visibility, mapping style and route constraints - plus a 200 that returns nothing and a broker that threw NotImplementedException for four months. The honest ledger.
Which of ModularMonolith's three modules could become a service tomorrow, what blocks the other two, and the hardening bill the sample never pays - a retrospective on the modular monolith as a station, not a destination.