Modulytics.Blueprints
1.0.11
dotnet new install Modulytics.Blueprints::1.0.11
📦 Modulytics Blueprints
DDD • Modular • Clean Architecture • CRUD Templates for .NET 9
Modulytics Blueprints нь .NET 9 дээр DDD + Modular Monolith архитектур ашиглан хурдан хөгжүүлэлт хийхэд зориулагдсан dotnet new template-үүдийн багц юм.
Эдгээр template-үүдийг ашигласнаар та шинэ модуль, aggregate, CRUD endpoint, domain layer, integration events болон бүрэн module scaffolding-ийг секундүүдийн дотор үүсгэж чадна.
🚀 Install
NuGet дээрээс нэг командоор суулгана:
dotnet new install Modulytics.Blueprints
Хэрвээ өмнөх хувилбар суусан бол:
dotnet new uninstall Modulytics.Blueprints
dotnet new install Modulytics.Blueprints
📂 Included Templates
Доорх template-үүд dotnet new list дээр харагдана:
| Template | Short Name | Description |
|---|---|---|
| Module Template | ml-module |
Шинэ DDD модуль scaffold үүсгэнэ: Application, Domain, Endpoints, Infrastructure, Persistence, IntegrationEvents зэрэг үндсэн хавтасууд |
| Feature Template | ml-feature |
Нэг aggregate root бүхий feature-ийг бүрэн scaffold хийнэ: Entity + DomainEvents + Repository + CQRS (Commands/Queries) + IntegrationEvents + Endpoints |
| Lookup Template | ml-lookup |
Нэг lookup бүхий feature-ийг бүрэн scaffold хийнэ: Entity + Repository + Consume (IntegrationEventHandler) |
Жич: Template бүр .template.config-ийн symbol-уудаар entity/module нэрийг автоматаар солигдуулна.
🛠 Usage
1️⃣ Module үүсгэх
dotnet new ml-module -n Payments \
--schema payments \
--route payments \
--SwaggerGroup payments \
--SwaggerDescription "Төлбөрийн модуль"
Дээрх команд нь Payments нэртэй бүрэн DDD модуль scaffold үүсгэнэ.
Үүсэх structure:
/src/Modules/Payments
├── Modules.Payments.Application
│ ├── AssemblyReference.cs
│ └── Modules.Payments.Application.csproj
│
├── Modules.Payments.Domain
│ ├── IUnitOfWork.cs
│ └── Modules.Payments.Domain.csproj
│
├── Modules.Payments.Endpoints
│ ├── AssemblyReference.cs
│ ├── PaymentsPermissions.cs
│ └── Modules.Payments.Endpoints.csproj
│
├── Modules.Payments.Infrastructure
│ ├── BackgroundJobs
│ │ ├── ProcessInboxMessages
│ │ │ ├── IntegrationEventHandlerFactory.cs
│ │ │ ├── ProcessInboxMessagesConfiguration.cs
│ │ │ ├── ProcessInboxMessagesJob.cs
│ │ │ └── ProcessInboxMessagesOptions.cs
│ │ └── ProcessOutboxMessages
│ │ ├── ProcessOutboxMessagesConfiguration.cs
│ │ ├── ProcessOutboxMessagesJob.cs
│ │ └── ProcessOutboxMessagesOptions.cs
│ │
│ ├── Consumers
│ │ └── ConsumerConfiguration.cs
│ │
│ ├── Idempotence
│ │ ├── IdempotentDomainEventHandler.cs
│ │ ├── IdempotentIntegrationEventHandler.cs
│ │ └── IntegrationEventConsumer.cs
│ │
│ ├── ServiceInstallers
│ │ ├── ApplicationServiceInstaller.cs
│ │ ├── BackgroundJobsServiceInstaller.cs
│ │ ├── EndpointsServiceInstaller.cs
│ │ ├── PersistenceServiceInstaller.cs
│ │ ├── ProcessInboxMessagesOptionsSetup.cs
│ │ └── ProcessOutboxMessagesOptionsSetup.cs
│ │
│ ├── AssemblyReference.cs
│ ├── PaymentsModuleInstaller.cs
│ └── Modules.Payments.Infrastructure.csproj
│
├── Modules.Payments.IntegrationEvents
│ └── Modules.Payments.IntegrationEvents.csproj
│
└── Modules.Payments.Persistence
├── Configurations
│ ├── InboxMessageConfiguration.cs
│ ├── InboxMessageConsumerConfiguration.cs
│ ├── OutboxMessageConfiguration.cs
│ └── OutboxMessageConsumerConfiguration.cs
│
├── Constants
│ ├── Schemas.cs
│ └── TableNames.cs
│
├── AssemblyReference.cs
├── PaymentsDbContext.cs
├── UnitOfWork.cs
└── Modules.Payments.Persistence.csproj
2️⃣ Feature нэмэх
dotnet new ml-feature -n Currency \
--Module MasterData \
--entity currency \
--Entities Currencies \
--entities currencies \
--schema master_data \
--table currencies \
--EntityMN "Валют" \
--EntityMNiin "Валютын" \
--EntityMNiig "Валютыг" \
--entityMN "валют" \
--entityMNiin "валютын" \
--entityMNiig "валютыг" \
--WithLookup \
--WithDetails \
--WithReference \
--RelatedEntity Division \
--relatedEntity division \
--related_entity division \
--related_table divisions
Үүсэх файлууд:
/src/Modules/MasterData
├── Modules.MasterData.Application
│ ├── Currencies
│ │ ├── CreateCurrency
│ │ │ ├── CreateCurrencyCommand.cs
│ │ │ ├── CreateCurrencyCommandHandler.cs
│ │ │ ├── CreateCurrencyCommandValidator.cs
│ │ │ └── CurrencyCreatedDomainEventHandler.cs
│ │ │
│ │ ├── DeleteCurrency
│ │ │ ├── DeleteCurrencyCommand.cs
│ │ │ ├── DeleteCurrencyCommandHandler.cs
│ │ │ └── DeleteCurrencyCommandValidator.cs
│ │ │
│ │ ├── GetCurrencyById
│ │ │ ├── GetCurrencyByIdQuery.cs
│ │ │ ├── GetCurrencyByIdQueryHandler.cs
│ │ │ └── CurrencyResponse.cs
│ │ │
│ │ ├── GetCurrencies
│ │ │ ├── GetCurrenciesQuery.cs
│ │ │ ├── GetCurrenciesQueryHandler.cs
│ │ │ └── CurrencyResponse.cs
│ │ │
│ │ ├── RestoreCurrency
│ │ │ ├── RestoreCurrencyCommand.cs
│ │ │ ├── RestoreCurrencyCommandHandler.cs
│ │ │ └── RestoreCurrencyCommandValidator.cs
│ │ │
│ │ └── UpdateCurrency
│ │ ├── UpdateCurrencyCommand.cs
│ │ ├── UpdateCurrencyCommandHandler.cs
│ │ ├── UpdateCurrencyCommandValidator.cs
│ │ └── CurrencyChangedDomainEventHandler.cs
│ │
│ ├── ValidationErrors
│ │ ├── CurrencyValidationErrors.cs
│ │ └── (other validation errors…)
│ │
│ └── (other application features…)
│
├── Modules.MasterData.Domain
│ ├── Currencies
│ │ ├── Events
│ │ │ ├── CurrencyCreatedDomainEvent.cs
│ │ │ └── CurrencyUpdatedDomainEvent.cs
│ │ │
│ │ ├── Currency.cs
│ │ ├── CurrencyId.cs
│ │ ├── CurrencyErrors.cs
│ │ └── ICurrencyRepository.cs
│ │
│ └── (other domain features…)
│
├── Modules.MasterData.Endpoints
│ ├── Contracts
│ │ ├── Currencies
│ │ │ ├── CreateCurrencyRequest.cs
│ │ │ ├── GetCurrenciesRequest.cs
│ │ │ ├── UpdateCurrencyRequest.cs
│ │ │ └── UpdateCurrencyRequestContent.cs
│ │ │
│ │ └── (other contract features…)
│ │
│ ├── Currencies
│ │ ├── CreateCurrencyEndpoint.cs
│ │ ├── DeleteCurrencyEndpoint.cs
│ │ ├── GetCurrencyByIdEndpoint.cs
│ │ ├── GetCurrenciesEndpoint.cs
│ │ ├── RestoreCurrencyEndpoint.cs
│ │ └── UpdateCurrencyEndpoint.cs
│ │
│ ├── Routes
│ │ ├── CurrenciesRoutes.cs
│ │ └── (other routes…)
│ │
│ └── (other endpoint features…)
│
├── Modules.MasterData.IntegrationEvents
│ ├── Currencies
│ │ ├── CurrencyCreatedIntegrationEvent.cs
│ │ └── CurrencyChangedIntegrationEvent.cs
│ │
│ └── (other integration event features…)
│
└── Modules.MasterData.Persistence
├── Configurations
│ ├── CurrencyConfiguration.cs
│ └── (other configurations…)
│
└── Repositories
├── CurrencyRepository.cs
└── (other repositories…)
3️⃣ Lookup нэмэх
dotnet new ml-lookup -n Currency \
--Module Inventory \
--SourceModule MasterData \
--entity currency \
--Entities Currencies \
--entities currencies \
--entityMN "валют"
Үүсэх файлууд:
/src/Modules/Inventory
├── Modules.Inventory.Application
│ ├── Lookups
│ │ ├── Currencies
│ │ │ ├── CurrencyCreatedIntegrationEventHandler.cs
│ │ │ └── CurrencyChangedIntegrationEventHandler.cs
│ │ │
│ │ └── (other lookup features…)
│ │
│ └── (other application features…)
│
├── Modules.Inventory.Domain
│ ├── Lookups
│ │ ├── Currencies
│ │ │ ├── Currency.cs
│ │ │ ├── CurrencyId.cs
│ │ │ ├── CurrencyErrors.cs
│ │ │ └── ICurrencyRepository.cs
│ │ │
│ │ └── (other lookup features…)
│ │
│ └── (other domain features…)
│
└── Modules.Inventory.Persistence
├── Configurations
│ ├── Lookups
│ │ ├── CurrencyConfiguration.cs
│ │ └── (other lookup configurations…)
│ │
│ └── (other configurations…)
│
└── Repositories
├── Lookups
│ ├── CurrencyRepository.cs
│ └── (other lookup repositories…)
│
└── (other repositories…)
🔧 Parameters
Template бүр дараах parameters-ыг дэмждэг:
| Parameter | Description | Example |
|---|---|---|
--Module |
Module name (PascalCase) | MasterData |
--route |
Module route (lowercase + kebab-case) | master-data |
--SwaggerGroup |
Swagger Group (lowercase) | masterdata |
--SwaggerDescription |
Swagger Description | Мастер дата модуль |
--Entity |
Entity name (PascalCase) | Currency |
--entity |
Entity name (camelCase) | currency |
--Entities |
Plural (PascalCase) | Currencies |
--entities |
Plural (camelCase) | currencies |
--schema |
Schema (snake_case) | master_data |
--table |
Table (snake_case) | currencies |
--EntityMN |
Монгол нэр (эхний үсэг томоор) | Валют |
--EntityMNiin |
Монгол нэр (эхний үсэг томоор, *-ын/ийн/ны/ний) | Валютын |
--EntityMNiig |
Монгол нэр (эхний үсэг томоор, *-ыг/ийг/г) | Валютыг |
--entityMN |
Монгол нэр (жижигээр) | валют |
--entityMNiin |
Монгол нэр (жижигээр, *-ын/ийн/ны/ний) | валютын |
--entityMNiig |
Монгол нэр (жижигээр, *-ыг/ийг/г) | валютыг |
--WithLookup |
Lookup select-тэй эсэх | true |
--WithDetails |
Detail-тэй эсэх (Master-Detail) | true |
--WithReference |
Reference-тэй эсэх (FK relationship) | true |
--RelatedEntity |
Related Entity (PascalCase) | Division |
--Relatedentity |
Related Entity (camelCase) | division |
--related_entity |
Related Entity (snake_case) | division |
--related_table |
Related Table (snake_case) | divisions |
Жишээ:
dotnet new ml-module -n MasterData \
--schema master_data \
--route master-data \
--SwaggerGroup masterdata \
--SwaggerDescription "Мастер дата модуль"
dotnet new ml-feature -n ProductCategory \
--Module MasterData \
--entity productCategory \
--Entities ProductCategories \
--entities productCategories \
--schema master_data \
--table product_categories \
--EntityMN "Бараа, бүтээгдэхүүний ангилал" \
--EntityMNiin "Бараа, бүтээгдэхүүний ангиллын" \
--EntityMNiig "Бараа, бүтээгдэхүүний ангиллыг" \
--entityMN "бараа, бүтээгдэхүүний ангилал" \
--entityMNiin "бараа, бүтээгдэхүүний ангиллын" \
--entityMNiig "бараа, бүтээгдэхүүний ангиллыг" \
--WithLookup
dotnet new ml-lookup -n Currency \
--Module Inventory \
--SourceModule MasterData \
--entity currency \
--Entities Currencies \
--entities currencies \
--entityMN "валют"
🧱 Folder Structure (Template Pack)
blueprints/
│
├── templates/
│ ├── feature/
│ │ ├── .template.config/template.json
│ │ └── src/Modules/__Module__/...
│ └── module/
│ ├── .template.config/template.json
│ └── src/Modules/__Module__/...
│
└── Blueprints.csproj
Blueprints.csproj нь template-үүдийг compile хийхгүй, зөвхөн content/ folder руу багцалдаг.
🔄 Update Template Pack
Version өсгөнө:
<Version>1.0.1</Version>
Package дахин үүсгэнэ:
dotnet pack -c Release -o ./nupkgs
NuGet руу push:
dotnet nuget push ./nupkgs/Modulytics.Blueprints.1.0.1.nupkg \
--source https://api.nuget.org/v3/index.json
--api-key YOUR_KEY \
--skip-duplicate
-
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.