RubyClean.Microservice.Template 1.0.1

dotnet new install RubyClean.Microservice.Template::1.0.1
                    
This package contains a .NET Template Package you can call from the shell/command line.

Clean Architecture Microservice Template

A modern .NET template for building microservices following Clean Architecture principles.

Installation

There are two ways to install this template:

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:

  1. Pack the template:
dotnet pack -c Release
  1. 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:

  1. Domain Layer: Core business logic and entities
  2. Application Layer: Application use cases using CQRS
  3. Infrastructure Layer: External concerns implementation
  4. API Layer: REST endpoints and configuration

Authentication

The API uses JWT Bearer authentication. To access protected endpoints:

  1. Obtain a JWT token
  2. Include it in the Authorization header:
Authorization: Bearer <your-token>

Protected endpoints are marked with the [Authorize] attribute.

Getting Started

  1. Install the template
  2. Create a new project
  3. Navigate to the project directory
  4. Run dotnet restore
  5. Update the connection string in appsettings.json
  6. 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.

Version Downloads Last Updated
1.0.1 130 2/16/2025
1.0.0 119 2/16/2025