2026-03-09 18:01:01 +07:00
2026-03-09 18:01:01 +07:00
2026-02-26 14:04:18 +07:00
2026-02-26 14:04:18 +07:00
2026-02-26 14:04:18 +07:00
2026-02-26 14:04:18 +07:00
2026-02-26 14:04:18 +07:00
2026-02-26 14:04:18 +07:00
2026-02-26 14:04:18 +07:00
2026-02-26 14:04:18 +07:00
2026-02-26 14:04:18 +07:00
2026-03-09 16:51:44 +07:00
2026-02-26 14:04:18 +07:00
2026-02-26 14:04:18 +07:00
2026-02-26 14:03:46 +07:00

MyNewProjectName - Clean Architecture Template

A Clean Architecture template for .NET 9 applications.

📁 Project Structure

├── MyNewProjectName.Domain          # Enterprise Business Rules (Entities, Value Objects, Domain Events)
├── MyNewProjectName.Application     # Application Business Rules (Use Cases, CQRS, Validators)
├── MyNewProjectName.Contracts       # DTOs for external communication (Requests, Responses)
├── MyNewProjectName.Infrastructure  # External concerns (Database, Identity, Services)
├── MyNewProjectName.WebAPI          # Web API presentation layer
├── MyNewProjectName.AdminAPI        # Admin API presentation layer
└── MyNewProjectName.UnitTest        # Unit tests

🏗️ Architecture

This template follows Clean Architecture principles:

┌─────────────────────────────────────────────────────────┐
│  Presentation Layer (WebAPI, AdminAPI)                  │
├─────────────────────────────────────────────────────────┤
│  Infrastructure Layer (EF Core, Identity, Services)     │
├─────────────────────────────────────────────────────────┤
│  Application Layer (MediatR, AutoMapper, Validators)    │
├─────────────────────────────────────────────────────────┤
│  Domain Layer (Entities, ValueObjects, Interfaces)      │
└─────────────────────────────────────────────────────────┘

Dependency Rule

  • Inner layers know nothing about outer layers
  • Dependencies point inward

🚀 Getting Started

Prerequisites

  • .NET 9 SDK
  • SQL Server (or modify connection string for other databases)

Setup

  1. Clone and rename the template

    # Clone the repository
    git clone <repository-url> MyNewProject
    cd MyNewProject
    
    # Run the rename script
    ./rename-project.sh MyNewProject
    
  2. Update connection string

    Edit appsettings.json in WebAPI/AdminAPI projects:

    {
      "ConnectionStrings": {
        "DefaultConnection": "Your-Connection-String"
      }
    }
    
  3. Run migrations

    cd MyNewProjectName.Infrastructure
    dotnet ef migrations add InitialCreate --startup-project ../MyNewProjectName.WebAPI
    dotnet ef database update --startup-project ../MyNewProjectName.WebAPI
    
  4. Run the application

    dotnet run --project MyNewProjectName.WebAPI
    

NuGet Packages

Application Layer

  • MediatR - CQRS pattern implementation
  • AutoMapper - Object-to-object mapping
  • FluentValidation - Validation rules

Infrastructure Layer

  • Entity Framework Core - ORM
  • Microsoft.AspNetCore.Identity - Authentication/Authorization

🔧 Key Features

  • Clean Architecture structure
  • CQRS with MediatR
  • Validation pipeline with FluentValidation
  • Logging pipeline behavior
  • Global exception handling
  • Generic Repository pattern
  • Unit of Work pattern
  • AutoMapper integration
  • Multi-API support (WebAPI + AdminAPI)
  • Auditable entities
  • Soft delete support
  • Domain events support

📝 Usage Examples

Creating a new Feature

  1. Add Entity in Domain/Entities/
  2. Add Repository Interface in Domain/Interfaces/
  3. Add Command/Query in Application/Features/{FeatureName}/
  4. Add DTO in Contracts/DTOs/
  5. Add Controller in WebAPI/Controllers/

Sample CQRS Structure

Application/Features/Sample/
├── Commands/
│   └── CreateSample/
│       ├── CreateSampleCommand.cs
│       ├── CreateSampleCommandHandler.cs
│       └── CreateSampleCommandValidator.cs
└── Queries/
    └── GetSamples/
        ├── GetSamplesQuery.cs
        ├── GetSamplesQueryHandler.cs
        └── SampleDto.cs

🔄 Renaming the Project

Use the provided script to rename all occurrences of MyNewProjectName:

./rename-project.sh NewProjectName

📄 License

MIT License

Description
No description provided
Readme 6.8 MiB
Languages
Python 91.9%
C# 5.7%
JavaScript 1.3%
Shell 0.5%
TypeScript 0.3%
Other 0.2%