Skip to content

A comprehensive reference repository demonstrating the evolution of ASP.NET Core architectures. Features production-ready templates ranging from Monolithic MVC/API patterns to scalable, enterprise-grade Clean Architecture (N-Layer) solutions implementing SOLID principles.

Notifications You must be signed in to change notification settings

enesimo16/DotNet-Architecture-Patterns

Repository files navigation

DotNet-Architecture-Patterns

.NET Architecture Pattern Status

DotNet-Architecture-Patterns is a comprehensive reference repository demonstrating the evolution of ASP.NET Core software architecture.

It provides production-ready templates ranging from simple Monolithic structures to complex, enterprise-grade Clean Architecture solutions. This project serves as a practical guide to understanding Dependency Injection, SoC (Separation of Concerns), and SOLID principles in real-world scenarios.


Architectural Evolution & Comparison

This repository is structured to show the progression from tightly coupled code to highly decoupled, maintainable systems.

Module / Architecture Complexity Scalability Testability Ideal Use Case
01-SingleLayer-MVC Quick prototypes, internal tools, learning basics.
02-SingleLayer-API ⭐⭐ ⭐⭐ ⭐⭐ Simple backends for mobile/web apps without complex logic.
03-MultiLayer-Shared ⭐⭐⭐ ⭐⭐⭐ ⭐⭐⭐ Standard business applications with distinct logic layers.
04-Clean-N-Layer ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐⭐ Enterprise systems, high-traffic apps, long-term maintenance.

Repository Contents

1. [01-SingleLayer-MVC]

The Monolith.

  • Structure: Controllers, Models, and Views are strictly coupled in a single project.
  • Focus: Understanding the basics of MVC routing and Razor Views.
  • Limitation: Hard to unit test; UI and Business Logic are intertwined.

2. [02-SingleLayer-API]

The Decoupling of UI.

  • Structure: A standalone RESTful API.
  • Focus: Returning JSON data, HTTP Status Codes, and Swagger documentation.
  • Improvement: The frontend can now be React, Angular, or a Mobile App (separated from backend).

3. [03-MultiLayer-Shared]

Introduction to N-Tier.

  • Structure: Breaks the app into API, Business (BLL), and DataAccess (DAL) layers using a shared class library.
  • Focus: Separation of Concerns. The API strictly handles requests; it knows nothing about the database.
  • Key Concept: Introduction of simple Dependency Injection.

4. [04-Clean-N-Layer-Architecture]

The Enterprise Standard (Best Practice).

  • Structure: Strictly implements Clean Architecture principles involving Core, Data, Service, and API layers.
  • Key Features:
    • Core Layer: Holds Entities, Interfaces, and DTOs (No external dependencies).
    • Repository Pattern & Unit of Work: Abstracts database access completely.
    • Service Layer: Contains pure business logic and mapping (AutoMapper).
    • Dependency Injection: Heavy use of DI to decouple layers.
    • Custom Response Wrapper: Standardized API responses (Success/Fail/Data).

This is the architecture I recommend and use for production-level applications like MelesAI.


Technology Stack

  • Framework: .NET 8 (ASP.NET Core)
  • Language: C# 12
  • Database: MS SQL Server / Entity Framework Core (Code-First)
  • Mapping: AutoMapper
  • Documentation: Swagger / OpenAPI
  • Tools: Visual Studio 2022, Postman

Getting Started

This repository is designed as a Multi-Project Solution. You can run any architecture pattern from a single interface.

  1. Clone the repository:

    git clone [https://github.com/enesimo16/DotNet-Architecture-Patterns.git](https://github.com/enesimo16/DotNet-Architecture-Patterns.git)
  2. Open the Solution:

    • Double-click ArchitecturePatterns.sln to open all projects in Visual Studio.
  3. Configure Database:

    • Each project (specifically 03 and 04) has its own appsettings.json.
    • Update the ConnectionStrings to match your local SQL Server instance (LocalDB or Docker).
  4. Run Migrations:

    • Open Package Manager Console.
    • Select the target Data project (e.g., 04-Clean-N-Layer-Architecture.Data).
    • Run: update-database
  5. Run the App:

    • Set your desired project (e.g., 04-Clean-N-Layer-Architecture.API) as the Startup Project.
    • Press F5.

Enes Yel(https://github.com/enesimo16)

About

A comprehensive reference repository demonstrating the evolution of ASP.NET Core architectures. Features production-ready templates ranging from Monolithic MVC/API patterns to scalable, enterprise-grade Clean Architecture (N-Layer) solutions implementing SOLID principles.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published