Modular monolith
pouryakit-modular-monolith, several Modules in one Host, each reached through its Gateway.
What it is
pouryakit-modular-monolith generates one Host of Modules: the Proving Sample's Catalog with Catalog.Contracts, Billing, Inventory, and Ledger, a Stream Module, with Ledger.Contracts. Each Module has a Composition Root of its own, an IModuleDefinition the Host adds with AddPouryaKitModules, and its endpoints send through the Module's Gateway.
Calls between Modules stay in-process
Integration Events and Snapshots go through the Host's Outbox, and a question goes through the owning Module's Contracts. Modules of one Host never call each other over HTTP.
When to use it
When the application has, or soon will have, more than one business boundary, and they deploy together. It also shows each way Modules talk: Catalog publishes what Inventory and Billing receive, Ledger keeps its accounts as a Stream, and Catalog's agent runs on the AI Capability.
Generate and run it
Generate it
dotnet new pouryakit-modular-monolith -n Acme.ShopMigrate each EF Core Module
Run it as Your first Host runs the monolith, and migrate Billing (BillingDbContext) and Inventory (InventoryDbContext) the same way as Catalog. Ledger needs no migration: Marten creates its tables itself.
What it composes
| Stated in | |
|---|---|
The monolith's Capabilities, with Streams, AI and PouryaKit.Modularity | What each composition composes |
| Ledger's Marten store joining the Host's message store | Streams |
| A cross-Module effect in the smoke test: a product Catalog creates opens its stock item in Inventory | The smoke test |