Search code examples
.netasp.net-coremicroservicessoftware-designclean-architecture

In Clean Architecture design, Do we need to create a separate "Project" for each layer?


In Clean Architecture design, Do we need to create a separate "Project" for each layer? Or Can we define the layer with the Folders and Namespaces on the same project?

I am working on designing a new application in MicroServices architecture using Net Core. I'm planning to use Clean architecture principles in my design.

I am planning to use the below project structure for my every individual service. Is this the right way? I'm trying to reduce the number of projects.

  • Project 1 - Presentation
  • Project 2 - Application Layer, Domain Layer, Persister Layer (Here layers are isolated by Folders and Namespaces)
  • Project 3 - Infra
  • Project 4 - Crosscutting

Solution

  • It would seem in the beginning of development that holding everything together in one place is better, but when the project grows you will experience more and more dificulty maintaining an overview of the seperate components.

    You can decide to move the code when this happens, but this can be more of an hassle then separating the code at the start.

    Especially once you start thinking about the use of nuget packages and such, this can help you in figuring out which code is using what components.