# Modular Monolith Architecture — Orbit .NET 11 Field Guide & Agentic Software Factory

> Orbit is an open-source .NET 11 modular monolith baseline and agentic software factory engineered by Milan Jovanović. Five isolated bounded contexts (Users, Catalog, Inventory, Orders, Shipments) run inside one ASP.NET Core deployment and one PostgreSQL 18 database with strict schema-per-module ownership, a System.Threading.Channels topic-routed pub/sub bus, and end-to-end OpenTelemetry.

Canonical: https://modularmonolith.com/
Source Repository: https://github.com/m-jovanovic/modular-monolith (pinned at `v2.0.0` / `3c8d0cf5`)

## Bounded Context & PostgreSQL 18 Schema Map

| Module | Schema | Owns | Published Seams | Subscribed Topics |
| --- | --- | --- | --- | --- |
| Users | `users` | Accounts, OIDC/LocalJwt auth, JIT provisioning, RBAC `IPermissionService` | `Users.IntegrationEvents` | — |
| Catalog | `catalog` | Categories, SKUs, pricing, product lifecycle (`Draft` -> `Active` -> `Discontinued`) | `Catalog.IntegrationEvents`, `ICatalogPublicApi` | — |
| Inventory | `inventory` | Warehouse stock, `SELECT ... FOR UPDATE` + `xmin` reservations, stock movements | `Inventory.IntegrationEvents` | `product-published`, `product-discontinued`, `order-placed`, `order-cancelled`, `shipment-dispatched` |
| Orders | `orders` | Customer projection, purchase orders, stock confirmation & `StockRejected` compensation | `Orders.IntegrationEvents` | `user-registered`, `user-profile-updated`, `order-stock-reserved`, `order-stock-rejected`, `shipment-dispatched`, `shipment-delivered` |
| Shipments | `shipments` | Warehouse fulfillment (`Pending` -> `Picking` -> `Packed` -> `Dispatched` -> `Delivered`) | `Shipments.IntegrationEvents` | `order-stock-reserved`, `order-cancelled` |

## Key Architectural Pillars

1. **Strict Module & Schema Isolation**: Zero tables in `public`. EF Core writes with `UseSnakeCaseNamingConvention()` and `xmin` concurrency tokens; Dapper reads strictly against the owning schema. Enforced by 49 automated architecture & SQL tests.
2. **Topic-Routed `System.Threading.Channels` Service Bus (`Orbit.Common.EventBus`)**: O(1) `FrozenDictionary` topic routing into dedicated bounded queues per subscriber, paired with PostgreSQL Outbox (`OutboxWakeupSignal` sub-10ms wakeup) and idempotent Inbox (`inbox_message_consumers`).
3. **OpenTelemetry Runtime Eyes for Humans & AI Agents**: W3C `trace_parent` stored in `outbox_messages` links HTTP commands, background Outbox relays, EventBus producer/consumer spans, and Inbox handlers inside a local Aspire Dashboard (`http://localhost:18888`).
4. **Agentic Software Factory**: `AGENTS.md` plus 8 composable skills in `.agents/skills/` let AI coding agents adapt Orbit to new domains, scaffold modules, add vertical slices, and self-verify against 59 automated gates.

## Explore Further

- [Interactive Architecture Tour](https://modularmonolith.com/tour/)
- [60-Second Quickstart](https://modularmonolith.com/start/)
- [Engineering Guides & Runnable Labs](https://modularmonolith.com/guides/)
- [Software Factory & Custom Domain Setup Service](https://modularmonolith.com/software-factory/)
- [Module Extraction Case Study](https://modularmonolith.com/case-studies/module-extraction/)
- [Modular Monolith Architecture Course](https://milanjovanovic.tech/modular-monolith-architecture)
