PouryaKit
Templates

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

Terminal
dotnet new pouryakit-modular-monolith -n Acme.Shop

Migrate 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.ModularityWhat each composition composes
Ledger's Marten store joining the Host's message storeStreams
A cross-Module effect in the smoke test: a product Catalog creates opens its stock item in InventoryThe smoke test

Failure messages

Next steps

On this page