I'm building a DDD application which is effectively a wrapper around Cognito. As such, everything that this is doing is effectively just a call onto the Cognito SDK.
Where I'm getting confused is how this should work with respect to Domain Services or Repositories.
I've got an Aggregate to represent a User. I then have a number of actions that I want to be able to support:
- Load a user by ID
- Update a user
- Delete a user
- Send an email confirmation message
- Verify the users email address
- Configure MFA
- Verify an MFA code
- Change the users password
Now, the first three of these feel like they fit a Repository well. They're basically Retrieve, Update and Delete from the standard CRUD model.
However, the other five I'm less sure about. They are actions performed on the user, but they're not standard CRUD ones. However, all eight of these are done using the same SDK instance.
So, would it be better to:
- Put all of these in a Repository?
- Put all of these - even the CRUD ones - in Domain Services?
- Put some of these on a Repository and others on Domain Services? (Even though they're all backed by the same SDK instance)
- Put some of these on a Repository and others on the Aggregate? (Though this would then mean that the Aggregate has calls that affect a remote service, which seems bad)
- Something else entirely?
To add to this, the "Verify an MFA Code" action is needed as a step in some other actions - namely "Delete a user" and "Change the users password". Which definitely makes it feel like a Domain Service.