How to organize my controllers in projects in .Net API?

by Salatiel   Last Updated May 22, 2020 20:05 PM

I'm working on a project that is a API with many controllers and modules. Which of the following is the best architectural practice to organizing my API controllers by dll (.NET 4.7 WebAPI)? Why?

OBS: Each item is inside a module is a dll

  1. One dll for each controller. Each csproj contains only one Controller.cs file:

Module 1
-- API Controller 1

-- API Controller 2

-- Domain
-- Application
-- Infra

Module 2
-- API Controller 3

-- API Controller 4

-- Domain
-- Application
-- Infra

  1. Group controllers in projects by context

Module 1
-- API

-- Domain
-- Application
-- Infra

Module 2
-- API

-- Domain
-- Application
-- Infra

  1. Create only one csproj with all controllers.

Module 1
-- Domain
-- Application
-- Infra

Module 2
-- Domain
-- Application
-- Infra

API (controllers)

Note: I'm using DDD (as possible), separating my business rules by context. Each context has its layers: domain, application and infra.

I started centralizing all Controllers of all contexts in one api project. It started to be messy, so I break in separate projects. However, there is some performance issue or architectural pattern that should I follow to organize my project?



Related Questions



Architect an existing Project

Updated September 14, 2017 17:05 PM

How does a service class relate to a model class

Updated April 28, 2017 05:05 AM