Domain Driven Design - modeling user registration process .NET Core

189 Views Asked by At

I am learning DDD and try to model user registration process using domain driven design. Lets imagine a dinner hosting system where Host and Guest are two entities. The host will be the one that will create dinner in the system and the guest will join the dinner, pay bill to host, rate the dinner, etc. Both host and guests will be the user of Dinner Hosting System. I have created three entities as below:

  • Host (id, First_Name, Last_Name, Email, Mobile, ...)
  • Guest (id, First_Name, Last_Name, Email, Mobile, ...)
  • User (id, user_type (Guest or Host), Joining_Date, Status, ...)

Here, I see that a user cannot exist on its own. It will always be either a host or a guest. So in this system, there should be two aggregate roots - Host and Guest. And the User entity will be part of each aggregate.

Also the user will be registered as below

Enter mobile number and submit

  • An OTP will be sent to the user
  • The OTP will be submitted and validated by the system
  • On the next screen, the user will enter and submit his First Name, Last Name, Email and Gender

As the complete user information is gathered in steps, and since the user can kill the app during registration process therefore, until the successful completion of last step, the user/host/guest entities should not be valid for the system, how can I create/save users/host/guest entities using DDD?

1

There are 1 best solutions below

0
kargarf On

The central business entity of a web application's user registration system is the user. In order to maintain data durability, the RegisterUser use case interacts with the UserRepository interface and verifies the input data.

A database driver for storing user data and the web framework for managing HTTP requests are examples of components that are included in the external framework, also known as the driver layer. So User is one aggregate root which host and guest are inherited and nested for this.

the other aggregate root entity is Dinner, which different kind of dinner menus will be inherited from.

for more information Click