RubyClean.Microservice.Template
1.0.1
dotnet new install RubyClean.Microservice.Template::1.0.1
Clean Architecture Microservice Template
A modern .NET template for building microservices following Clean Architecture principles.
Installation
There are two ways to install this template:
1. Install from NuGet (Recommended)
dotnet new install RubyClean.Microservice.Template
2. Install from Source
Clone this repository and run:
dotnet new install /Users/YourPath/MicroServiceArchitecture
Usage
Create a new microservice using:
dotnet new cleanruby -n YourMicroserviceName
Options:
-n|--name
: The name of your microservice (required)
Publishing to NuGet
If you want to share this template with others via NuGet:
- Pack the template:
dotnet pack -c Release
- Push to NuGet:
dotnet nuget push bin/Release/RubyClean.Microservice.Template.1.0.0.nupkg --api-key YOUR-API-KEY --source https://api.nuget.org/v3/index.json
Template Features
- Clean Architecture with 4 layers (API, Application, Domain, Infrastructure)
- CQRS pattern implementation
- Docker and Kubernetes configuration
- Minimal API endpoints
- Entity Framework Core setup
- Health checks
- Logging middleware
- Exception handling
- Architectural Decision Records (ADR)
Project Structure
MyMicroservice.sln
├── src/
├── MyMicroservice.Api/ # API Layer - Endpoints and Configuration
├── MyMicroservice.Application/ # Application Layer - Commands and Queries
├── MyMicroservice.Domain/ # Domain Layer - Entities and Business Logic
├── MyMicroservice.Infrastructure/ # Infrastructure Layer - External Concerns
└── MyMicroservice.Common/ # Shared Utilities and Helpers
Architecture Overview
The solution follows Clean Architecture principles with four main layers:
- Domain Layer: Core business logic and entities
- Application Layer: Application use cases using CQRS
- Infrastructure Layer: External concerns implementation
- API Layer: REST endpoints and configuration
Authentication
The API uses JWT Bearer authentication. To access protected endpoints:
- Obtain a JWT token
- Include it in the Authorization header:
Authorization: Bearer <your-token>
Protected endpoints are marked with the [Authorize] attribute.
Getting Started
- Install the template
- Create a new project
- Navigate to the project directory
- Run
dotnet restore
- Update the connection string in
appsettings.json
- Run
dotnet run --project src/YourMicroserviceName.Api
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
-
net8.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.