Giter Site home page Giter Site logo

hack3rlife / cleanarchitecture-webapi-template Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 229 KB

Clean Architecture Project Template for ASP .NET Core WebAPI Projects using C#

License: GNU General Public License v3.0

C# 96.18% Dockerfile 3.82%
aspnetcore webapi dot-net-core dotnetcore asp-net-core csharp dotnet-new

cleanarchitecture-webapi-template's Introduction

Clean Architecture Template

The following solution template can be used for creating C# ASP .NET Core WebAPI using Clean Architecture Design Pattern Principles.

Frameworks, tools and techologies used

  1. ASP .NET Core 3.1
  2. MediatR
  3. FluentValidation
  4. FluentAssertions
  5. Moq
  6. Docker
  7. Lorem.Universal.NET
  8. Newtonsoft.Json
  9. xUnit
  10. Swashbuckle.AspNetCore

Index

Getting Started

  1. Install Visual Studio
  2. Install the latest .NET 5 SDK | .NET 6 SDK
  3. Install .Net Core 3.1 SDK.

Local Installation

  1. Clone this repository in your computer in a local <DIRECTORY> (e.g.: C:\Users\hack3rlife\source\repos).
  2. Install the template by running the following command: dotnet new <DIRECTORY>.
  3. Create a new directory (e.g.: hack3rlife-cleanarchitecture) and cd into it.
  4. Create a new solution by executing the following command dotnet new -i CleanArchitectureNetCoreWebAPI -n <PROJECT_NAME>.

NuGet Installation

  1. Execute dotnet new -i Hack3rlife.ASP.NETCore.WebAPI to install the latest version.
    1. Execute dotnet new -u Hack3rlife.ASP.NETCore.WebAPI to uninstall the template.

How the code is organized

The solution is organized in the following way

- BlogWebApi.WebApi.sln

    | - README.md

    | - src

        | - BlogWebApi.Application

        | - BlogWebApi.Domain

        | - BlogWebApi.Infrastructure

        |- BlogWebApi.WebApi

    | - tests

        | - Application.UnitTest

        | - Infrastructure.IntegrationTests

        | - WebApi.EndToEndTests

Domain Project

This project will include Domain Models, Interfaces that will be implemented by the outside layers, enums, etc., specific to the domain logic. This project should not have any dependecy to another project since it is the core of the project.

Domain Types

  • Domain Models
  • Interfaces
  • Exceptions
  • Enums

Application Project

This project will contain the application logic. The only dependency that should have is the Domain project. Any other project dependency must be removed.

Appllication Types

  • Exceptions
  • Interfaces
  • DTOs
  • Mappers

Infrastructure Project

The Infrastructure project generally includes data access implementations or accessing external resources as file sytems, SMTP, third-party services, etc. These classes should implementations of the Interfaces defined in the Domain Project. Therefore, the only dependency in this project should be to the Domain Project. Any other dependency must be removed.

Infrastructure Types

  • EF Core Types
  • Repository Implementation

WebAPI Project

This is the entry point of our application and it depends on the Application and Infrastrucre projects. The dependency on Infrastructre Project is requiered to support Dependency Injection in the Startup.cs class. Therefore, no direct instantiation of or static calls to the Infrastucture project should be allowed.

WebAPI Types

  • Controllers
  • Startup
  • Program

References

cleanarchitecture-webapi-template's People

Contributors

hack3rlife avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

tcruz3009

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.