MicroserviceKit 0.1.0-beta
See the version list below for details.
dotnet tool install --global MicroserviceKit --version 0.1.0-beta
dotnet new tool-manifest
dotnet tool install --local MicroserviceKit --version 0.1.0-beta
#tool dotnet:?package=MicroserviceKit&version=0.1.0-beta&prerelease
nuke :add-package MicroserviceKit --version 0.1.0-beta
๐ .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
# Clone the repository
git clone https://github.com/your-repo/microservice-net8-ddd.git
cd microservice-net8-ddd
# Build the CLI tool
dotnet build src/CLI/MicroserviceGenerator.CLI/MicroserviceGenerator.CLI.csproj
# Install globally (optional)
dotnet pack src/CLI/MicroserviceGenerator.CLI/MicroserviceGenerator.CLI.csproj
dotnet tool install -g MicroserviceGenerator.CLI
Generate Your First Microservice
# Interactive mode - guided setup
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- new OrderService --interactive
# Quick start with defaults
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- new OrderService
# From configuration file
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- new OrderService --config examples/enterprise-service.json
# Custom output directory
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- new OrderService --output ./my-services/
๐ 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
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- migrate --analyze
# Preview migration to standard level
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- migrate --level standard --dry-run
# Execute migration
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- migrate --level standard
# View migration history
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- 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
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- new ProductCatalog --config examples/minimal-crud.json
Event-Driven Microservice
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- new OrderService --config examples/event-driven.json
Enterprise Service
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- new PaymentService --config examples/enterprise-service.json
๐ ๏ธ Development
Prerequisites
- .NET 8 SDK
- Docker & Docker Compose
- Kubernetes (optional)
Build & Test
# Build solution
dotnet build
# Run tests
dotnet test
# Run CLI locally
dotnet run --project src/CLI/MicroserviceGenerator.CLI -- --help
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
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ค Support
- ๐ง Email: support@microservice-generator.com
- ๐ฌ Discussions: GitHub Discussions
- ๐ Issues: GitHub Issues
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.
🎉 BETA Release 0.1.0
โ
Core functionality working:
- Domain Layer generation with AggregateKit
- REST API Controllers with full CRUD
- Comprehensive Unit Testing
- CLI with interactive mode
- Smart architecture selection
🚧 In Development:
- Application Layer (Commands/Queries/Handlers)
- Infrastructure Layer (Repositories/DbContext)
- Docker & Kubernetes support
- Integration Tests
โ ๏ธ This is a BETA version. Core features work but some modules are still in development.