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
PublicistandAdministratorare able to create posts, but posts created byPublicisthave to be approved byAdministratorfirst before they go public. In my understanding this is a part of aPosts.Domain, so inPostaggregate (and at the same time entity) I encapsulated changing the post's status into methods likeSetPublishedStatusBythat 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.APIor some other service andSetPublishedStatuswould be then called without parameters after it is already done? - Let's stick to above context. Despite
Postsmicroservice, I'm also developing independentUsersmicroservice responsible for storing the users and providing some tools forAdministratorto 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
PublishPostcommand with a post ID to the gateway - Gateway authenticates user from HTTP request (probably done via cookie with JWT)
- Gateway sends a
PublishPostcommand toPostsmicroservice Postsmicroservice callsUsersmicroservice to get relevant user data from DBPostsmicroservice retreives post from DB by ID- All business rules are evaluated through the
Posts.Domainand status is changed toPublic Postsmicroservice updates DB if everything goes fine and notifies Gateway that sendsSuccessHTTP response
Aucun commentaire:
Enregistrer un commentaire