Free Clean Architecture Template for NET Developers

Listen to this Post

Featured Image
Milan Jovanović has built a free Clean Architecture template for .NET developers, with over 16,500+ downloads. The template includes:

  • Simple domain model
  • Domain Events pattern
  • CQRS + clean use cases
  • Validation and logging
  • JWT Authentication
  • RBAC Authorization boilerplate
  • Minimal APIs & health checks
  • Docker support for local deployment

The template has been updated to remove MediatR (now commercial).

πŸ”— Download the template here: https://lnkd.in/eYNb_EVf

You Should Know:

1. Running the Template with Docker

To set up the template locally using Docker:

docker-compose up -d 

Verify running containers:

docker ps 

2. JWT Authentication Setup

Generate a secure JWT key:

openssl rand -base64 32 

Update `appsettings.json`:

"Jwt": { 
"Key": "your_generated_key_here", 
"Issuer": "your_issuer", 
"Audience": "your_audience" 
} 

3. CQRS Implementation

Example command handler structure:

public class CreateUserCommandHandler : IRequestHandler<CreateUserCommand, Result> 
{ 
public async Task<Result> Handle(CreateUserCommand request, CancellationToken cancellationToken) 
{ 
// Business logic here 
} 
} 

4. Domain Events

Triggering an event:

public class UserCreatedEvent : INotification 
{ 
public string UserId { get; } 
public UserCreatedEvent(string userId) => UserId = userId; 
}

// Inside a service: 
await _mediator.Publish(new UserCreatedEvent(user.Id)); 

5. Health Checks

Add a health endpoint:

app.MapHealthChecks("/health"); 

6. Logging with Serilog

Configure in `Program.cs`:

builder.Host.UseSerilog((ctx, lc) => lc 
.WriteTo.Console() 
.WriteTo.File("logs/log.txt")); 

What Undercode Say:

This template is a massive time-saver for .NET developers working with Clean Architecture, CQRS, and Docker. Removing MediatR simplifies dependency management, while JWT and RBAC provide a solid security foundation.

πŸ”Ή Key Linux Commands for Debugging .NET Apps:

 Check running .NET processes 
ps aux | grep dotnet

Monitor logs in real-time 
tail -f /var/log/syslog

Check Docker logs 
docker logs <container_id> 

πŸ”Ή Windows Equivalent:

 List running .NET processes 
Get-Process -Name "dotnet"

Check event logs 
Get-EventLog -LogName Application -Source "DotNet Runtime" 

πŸ”Ή Prediction:

As MediatR shifts commercial, more open-source alternatives will emerge, pushing developers toward lighter, custom event-driven architectures.

Expected Output:

A production-ready .NET backend with:

βœ… Clean Architecture

βœ… Secure JWT Auth

βœ… Dockerized Deployment

βœ… Event-Driven Design

πŸ”— Template Link: https://lnkd.in/eYNb_EVf

References:

Reported By: Milan Jovanovic – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass βœ…

Join Our Cyber World:

πŸ’¬ Whatsapp | πŸ’¬ Telegram