MicroserviceKit 0.2.0
See the version list below for details.
dotnet tool install --global MicroserviceKit --version 0.2.0
dotnet new tool-manifest
dotnet tool install --local MicroserviceKit --version 0.2.0
#tool dotnet:?package=MicroserviceKit&version=0.2.0
nuke :add-package MicroserviceKit --version 0.2.0
๐ MicroserviceKit - .NET 8 Microservice Template Generator
A powerful, configurable template generator for .NET 8 microservices with a modular "Lego blocks" approach. Generate production-ready microservices with Clean Architecture, DDD patterns, CQRS, containerization, and comprehensive testing.
โจ Features
๐๏ธ Architecture Levels
- MINIMAL: Single project for simple CRUD services (1-2 developers)
- STANDARD: 3-layer architecture for medium complexity (2-5 developers)
- ENTERPRISE: 4-layer architecture for complex services (5+ developers)
- AUTO: Intelligent selection based on your requirements
๐งฉ Modular Components
- Domain Layer: Aggregates, Entities, Value Objects, Domain Events
- Application Layer: Commands, Queries, Handlers, DTOs, Validation
- API Layer: REST Controllers with OpenAPI, Validation, Error Handling
- Infrastructure Layer: Repositories, DbContext, External Services
- Testing: Unit Tests, Integration Tests, Test Utilities
๐ณ Containerization
- Docker: Intelligent Dockerfile generation for microservice and infrastructure
- Docker Compose: Orchestration with PostgreSQL, MongoDB, RabbitMQ
- Kubernetes: Production-ready manifests with HPA, Services, ConfigMaps
๐ง Technologies
- .NET 8 with latest C# features
- Wolverine for CQRS/Mediator (MIT license)
- AggregateKit for DDD base classes
- Entity Framework Core for persistence
- FluentValidation for input validation
- xUnit, FluentAssertions, Moq for testing
๐ Quick Start
Installation
# Install globally from NuGet
dotnet tool install --global MicroserviceKit --prerelease
# Or install specific version
dotnet tool install --global MicroserviceKit --version 0.1.0-beta
Generate Your First Microservice
# Interactive mode - guided setup
microkit new OrderService --interactive
# Quick start with defaults
microkit new OrderService
# From configuration file
microkit new OrderService --config examples/enterprise-service.json
# Custom output directory
microkit new OrderService --output ./my-services/
# Show help
microkit --help
Alternative: Build from Source
# Clone the repository
git clone https://github.com/suranig/MicroserviceKit.git
cd MicroserviceKit
# Build and run locally
dotnet build
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- new OrderService
๐ Configuration
Basic Configuration
{
"ServiceName": "OrderService",
"RootNamespace": "Company.OrderService",
"Architecture": {
"Level": "standard"
},
"Features": {
"Api": {
"Style": "controllers",
"Documentation": true,
"Versioning": true
},
"Persistence": {
"WriteModel": "postgresql",
"ReadModel": "mongodb"
},
"Messaging": {
"Enabled": true,
"Provider": "rabbitmq"
}
},
"Domain": {
"Aggregates": [
{
"Name": "Order",
"Properties": [
{ "Name": "CustomerId", "Type": "Guid" },
{ "Name": "TotalAmount", "Type": "decimal" },
{ "Name": "Status", "Type": "OrderStatus" }
],
"Operations": ["Create", "UpdateStatus", "Cancel"]
}
]
}
}
Architecture Levels
Level | Projects | Use Case | Team Size |
---|---|---|---|
MINIMAL | 1 project | Simple CRUD, prototypes | 1-2 devs |
STANDARD | 3 projects | Business logic, medium complexity | 2-5 devs |
ENTERPRISE | 4+ projects | Complex domains, high scalability | 5+ devs |
AUTO | Intelligent | Analyzes your config and decides | Any |
๐๏ธ Generated Structure
Standard Level
OrderService/
โโโ src/
โ โโโ OrderService.Domain/ # Aggregates, Entities, Events
โ โโโ OrderService.Application/ # Commands, Queries, Handlers
โ โโโ OrderService.Api/ # Controllers, DTOs, Middleware
โโโ tests/
โ โโโ OrderService.UnitTests/ # Domain & Application tests
โ โโโ OrderService.IntegrationTests/ # API & Database tests
โโโ docker/
โ โโโ microservice.Dockerfile # Main application
โ โโโ postgres.Dockerfile # Write model
โ โโโ mongodb.Dockerfile # Read model
โ โโโ docker-compose.yml # Full orchestration
โโโ k8s/
โโโ deployment.yaml # Kubernetes deployment
โโโ service.yaml # Load balancer
โโโ hpa.yaml # Auto-scaling
Enterprise Level
OrderService/
โโโ src/
โ โโโ OrderService.Domain/ # Rich domain model
โ โโโ OrderService.Application/ # Use cases & DTOs
โ โโโ OrderService.Infrastructure/ # Persistence & External services
โ โโโ OrderService.Api/ # REST/gRPC endpoints
โโโ tests/
โ โโโ OrderService.UnitTests/ # Fast, isolated tests
โ โโโ OrderService.IntegrationTests/ # Database & API tests
โ โโโ OrderService.ArchitectureTests/ # Architecture compliance
โโโ deployment/ # Full DevOps setup
๐งช Testing Strategy
Generated Test Types
Unit Tests
- Domain logic and business rules
- Command/Query handlers
- Value object validation
- Domain event handling
Integration Tests
- API endpoints with real database
- Repository implementations
- Message publishing/consuming
- External service integration
Architecture Tests
- Layer dependency rules
- Naming conventions
- Code quality metrics
Test Example
[Fact]
public async Task CreateOrder_WithValidData_ShouldReturnOrderId()
{
// Arrange
var command = new CreateOrderCommand(
CustomerId: Guid.NewGuid(),
Items: [new OrderItem("Product", 2, 10.00m)]
);
// Act
var result = await _handler.Handle(command, CancellationToken.None);
// Assert
result.Should().NotBeEmpty();
_mockRepository.Verify(x => x.AddAsync(
It.IsAny<Order>(),
It.IsAny<CancellationToken>()),
Times.Once);
}
๐ณ Docker & Kubernetes
Docker Compose (Development)
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f orderservice
# Scale microservice
docker-compose up -d --scale orderservice=3
Kubernetes (Production)
# Deploy to Kubernetes
kubectl apply -f k8s/
# Check status
kubectl get pods -l app=orderservice
# Scale horizontally
kubectl scale deployment orderservice-deployment --replicas=5
# View auto-scaling
kubectl get hpa
๐ Migration & Evolution
Migrate Existing Projects
# Analyze current project
microkit migrate --analyze
# Preview migration to standard level
microkit migrate --level standard --dry-run
# Execute migration
microkit migrate --level standard
# View migration history
microkit history
Smart Auto-Configuration
The generator automatically enables features based on complexity:
- DDD: Enabled when complexity >= medium
- CQRS: Enabled when multiple operations per aggregate
- Infrastructure Layer: Enabled when external dependencies detected
- Docker: Enabled for standard+ levels
- Kubernetes: Enabled for enterprise level
๐ Examples
Simple CRUD Service
microkit new ProductCatalog --config examples/minimal-crud.json
Event-Driven Microservice
microkit new OrderService --config examples/event-driven.json
Enterprise Service
microkit new PaymentService --config examples/enterprise-service.json
๐ ๏ธ Development
Prerequisites
- .NET 8 SDK
- Docker & Docker Compose
- Kubernetes (optional)
Build & Test
# Build solution
make build
# Run unit tests
make test
# Run CLI tests
make cli-test
# Run full CLI test suite
make cli-test-full
# Clean CLI test directories
make cli-clean
# Development workflow (build + test)
make dev
# Run CLI locally (if building from source)
dotnet run --project src/CLI/CLI.csproj -- --help
# Or use installed version
microkit --help
CLI Testing
The project includes a dedicated testing infrastructure for CLI commands:
# Quick CLI test (standard microservice)
./test_cli/quick-test.sh
# Full test suite (all architecture levels)
./test_cli/full-test.sh
# Clean test directories
./test_cli/clean.sh
# Test specific architecture level
make test-basic # Minimal level
make test-standard # Standard level
make test-enterprise # Enterprise level
# Interactive CLI testing
make cli-interactive
Test Directory Structure:
test_cli/
โโโ basic/ # Basic microservice tests
โโโ standard/ # Standard architecture tests
โโโ enterprise/ # Enterprise configuration tests
โโโ messaging/ # Messaging module tests (future)
โโโ *.sh # Test automation scripts
All CLI tests are automatically excluded from version control and run in isolated directories.
Contributing
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Open Pull Request
๐ Documentation
- Development Plan - Detailed roadmap and implementation status
- Usage Guide - Comprehensive usage examples
- Examples - Configuration examples for different scenarios
- Migration Guide - How to migrate existing projects
๐ฏ Roadmap
โ Completed (Phase 1-2)
- Domain Layer generation with AggregateKit
- REST API Controllers with full CRUD
- Comprehensive Unit Testing
- CLI with interactive mode
- Smart architecture level selection
๐ง In Progress (Phase 3)
- Application Layer (Commands/Queries/Handlers)
- Infrastructure Layer (Repositories/DbContext)
- Integration Testing
- Docker & Kubernetes support
๐ฎ Planned (Phase 4+)
- gRPC API support
- Event Sourcing patterns
- Advanced CQRS with separate read/write models
- Observability (Logging, Metrics, Tracing)
- Performance optimization
๐ฆ NuGet Package
MicroserviceKit is available on NuGet.org:
- Package: MicroserviceKit
- Current Version: 0.1.0-beta
- Command:
microkit
- Installation:
dotnet tool install --global MicroserviceKit --prerelease
Package Statistics
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with โค๏ธ for .NET developers who want to build better microservices faster.
Product | Versions 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. |
This package has no dependencies.
🎉 Major Release 0.2.0 - Enterprise-Ready Microservices!
โ
NEW ENTERPRISE FEATURES:
- 📨 Event-Driven Architecture with RabbitMQ messaging
- 📊 CQRS with MongoDB read models and PostgreSQL write models
- 🌐 External Services integration with Polly resilience patterns
- 🐳 Complete Docker & Kubernetes deployment infrastructure
- 🧪 Comprehensive Integration Testing with TestContainers
- 🔒 Production-ready security, monitoring, and health checks
- 📈 Built-in metrics, logging, and observability
โ
COMPLETE INFRASTRUCTURE:
- REST APIs with proper /api/rest/{aggregate} structure
- Domain events with automatic read model synchronization
- Service registry with circuit breaker, retry, timeout patterns
- Docker Compose with full development stack
- Kubernetes manifests with HPA, monitoring, security
- Integration tests for APIs, databases, and messaging
🚀 PRODUCTION READY: Generate enterprise-grade microservices with complete infrastructure, testing, and deployment capabilities!