MicroserviceKit 0.4.5

dotnet tool install --global MicroserviceKit --version 0.4.5
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local MicroserviceKit --version 0.4.5
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=MicroserviceKit&version=0.4.5
                    
nuke :add-package MicroserviceKit --version 0.4.5
                    

๐Ÿš€ MicroserviceKit - .NET 8 Microservice Template Generator

NuGet Version NuGet Downloads .NET License: MIT GitHub

๐Ÿš€ Complete toolkit for generating production-ready .NET 8 microservices with DDD, CQRS, Clean Architecture, Event-Driven Architecture, and comprehensive infrastructure.

โœจ Features

  • ๐Ÿ—๏ธ Clean Architecture - Domain, Application, Infrastructure, API layers
  • ๐Ÿ“ฆ Domain-Driven Design - Aggregates, Entities, Value Objects, Domain Events
  • โšก CQRS Pattern - Command Query Responsibility Segregation with MassTransit
  • ๐Ÿ”„ Event-Driven Architecture - RabbitMQ, MassTransit, Domain Events
  • ๐Ÿ—„๏ธ Multi-Database Support - PostgreSQL (write), MongoDB (read), Redis (cache)
  • ๐Ÿ”— External Services Integration - HTTP clients with Polly resilience
  • ๐Ÿงช Comprehensive Testing - Unit, Integration, E2E with TestContainers
  • ๐Ÿณ Docker & Kubernetes - Production-ready containerization with Dockerfile, docker-compose.yml, Makefile
  • ๐Ÿ“Š Monitoring & Health Checks - Built-in observability
  • ๐Ÿ” Security - JWT authentication, OAuth2, RBAC
  • ๐ŸŒ API Gateway - Centralized routing and authentication

๐Ÿš€ Quick Start

Install the CLI tool

dotnet tool install -g MicroserviceKit

Generate your first microservice

# Interactive mode (recommended for beginners)
microkit generate MyService --interactive

# Quick start with enterprise template
microkit generate ArticleService --template cqrs-event-sourcing

# With custom aggregates and external services
microkit generate MyService --template cqrs-event-sourcing --aggregates Article Comment --external-services ImageService VideoService

Explore available templates

# List all templates
microkit list

# List by category
microkit list --category service-types

# Get detailed template information
microkit describe cqrs-event-sourcing.json

๐Ÿ“‹ Available Templates

๐Ÿท๏ธ Enterprise Service Types

Perfect for production microservices with complex business requirements:

  • Use for: Services with complex business rules, audit trail requirements, event-driven architecture
  • Complexity: Enterprise (25 minutes)
  • Features: CQRS, Event Sourcing, Domain Events, Aggregate Root, PostgreSQL
  • Perfect for: Article management, Order processing, Financial transactions
bpc-workflow.json
  • Use for: Business process orchestration, workflow management, external system integration
  • Complexity: Enterprise (30 minutes)
  • Features: Workflow Engine, Saga Pattern, External Integrations, State Machine, Hangfire
  • Perfect for: Payment processing, Document approval workflows, Multi-step business processes
event-store.json
  • Use for: Centralized event storage, event replay, audit logs
  • Complexity: Enterprise (20 minutes)
  • Features: Event Store, Event Sourcing, Projections, Event Replay
  • Perfect for: Event sourcing infrastructure, Audit systems, Event analytics
read-model.json
  • Use for: High-performance read operations, reporting, data projections
  • Complexity: Medium (15 minutes)
  • Features: CQRS Read Side, MongoDB, Projections, Redis Cache, Event Handlers
  • Perfect for: Reporting services, Search APIs, Data analytics
identity-auth.json
  • Use for: User authentication, authorization, multi-tenant security
  • Complexity: Enterprise (25 minutes)
  • Features: OAuth2, JWT, RBAC, Multi-Auth, Identity Server
  • Perfect for: Identity provider, User management, API security
api-gateway.json
  • Use for: Centralized API management, routing, cross-cutting concerns
  • Complexity: Enterprise (20 minutes)
  • Features: API Gateway, Routing, Rate Limiting, Circuit Breaker, Ocelot
  • Perfect for: Microservices entry point, API aggregation, Security gateway
multi-tenant.json
  • Use for: SaaS applications, tenant isolation, configuration per tenant
  • Complexity: Enterprise (20 minutes)
  • Features: Multi-tenancy, Tenant Isolation, Configuration per Tenant, Domain Routing
  • Perfect for: SaaS platforms, Multi-client systems, Tenant-specific features
legacy-adapter.json
  • Use for: Integration with legacy systems, data synchronization
  • Complexity: Medium (15 minutes)
  • Features: Adapter Pattern, Legacy Integration, Data Sync, Anti-corruption Layer
  • Perfect for: Legacy system integration, Data migration, System modernization
search-indexing.json
  • Use for: Full-text search, content indexing, search analytics
  • Complexity: Medium (15 minutes)
  • Features: Elasticsearch, Search Indexing, Event-driven, Full-text Search
  • Perfect for: Content search, Product catalogs, Document search
cqrs-simple.json
  • Use for: CQRS without Event Sourcing, simpler business logic
  • Complexity: Medium (15 minutes)
  • Features: CQRS, Clean Architecture, PostgreSQL, Redis Cache
  • Perfect for: CRUD-heavy services, Simple business logic, Standard applications

๐Ÿ—๏ธ Architecture Levels

Choose based on your project complexity:

standard-service.json ๐Ÿ“Š Balanced
  • Use for: Standard business applications, moderate complexity
  • Complexity: Medium (10 minutes)
  • Features: Clean Architecture, CQRS, SQLite, JWT Auth
  • Perfect for: Business applications, Standard APIs, Moderate complexity
  • Use for: Enterprise applications, all patterns included
  • Complexity: Complex (20 minutes)
  • Features: DDD, CQRS, Event Sourcing, Microservices Patterns, Docker, Kubernetes
  • Perfect for: Large enterprises, Complex domains, Full-scale microservices

๐Ÿ—๏ธ Generated Architecture

Every generated service includes:

MyService/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ Domain/                 # Domain layer (DDD)
โ”‚   โ”‚   โ”œโ”€โ”€ Aggregates/         # Aggregate roots with business logic
โ”‚   โ”‚   โ”œโ”€โ”€ Entities/           # Domain entities
โ”‚   โ”‚   โ”œโ”€โ”€ ValueObjects/       # Immutable value objects
โ”‚   โ”‚   โ”œโ”€โ”€ Events/             # Domain events
โ”‚   โ”‚   โ””โ”€โ”€ Repositories/       # Repository interfaces
โ”‚   โ”œโ”€โ”€ Application/            # Application layer (CQRS)
โ”‚   โ”‚   โ”œโ”€โ”€ Commands/           # Command handlers (write operations)
โ”‚   โ”‚   โ”œโ”€โ”€ Queries/            # Query handlers (read operations)
โ”‚   โ”‚   โ”œโ”€โ”€ DTOs/               # Data transfer objects
โ”‚   โ”‚   โ””โ”€โ”€ Behaviors/          # Cross-cutting concerns
โ”‚   โ”œโ”€โ”€ Infrastructure/         # Infrastructure layer
โ”‚   โ”‚   โ”œโ”€โ”€ Persistence/        # EF Core, MongoDB, Redis
โ”‚   โ”‚   โ”œโ”€โ”€ ExternalServices/   # HTTP clients with Polly
โ”‚   โ”‚   โ”œโ”€โ”€ Messaging/          # MassTransit + RabbitMQ
โ”‚   โ”‚   โ””โ”€โ”€ Configuration/      # Dependency injection
โ”‚   โ””โ”€โ”€ Api/                    # API layer
โ”‚       โ”œโ”€โ”€ Controllers/        # REST API controllers
โ”‚       โ”œโ”€โ”€ Middleware/         # Custom middleware
โ”‚       โ””โ”€โ”€ Extensions/         # Service registration
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ Unit/                   # Unit tests with xUnit
โ”‚   โ”œโ”€โ”€ Integration/            # Integration tests with TestContainers
โ”‚   โ””โ”€โ”€ EndToEnd/               # E2E tests
โ”œโ”€โ”€ Dockerfile                  # Multi-stage Docker build
โ”œโ”€โ”€ docker-compose.yml          # Complete development environment
โ”œโ”€โ”€ Makefile                    # Development commands
โ”œโ”€โ”€ k8s/                        # Kubernetes manifests
โ””โ”€โ”€ docs/                       # Auto-generated documentation

๐Ÿ› ๏ธ CLI Commands

๐Ÿš€ Generate Commands

# Interactive mode (recommended)
microkit generate MyService --interactive

# Quick generation with template
microkit generate ArticleService --template cqrs-event-sourcing

# Custom aggregates
microkit generate MyService --template cqrs-event-sourcing --aggregates Article Comment User

# External services integration
microkit generate MyService --template cqrs-event-sourcing --external-services ImageService VideoService NotificationService

# Full customization
microkit generate MyService --template cqrs-event-sourcing \
  --aggregates Article Comment \
  --external-services ImageService VideoService \
  --database postgresql \
  --output ./services/ArticleService

๐Ÿ“‹ Discovery Commands

# List all templates
microkit list

# List by category
microkit list --category service-types
microkit list --category levels

# Filter by complexity
microkit list --complexity enterprise
microkit list --complexity medium

# Detailed view with descriptions
microkit list --detailed

# Get specific template information
microkit describe cqrs-event-sourcing.json
microkit describe api-gateway.json --format json

๐Ÿ”ง Template Customization

Example: Article Service Configuration

{
  "templateType": "cqrs-event-sourcing",
  "microserviceName": "ArticleService",
  "namespace": "Company.ArticleService",
  "domain": {
    "aggregates": [
      {
        "name": "Article",
        "properties": [
          { "name": "Title", "type": "string", "isRequired": true },
          { "name": "Content", "type": "string", "isRequired": true },
          { "name": "Status", "type": "ArticleStatus", "isRequired": true }
        ],
        "operations": ["Create", "Update", "Publish", "Archive"]
      }
    ]
  },
  "features": {
    "database": {
      "writeModel": { "provider": "postgresql" },
      "readModel": { "provider": "mongodb" }
    },
    "messaging": { "enabled": true, "provider": "rabbitmq" },
    "externalServices": {
      "enabled": true,
      "services": [
        {
          "name": "ImageService",
          "baseUrl": "https://api.images.com",
          "operations": ["Upload", "Process", "Delete"]
        }
      ]
    }
  },
  "deployment": {
    "docker": { "enabled": true },
    "kubernetes": { "enabled": true }
  }
}

๐Ÿงช Testing & Development

Generated Development Environment

Every service includes a complete development setup:

# Start development environment
make dev-setup

# Run the service
make run

# Run tests
make test

# Build Docker image
make docker-build

# Run with Docker
make docker-run

# Clean up
make clean

Testing with TestContainers

# Unit tests
dotnet test tests/Unit/

# Integration tests with real databases
dotnet test tests/Integration/

# End-to-end tests
dotnet test tests/EndToEnd/

# All tests
make test

๐Ÿณ Docker & Kubernetes

Complete Containerization

Every generated service includes:

  • Multi-stage Dockerfile - Optimized for production
  • docker-compose.yml - Complete development environment with PostgreSQL, MongoDB, Redis, RabbitMQ
  • Kubernetes manifests - Production-ready K8s deployment
  • Health checks - Liveness and readiness probes
  • Makefile - All development commands
# Development with Docker Compose
docker-compose up -d

# Build production image
docker build -t myservice:latest .

# Deploy to Kubernetes
kubectl apply -f k8s/

๐Ÿ“Š Monitoring & Observability

Built-in Monitoring

  • Health Checks - /health, /health/ready, /health/live
  • Metrics - ASP.NET Core built-in metrics
  • Structured Logging - Serilog with correlation IDs
  • Distributed Tracing - OpenTelemetry ready
# Health endpoints
curl http://localhost:5000/health
curl http://localhost:5000/health/ready
curl http://localhost:5000/health/live

# Metrics endpoint
curl http://localhost:5000/metrics

๐Ÿ” Security

Authentication & Authorization

# JWT for internal services
curl -H "Authorization: Bearer <jwt-token>" \
     http://localhost:5000/api/articles

# OAuth2 for external applications
curl -H "Authorization: Bearer <oauth-token>" \
     http://localhost:5000/api/articles

๐ŸŒŸ Real-World Examples

Headless CMS Architecture

# Article management service
microkit generate ArticleService --template cqrs-event-sourcing --aggregates Article ArticleBlock

# Page management service
microkit generate PageService --template cqrs-event-sourcing --aggregates Page PageLayout

# Content read service
microkit generate ContentReadService --template read-model --aggregates ArticleProjection PageProjection

# Search service
microkit generate SearchService --template search-indexing

# Identity service
microkit generate IdentityService --template identity-auth --aggregates User Role Permission

# API Gateway
microkit generate ApiGateway --template api-gateway

E-commerce Platform

# Order management
microkit generate OrderService --template cqrs-event-sourcing --aggregates Order OrderItem

# Product catalog
microkit generate ProductService --template cqrs-simple --aggregates Product Category

# Inventory management
microkit generate InventoryService --template cqrs-event-sourcing --aggregates Inventory

# Payment processing
microkit generate PaymentService --template bpc-workflow --aggregates Payment PaymentMethod

# Search service
microkit generate SearchService --template search-indexing

๐Ÿ“š Documentation

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ†˜ Support


Built with โค๏ธ for the .NET community

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
0.4.5 67 6/20/2025
0.4.4 89 6/20/2025
0.4.2 101 6/20/2025
0.4.1 128 6/20/2025
0.4.0 127 6/20/2025
0.3.0 287 6/10/2025
0.2.0 209 6/9/2025
0.1.0-beta 184 6/8/2025

🚀 v0.4.5 - Templates Included: Fixed missing templates in NuGet package. All microservice templates are now properly included and accessible via CLI commands (list, describe, generate).