I'm trying to create a simple blogging platform and at the same time learn more about DDD and Microservices, so I wanted to ask you about two advises in this context:
- One of the business rules I assumed in my project is that only users in roles
Publicist
andAdministrator
are able to create posts, but posts created byPublicist
have to be approved byAdministrator
first before they go public. In my understanding this is a part of aPosts.Domain
, so inPost
aggregate (and at the same time entity) I encapsulated changing the post's status into methods likeSetPublishedStatusBy
that takeUser
(requestor) data as parameters and evaluate above rule (+ create domain events). However now I'm having some doubts whether information about requestor is really a part of thePosts.Domain
. Maybe requestor should be evaulated in a different place, likePosts.API
or some other service andSetPublishedStatus
would be then called without parameters after it is already done? - Let's stick to above context. Despite
Posts
microservice, I'm also developing independentUsers
microservice responsible for storing the users and providing some tools forAdministrator
to manage them. What would be then the proper data flow when a user wants to publish a new post? I'd imagine this in a following way:
- Client sends
PublishPost
command with a post ID to the gateway - Gateway authenticates user from HTTP request (probably done via cookie with JWT)
- Gateway sends a
PublishPost
command toPosts
microservice Posts
microservice callsUsers
microservice to get relevant user data from DBPosts
microservice retreives post from DB by ID- All business rules are evaluated through the
Posts.Domain
and status is changed toPublic
Posts
microservice updates DB if everything goes fine and notifies Gateway that sendsSuccess
HTTP response
Aucun commentaire:
Enregistrer un commentaire