Muonroi.Modular.Template
1.0.0-alpha.1
See the version list below for details.
dotnet new install Muonroi.Modular.Template::1.0.0-alpha.1
Muonroi.Modular.Template
A .NET solution template for building Modular Monolith applications using ASP.NET Core with the Muonroi.BuildingBlock library. Perfect for enterprise systems with medium complexity that need module separation while keeping deployment simple.
Quick Start
# 1. Install template
dotnet new install Muonroi.Modular.Template
# 2. Create new project
dotnet new mr-mod-sln -n MyModularApp
# 3. Setup
cd MyModularApp/MyModularApp
dotnet restore
# 4. Run migrations
cd src/Host/MyModularApp.Host
dotnet ef migrations add InitialCreate --project ../../Shared/MyModularApp.Kernel
dotnet ef database update --project ../../Shared/MyModularApp.Kernel
# 5. Run
dotnet run
Open: https://localhost:5001/swagger
Prerequisites
- .NET 9.0 SDK or later
- (Optional) EF Core CLI:
dotnet tool install --global dotnet-ef
Installation
From NuGet (recommended)
dotnet new install Muonroi.Modular.Template
From source
git clone <your-private-url>/Muonroi.Modular.Template.git
cd Muonroi.Modular.Template
dotnet new install ./
Verify installation
dotnet new list | grep "mr-mod-sln"
Usage
Create new project
dotnet new mr-mod-sln -n <ProjectName> [--ui <angular|react|mvc|none>]
| Parameter | Short | Description | Default |
|---|---|---|---|
--name |
-n |
Solution/project name | (required) |
--UiFramework |
--ui |
Frontend shell scaffold (angular, react, mvc, none) |
none |
Generated UI shells use Muonroi hybrid UI engine:
- Backend metadata endpoints:
GET /api/v1/auth/ui-engine/{userId},GET /api/v1/auth/ui-engine/current - FE runtime packages:
@muonroi/ui-engine-core,@muonroi/ui-engine-angular,@muonroi/ui-engine-react - MVC runtime package:
Muonroi.Ui.Engine.Mvc - Optional UI-kit adapter package:
@muonroi/ui-engine-primeng
Template boundary:
Muonroi.Modular.Templatekeeps scaffold/wiring fordotnet new.- Shared UI runtime core is maintained in
Muonroi.Ui.Engine. - Runtime verification should be executed on freshly generated projects under
_tmp/verify-runs, not by treating template source as production app.
Sync helper:
./scripts/sync-ui-engine.sh --ui-engine-path ../Muonroi.Ui.Engine --openapi http://localhost:5000/swagger/v1/swagger.json --framework all
Examples
# Create modular monolith for e-commerce
dotnet new mr-mod-sln -n ECommerce
# Creates modules: Identity, Catalog with shared Kernel
# Create modular monolith with React shell starter
dotnet new mr-mod-sln -n ECommerce --ui react
Project Structure
MyModularApp/
├── MyModularApp.sln
├── src/
│ ├── Host/ # Application Entry Point
│ │ └── MyModularApp.Host/ # Web API Host
│ │ ├── appsettings.json
│ │ ├── appsettings.Development.json
│ │ ├── appsettings.Production.json
│ │ ├── Program.cs # Bootstrapper
│ │ └── Infrastructures/ # DI Configuration
│ ├── Modules/ # Independent Business Modules
│ │ ├── Identity/ # User/Auth module
│ │ │ ├── Controllers/
│ │ │ ├── Models/
│ │ │ ├── Services/
│ │ │ └── IdentityModule.cs # Module registration
│ │ └── Catalog/ # Product catalog module
│ │ ├── Controllers/
│ │ ├── Models/
│ │ ├── Services/
│ │ └── CatalogModule.cs # Module registration
│ └── Shared/ # Shared Infrastructure
│ ├── MyModularApp.Kernel/ # Data layer, DbContext
│ │ ├── Persistence/
│ │ │ ├── MyModularAppDbContext.cs
│ │ │ └── Migrations/
│ │ └── Repositories/
│ └── MyModularApp.Shared/ # Shared contracts
│ ├── Events/ # Domain events
│ └── Dtos/ # Shared DTOs
└── README.md
Configuration
Supported Database Types
| DbType | Connection String Key |
|---|---|
Sqlite |
SqliteConnectionString |
SqlServer |
SqlServerConnectionString |
MySql |
MySqlConnectionString |
PostgreSql |
PostgreSqlConnectionString |
MongoDb |
MongoDbConnectionString |
Example Configuration
{
"DatabaseConfigs": {
"DbType": "Sqlite",
"ConnectionStrings": {
"SqliteConnectionString": "Data Source=modular_app.db"
}
},
"TokenConfigs": {
"Issuer": "https://localhost:5001",
"Audience": "https://localhost:5001",
"SymmetricSecretKey": "your-secret-key-minimum-32-characters!",
"UseRsa": false,
"ExpiryMinutes": 60
},
"EnableEncryption": false
}
Feature Flags
Toggle optional features to reduce startup time:
{
"FeatureFlags": {
"UseGrpc": false,
"UseServiceDiscovery": false,
"UseMessageBus": false,
"UseBackgroundJobs": false,
"UseEnsureCreatedFallback": true
}
}
Enterprise Operations (E4/E5)
Enable management endpoints only when needed:
{
"EnterpriseOps": {
"EnableComplianceEndpoints": false,
"EnableOperationsEndpoints": false
}
}
When enabled:
EnableComplianceEndpoints: mapsMapMComplianceEndpoints()EnableOperationsEndpoints: mapsMapMEnterpriseOperationsEndpoints()
Ops scripts included in scripts/:
check-enterprise-upgrade-compat.ps1check-enterprise-slo-gates.ps1
SLO presets included in deploy/enterprise/slo-presets/:
balanced.jsonstrict.jsonregulated.json
Note: if your Muonroi.BuildingBlock package version does not include E4/E5 endpoint extensions yet, these toggles are ignored safely.
Database Migrations
Since modules share a single database (via Kernel), migrations are centralized:
# Add migration
dotnet ef migrations add "AddNewFeature" \
-p ./src/Shared/MyModularApp.Kernel \
--startup-project ./src/Host/MyModularApp.Host \
-o Persistence/Migrations
# Update database
dotnet ef database update \
-p ./src/Shared/MyModularApp.Kernel \
--startup-project ./src/Host/MyModularApp.Host
Modular Monolith Architecture
Why Modular Monolith?
- Simpler than Microservices - Single deployment, no distributed complexity
- Better than Monolith - Clear module boundaries, independent development
- Migration Path - Easy to extract modules into microservices later
Module Communication
Modules communicate via:
- Domain Events - In-process async communication
- Integration Events - Cross-module events via MediatR
- Shared Contracts - DTOs in
Sharedproject (use sparingly) - Direct References - Avoid when possible
Adding New Module
Create module folder under
src/Modules/:src/Modules/ └── Orders/ # New module ├── Controllers/ ├── Models/ ├── Services/ └── OrdersModule.cs # Module registrationAdd module project reference to Host
Register module services in
Program.cs:builder.Services.AddOrdersModule();Add module entities to Kernel DbContext (optional)
Features
- Modular Monolith - Independent modules, single deployment
- CQRS with MediatR - Command/Query separation per module
- Authentication & Authorization - JWT, permissions, roles
- Entity Framework Core - Shared Kernel database
- Structured Logging - Serilog with service-specific log files
- Caching - Memory, Redis, or Multi-level
- Multi-tenancy - Data isolation by tenant
- Inter-Module Events - Loose coupling via domain events
- Service Discovery - Consul integration
- Message Bus - Kafka/RabbitMQ via MassTransit
- Background Jobs - Hangfire/Quartz integration
Rule Engine
This template ships with ready-to-use rule samples and hooks.
Quick Start
Examples in this template
src/Host/Muonroi.Modular.Host/Rules/B2B/B2BRegistrationRules.cssrc/Host/Muonroi.Modular.Host/Rules/ContainerValidationRule.cssrc/Host/Muonroi.Modular.Host/Rules/ContainerExistenceRule.cssrc/Host/Muonroi.Modular.Host/Rules/LoggingHook.cs
Centralized docs
Module Guidelines
✅ DO:
- Keep modules independent and loosely coupled
- Use events for inter-module communication
- Share only necessary contracts (DTOs/interfaces)
- Follow Domain-Driven Design within modules
- Use separate folders for module concerns
❌ DON'T:
- Create direct module-to-module dependencies
- Share domain entities across modules
- Put business logic in Shared projects
- Mix module responsibilities
Documentation
Private docs are centralized in Muonroi.Docs:
- License Capability Model
- Control Plane MVP
- Enterprise Secure Profile (E2)
- Enterprise Centralized Authorization (E3)
- Enterprise Compliance (E4)
- Enterprise Operations (E5)
Troubleshooting
"Connection string is not provided"
Ensure DbType matches the connection string key:
{
"DatabaseConfigs": {
"DbType": "MySql", // Must match key below
"ConnectionStrings": {
"MySqlConnectionString": "..." // ✓ Correct key
}
}
}
"The input is not a valid Base-64 string"
Set "EnableEncryption": false in appsettings.
Migration errors
Always specify both -p (Kernel) and --startup-project (Host):
dotnet ef migrations add Init \
-p ./src/Shared/MyModularApp.Kernel \
--startup-project ./src/Host/MyModularApp.Host
API slow on startup
Disable unused features in FeatureFlags.
Module not loading
Check Program.cs for module registration:
builder.Services.AddIdentityModule();
builder.Services.AddCatalogModule();
Edition Notes
- Template package is MIT.
- Generated projects run in Free mode by default (
LicenseConfigs:LicenseFilePath = null). - If you enable premium modules (multi-tenant strict mode, RBAC+, rule-engine workflows, gRPC, message bus, distributed cache, audit trail), provide a paid Muonroi license with matching feature keys.
License
MIT License. See LICENSE.txt for details.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.9.3 | 111 | 2/8/2026 |
| 1.9.2 | 113 | 2/8/2026 |
| 1.8.1 | 121 | 1/25/2026 |
| 1.8.0 | 120 | 1/25/2026 |
| 1.7.6 | 121 | 1/24/2026 |
| 1.7.5 | 118 | 1/24/2026 |
| 1.7.4 | 123 | 1/24/2026 |
| 1.7.3 | 123 | 1/24/2026 |
| 1.0.0-alpha.2 | 34 | 3/8/2026 |
| 1.0.0-alpha.1 | 32 | 3/8/2026 |