ProductionReady.Microservice.Template
1.0.1
dotnet new install ProductionReady.Microservice.Template::1.0.1
Production-Ready .NET 8 Microservice Template
A comprehensive, production-ready .NET 8 microservice template that follows Clean Architecture principles and implements CQRS pattern with enterprise-grade features.
๐ Quick Start
Install the Template
# Install from NuGet (once published)
dotnet new install ProductionReady.Microservice.Template
# Or install from local package
dotnet new install ProductionReady.Microservice.Template.1.0.0.nupkg
Create a New Microservice
# Basic usage
dotnet new microservice -n UserManagement -CompanyName Acme
# With custom options
dotnet new microservice -n OrderProcessing -CompanyName Acme -Port 5100 -HttpsPort 5101 --EnableDocker true --EnableKubernetes true
Available Parameters
Parameter | Type | Default | Description |
---|---|---|---|
CompanyName |
string | "Company" | Your company or organization name |
ServiceName |
string | "ServiceName" | The name of your microservice |
Port |
integer | 5000 | HTTP port for the service |
HttpsPort |
integer | 5001 | HTTPS port for the service |
IncludeDatabase |
bool | true | Include Entity Framework and database configuration |
DatabaseProvider |
choice | SqlServer | Database provider (SqlServer/PostgreSQL) |
EnableDocker |
bool | true | Include Docker support |
EnableKubernetes |
bool | true | Include Kubernetes manifests |
EnableGitHubActions |
bool | true | Include GitHub Actions CI/CD pipeline |
๐๏ธ Architecture
The template follows Clean Architecture with these layers:
โโโ src/
โ โโโ {Company}.{ServiceName}.Domain/ # Domain entities and business rules
โ โโโ {Company}.{ServiceName}.Application/ # Business logic and CQRS handlers
โ โโโ {Company}.{ServiceName}.Infrastructure/ # Data access and external services
โ โโโ {Company}.{ServiceName}.Api/ # REST API controllers and configuration
โโโ tests/
โ โโโ {Company}.{ServiceName}.Application.Tests/ # Unit tests
โ โโโ {Company}.{ServiceName}.Api.Tests/ # Integration tests
โโโ docker/ # Docker configuration
โโโ k8s/ # Kubernetes manifests
โโโ .github/workflows/ # CI/CD pipeline
โจ Features Included
๐๏ธ Architecture & Patterns
- Clean Architecture with proper dependency inversion
- CQRS pattern with MediatR
- Domain-Driven Design principles
- Repository pattern with Entity Framework Core
- Decorator pattern for cross-cutting concerns
๐ง Technical Features
- .NET 8 with latest features
- Entity Framework Core 8 for data access
- MediatR for CQRS implementation
- FluentValidation for input validation
- AutoMapper for object mapping
- Serilog for structured logging
๐ก๏ธ Security & Reliability
- Global exception handling middleware
- Request/Response logging middleware
- Security headers configuration
- CORS configuration
- Health checks with multiple endpoints
- Input validation with custom error responses
๐ณ DevOps & Deployment
- Docker support with multi-stage builds
- Docker Compose for local development
- Kubernetes manifests for production deployment
- GitHub Actions CI/CD pipeline
- Health checks for container orchestration
๐งช Testing
- Unit tests with xUnit
- Integration tests with TestHost
- Test utilities and fixtures
- Code coverage configuration
๐ Getting Started with Generated Project
After creating your microservice:
1. Build and Run Locally
cd YourServiceName
dotnet build
dotnet run --project src/YourCompany.YourServiceName.Api
2. Run with Docker
docker build -t yourservice .
docker run -p 5000:5000 yourservice
3. Run with Docker Compose
docker-compose up
4. Deploy to Kubernetes
kubectl apply -f k8s/
๐ API Endpoints
The generated microservice includes:
GET /health
- Health check endpointGET /health/ready
- Readiness probeGET /health/live
- Liveness probeGET /swagger
- API documentationGET /api/weatherforecast
- Sample endpoint
๐ง Configuration
appsettings.json
{
"Serilog": {
"MinimumLevel": "Information"
},
"AllowedHosts": "*",
"Cors": {
"AllowedOrigins": ["http://localhost:3000"]
}
}
Environment Variables
Variable | Description | Default |
---|---|---|
ASPNETCORE_ENVIRONMENT |
Environment (Development/Staging/Production) | Development |
ASPNETCORE_URLS |
URLs to listen on | http://+:5000 |
ConnectionStrings__DefaultConnection |
Database connection string | - |
๐งช Testing
# Run all tests
dotnet test
# Run with coverage
dotnet test --collect:"XPlat Code Coverage"
# Run specific test project
dotnet test tests/YourCompany.YourServiceName.Application.Tests
๐ Documentation
The generated project includes:
- README.md - Project overview and setup instructions
- API documentation - Swagger/OpenAPI specs
- Architecture decision records - In the
docs/
folder - Deployment guides - Docker and Kubernetes instructions
๐ค Contributing
- Fork the template repository
- Create a feature branch
- Make your changes
- Test the template generation
- Submit a pull request
๐ License
This template is licensed under the MIT License. See the LICENSE file for details.
๐ท๏ธ Template Management
Uninstall Template
dotnet new uninstall ProductionReady.Microservice.Template
List Installed Templates
dotnet new list
Template Help
dotnet new microservice --help
Happy coding! ๐
Create robust, scalable microservices with this production-ready template that follows industry best practices and includes everything you need to get started quickly.
This package has 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.0.1 | 471 | 7/21/2025 |
v1.0.1 - Production-Ready Microservice Template
🚀 Features:
โข Clean Architecture with Domain, Application, Infrastructure, and API layers
โข CQRS pattern implementation with MediatR
โข Structured logging with Serilog and multiple enrichers
โข Global exception handling and request logging middleware
โข FluentValidation for robust input validation
โข Health checks with readiness/liveness probes
โข Docker support with optimized multi-stage builds
โข Kubernetes deployment manifests for production
โข GitHub Actions CI/CD pipeline with testing and security scans
โข Security headers and CORS configuration
โข Comprehensive unit and integration tests
โข AutoMapper for object mapping
โข Entity Framework Core with repository pattern
โข Caching strategies with decorators
โข Complete documentation and setup guides
🛡๏ธ Security:
โข No vulnerable packages (all dependencies verified)
โข Security best practices implemented
โข HTTPS enforcement and security headers
📦 Template Options:
โข Configurable company and service names
โข Optional Docker and Kubernetes support
โข Database provider selection (SQL Server/PostgreSQL)
โข GitHub Actions CI/CD pipeline inclusion
โข Customizable ports and configuration