본문 바로가기

Backend/.NET

Server Architecture - Distributing Projects

반응형

Server Structure

An interface is a middleman between the browser and the server. It sends a request to a server and handles the response from it. The interface has a dependency on the infrastructure which also has a dependency on the application core project that defines things that are specific to the project such as business logic hence has no dependency on any other project.

Implementation

1. Creating Projects

Let's add a solution first.

dotnet new sln

▶ Interface

Create a webapi project that will be an entry point to our whole project. Then add it to the solution

dotnet new webapi -o API
dotnet sln add API

▶ Infrastructure

Create the infrastructure project that will govern the tasks related to data and add it to the solution.

dotnet new classlib -n Infrastructure
dotnet sln add Infrastructure

▶ Core

Now, finally create a core project and add it to the solution

dotnet new classlib -n Core
dotnet sln add Core

2. Adding References

As I mentioned above each project has a dependency on another except for the core project. Let's go to the API project  (interface) to add a reference to the infrastructure project.

cd API/
dotnet add reference ../Infrastructure/

When it is done, let's go back to the root folder.

cd ..

Then move to the infrastructure project to add a reference to the core project.

cd Infrastructure/
dotnet add reference ../Core/

Go back again to the root folder.

cd ..

Run the command below to reflect the changes we make to the structure of our project.

dotnet restore

Well, that is it! We have seen 'Interface' -> 'Infrastructure' -> 'Core' architecture in .NET development here and I hope this can help you better structure your project.


References

Common web application architectures | Microsoft Learn

 

Common web application architectures

Architect Modern Web Applications with ASP.NET Core and Azure | Explore the common web application architectures

learn.microsoft.com

 

728x90
반응형

'Backend > .NET' 카테고리의 다른 글

.NET - Cleaning Up Program File: Service Extension Method  (0) 2023.03.08
How to create .NET web-API  (1) 2023.03.02
Adding Relation to DB  (0) 2023.03.02
Auto Migration and Data Seeding  (1) 2023.03.01
Working with SQLite in .NET (Code first)  (1) 2023.03.01