feat(productreview): add ProductReview microservice#1
Open
MuhammedEminClk wants to merge 17 commits into
Open
Conversation
…d UserId ProductReview.Create() was returning ProductReviewErrors.Rating.EmptyError for both empty ProductId and UserId checks — wrong error type entirely. Added dedicated EmptyProductIdError and EmptyUserIdError to ProductReviewErrors, updated Create() to use them, and strengthened the corresponding unit tests to assert on the specific error codes rather than just IsFailure. Also added ProductReviewUpdatedDomainEvent assertion to Update_ByOwner_Succeeds test.
…eviews Updated the `ProductReviewCreatedDomainEventHandler` to invalidate both "reviews" and "average-rating" cache tags. Modified the `GetProductReviewListQuery` to support pagination with `PageNumber` and `PageSize` parameters, and adjusted the corresponding query handler and repository methods to return paginated results. Updated the API endpoint to reflect these changes, ensuring a more efficient retrieval of product reviews.
…ement check Updated the health check for RabbitMQ to use an HTTP-based approach due to compatibility issues with the RabbitMQ.Client version. This change ensures that the health check remains functional regardless of the RabbitMQ client version. Additionally, modified the ProductReviewDeleteEndpoint to correctly bind the userId from the query parameters and updated the Keycloak realm in the dependency injection configuration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fork
Original repo: https://github.com/senrecep/Aspire
This PR implements the ProductReview microservice following the existing ProductService and CategoryService patterns exactly — Clean Architecture with CQRS separation, DDD aggregate roots, and the Result pattern throughout. The domain layer encapsulates all business logic: ownership checks (update/delete authorization) live inside the
ProductReviewentity itself, not in handlers, and value objects (ReviewRating,ReviewComment,ProductId,UserId) enforce invariants at construction time via factory methods returningResult<T>. TheAlreadyReviewedbusiness rule is enforced in the command handler before hitting the repository, keeping the aggregate free of query dependencies.For the persistence layer, separate
ApplicationWriteDbContextandApplicationReadDbContextinstances maintain the CQRS boundary — the read context runs withNoTrackingand has audit/domain-event interceptors disabled. A unique composite index on(product_id, user_id)provides a database-level safety net for the duplicate review rule. Soft deletes are handled via a global query filter so deleted records are transparently excluded from all queries. TheProductReviewCreatedDomainEventHandlerinvalidates Redis cache tags and publishes aProductReviewCreatedIntegrationEventto RabbitMQ via MassTransit — keeping the integration concern out of the domain and inside the application layer where it belongs.Trade-offs
userIdon the DELETE endpoint is passed as a query parameter (?userId=...) rather than extracted from the JWT claims. In a real production system this would be extracted from the authenticated user context to prevent spoofing, but since Keycloak auth is already wired and the task focuses on architectural patterns, this approach keeps the implementation straightforward and consistent with how other endpoints receive user identity.Guidprimitives instead of value objects, which is intentional — read models are flat projections for queries, not domain objects, so value object overhead is unnecessary there.