Visual Studio Solution Structure – Best Practices for Domain Driven Design RESTful Web Service

cdomain-driven-designrest

I am building a .NET 4.5 C# Web API RESTful solution and I would like someone to tell me if my project solution is correct and/or wise(-enough?) for a solution designed using Domain Driven Design, please.

The solution has been split into 6 projects:

  • /Base

(Not referenced by anything)

The web project and forms the interface between the solution and the outside world. Contains the Web API controllers. Contains almost no logic beyond gathering values from request objects and asking the BizApi layer for work.

  • /Biz.Api

(Referenced by Base])

Provides the domain services and allows the /Base interface project to have access to the domain business logic objects in the /Biz.Domain project.

  • /Biz.Domain

(Referenced by Biz.Api)

Provides the domain classes for the Biz.Api layer. These provide methods to manipulate the data of the business in memory.

  • /Dal.Db

(Referenced by Biz.Api)

The database repository layer. Accesses the databases and maps returned data into internal DTO's defined in the /Interfaces layer.

  • /Dal.Services

(Referenced by Biz.Api)

Provides a proxy layer to external dependencies like web services and maps their returned data to internal DTOs defined in the /Interfaces project.

  • /Interfaces

(Referenced by most projects above)

Contains the DTO classes for passing data around the solution and the C# interfaces to define contracts for things like IoC.

Best Answer

This folder structure is inspired by the famous Implementing domain driven design book by Vaugh Vernon.

Solution:
├ WebService (REST Services reside here)
├ WebServiceTests
├ Application (Application services reside here)
├ ApplicationTests
├ Domain (Entities, VO, Domain services, domain factories, specifications, domain events, Repositories interfaces, infrastructures services interfaces)
├ DomainTests
├ Infrastructure (Repositories, Infrastructure services impl., Adapters to external services)
└ InfrastructureTests

I start with a Solution then create four projects for each layer in my application then another four projects for each layer tests.

Don't create a folder interfaces or services in your domain layer instead related classes should be grouped by functionality in modules.