CleanArchSharp 3.0.2

dotnet new install CleanArchSharp@3.0.2
                    
This package contains a .NET Template Package you can call from the shell/command line.

CleanArchSharp

A modern Clean Architecture template for ASP.NET Core Web APIs — production-ready with JWT auth, PostgreSQL, Redis caching, RabbitMQ messaging, and more.

src/
├── MyProject.API            ← HTTP layer (controllers, middleware)
├── MyProject.Application    ← Use cases, CQRS handlers, domain events
├── MyProject.Contracts      ← Shared DTOs, settings, interfaces
├── MyProject.Infrastructure ← External services (Redis, RabbitMQ, Stripe, etc.)
├── MyProject.Persistence    ← EF Core DbContext, migrations, seeders
└── MyProject.Domain         ← Core entities, value objects, domain interfaces

Prerequisites

Tool Minimum Version Download
.NET SDK 10.0 dotnet.microsoft.com
PostgreSQL 15+ postgresql.org
Redis (optional) 6+ redis.io
RabbitMQ (optional) 3.12+ rabbitmq.com

Verify installation:

dotnet --version    # should be 10.0.100 or higher
psql --version      # should be 15+

Getting Started

1. Install the Template

NuGet Downloads License

dotnet new install CleanArchSharp@3.0.2

After installation, verify it’s available:

dotnet new list

You should see entries like:

cleanarchsharp
Clean Architecture Template for WebAPI by Sushil

Create a New API Project

dotnet new cleanarchsharp -n ProjectName

2. Configure the database

Edit src/MyProject.API/appsettings.Development.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "Host=localhost;Port=5432;Database=myproject;Username=postgres;Password=your_password;"
  }
}

Tip: appsettings.*.json files are in .gitignore — they will not be committed.

3. Create the database

cd src/MyProject.API
dotnet ef database update

This applies all migrations and creates the myproject database.

4. Run the API

dotnet run

The API starts at https://localhost:5001 (or the port shown in the console).

Open Swagger UI: https://localhost:5001/swagger


Configuration Reference

appsettings.json — mandatory settings

{
  "JwtSettings": {
    "Secret": "your-32-char-min-secret-key-here!",
    "Issuer": "MyProject",
    "Audience": "MyProject"
  },
  "ConnectionStrings": {
    "DefaultConnection": "Host=localhost;Port=5432;Database=myproject;Username=postgres;Password=your_password;"
  }
}
Setting Required Notes
JwtSettings.Secret Minimum 32 characters
ConnectionStrings.DefaultConnection PostgreSQL connection string

Optional features

{
  "ConnectionStrings": {
    "Redis": "localhost:6379"       // Enables Redis caching + SignalR backplane
  },
  "RabbitMqOptions": {
    "Enabled": true,                 // Enables RabbitMQ messaging
    "Host": "localhost",
    "Username": "guest",
    "Password": "guest"
  },
  "PushKit": {
    "Fcm": { "ProjectId": "..." },  // Firebase Cloud Messaging
    "Apn": { "BundleId": "..." }    // Apple Push Notification
  },
  "GoogleOAuth": {
    "ClientId": "...",
    "ClientSecret": "..."
  },
  "Stripe": {
    "SecretKey": "...",
    "WebhookSecret": "..."
  }
}

Database Seeding

Seed roles & resources

cd src/MyProject.API
dotnet run seed role

This creates: SuperAdmin, Admin, User roles + all system resources.

Seed subscription plans

dotnet run seed plan

Seed currencies

dotnet run seed currency

Seed email templates

dotnet run seed mail-templates

Create users

dotnet run seed user <email> <password> <name> <role>

Examples:

# SuperAdmin
dotnet run seed user superadmin@myproject.com SuperAdmin@123 "Super Admin" SuperAdmin

# Admin
dotnet run seed user admin@myproject.com Admin@123 "Admin User" Admin

# Regular user
dotnet run seed user user@myproject.com User@123 "Regular User" User

Developer Workflow

Add a new migration

cd src/MyProject.API
dotnet ef migrations add MigrationName

Run tests

dotnet test

Architecture rules

Layer Depends on Can reference
API Application, Contracts Infrastructure, Persistence (project refs only)
Application Contracts, Domain
Infrastructure Application, Contracts
Persistence Domain, Contracts
Domain Contracts

Program.cs only imports MyProject.Application.DependencyInjection and MyProject.Contracts.Interfaces. All DI wiring is handled by ApplicationLayerBootstrapper.


Project Features

Category What's included
Architecture Clean Architecture with dependency inversion
API Versioning (v1, v2), Swagger, rate limiting, CORS
Auth JWT bearer tokens, refresh tokens, API keys, Google OAuth
2FA TOTP-based two-factor authentication
Database EF Core + PostgreSQL with migrations
Caching Redis (with in-memory fallback)
Messaging RabbitMQ (domain events, notifications)
Push Firebase Cloud Messaging + Apple Push Notification
Payments Stripe integration
Real-time SignalR with Redis backplane, SSE
Localization Multi-language support (EN, JA, ES, FR)
Audit Security audit logging
Notifications Email (AWS SES), in-app, push

IDE Integration (Visual Studio & JetBrains Rider)

CleanArchSharp appears in the New Project dialog in:

Visual Studio

  1. Open File → New → Project

  2. Search for CleanArchSharp

  3. Choose:

    • CleanArchSharp Solution Template
    • CleanArchSharp API Template Visual Studio Preview

JetBrains Rider

  1. Go to New Solution

  2. Search for CleanArchSharp

  3. Select your desired template and framework

    Rider Preview

  • .NETStandard 2.1

    • 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
3.0.2 82 7/8/2026
3.0.1 96 7/4/2026
3.0.0 139 6/18/2026
2.2.0 213 4/16/2026
2.1.1 5,827 12/18/2025
2.1.0 487 12/17/2025
2.0.0 500 12/17/2025
1.3.1 445 12/15/2025
1.3.0 448 12/15/2025
1.2.0 343 12/12/2025
Loading failed