Conversation
|
Caution Review failedFailed to post review comments. WalkthroughAdds HealthModule with allowlisted liveness/readiness endpoints; introduces cookie-based JWT extraction/config; migrates user IDs to UUID and shifts APIs to walletAddress; adds role-specific user fields; creates Stores module; expands Offers with product linking, expiration cron/endpoints, and notifications; implements Seller Reviews module; updates entities, DTOs, migrations, tests, and documentation accordingly. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant API as API Gateway
participant HC as HealthController
participant DB as TypeORM DB
participant RD as Redis (optional)
participant OS as Disk/Memory
Client->>API: GET /api/v1/health/live
API->>HC: checkLive()
HC-->>API: { status: "up" }
API-->>Client: 200
Client->>API: GET /api/v1/health/ready
API->>HC: checkReady()
HC->>DB: pingCheck(database)
alt REDIS configured
HC->>RD: connect + PING
RD-->>HC: PONG
end
HC->>OS: memoryHeapCheck (if env)
HC->>OS: diskStorageCheck (if env)
HC-->>API: aggregated result
API-->>Client: 200/503
sequenceDiagram
autonumber
participant Cron as OfferExpirationService (Cron)
participant OfferSvc as OfferService
participant Repo as OfferRepository
participant Notif as NotificationService
Cron->>OfferSvc: expireOffers()
OfferSvc->>Repo: find({ status: PENDING, expiresAt < now })
Repo-->>OfferSvc: [expiredOffers]
alt Any expired
loop each expired offer
OfferSvc->>Repo: update(status=REJECTED, updatedAt=now)
OfferSvc->>Notif: createAndSendNotificationToUser({ type: offer_rejected, entityId: offer.id, userId: sellerId, payload })
end
else None
Note over OfferSvc: No-op
end
OfferSvc-->>Cron: expiredCount
sequenceDiagram
autonumber
actor Buyer
participant API as API (JWT cookie)
participant SRC as SellerReviewController
participant Svc as SellerReviewService
participant DB as Repos (Offer/User/SellerReview)
participant User as User (Seller)
Buyer->>API: POST /api/v1/reviews { offerId, rating, comment }
API->>SRC: createReview(req.user.id, dto)
SRC->>Svc: createReview(buyerId, dto)
Svc->>DB: findOne(Offer with seller & buyerRequest)
Svc->>DB: findOne(User as buyer)
Svc->>DB: findOne(SellerReview by offerId+buyerId)
alt Valid and not reviewed
Svc->>DB: save(SellerReview)
Svc->>DB: compute seller average + total
Svc->>User: update(avg, total)
Svc-->>SRC: SellerReviewResponseDTO
SRC-->>API: 201 { success, data }
else Error
Svc-->>SRC: throws (NotFound/Forbidden/BadRequest)
SRC-->>API: 4xx
end
sequenceDiagram
autonumber
actor Client
participant API as API
participant JWT as JwtStrategy
participant Auth as AuthService
participant User as UserService
Client->>API: Request with Cookie auth_token=JWT
API->>JWT: extract from cookie/header
JWT->>Auth: validate(payload)
alt payload.walletAddress
Auth->>User: getUserByWalletAddress()
else payload.id
Auth->>User: getUserById()
end
User-->>Auth: user
Auth-->>JWT: user info
JWT-->>API: req.user populated (UUID id)
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
🚀 StarShop Pull Request
Mark with an
xall the checkboxes that apply (like[x])📌 Type of Change
📝 Changes description
🎯 Review & Rating System for Sellers
Implemented a comprehensive review and rating system that allows buyers to rate and review sellers after confirming a purchase. This builds trust and helps future buyers make informed decisions.
��️ Core Components Added
New Entity:
SellerReviewentity with UUID primary key, foreign keys to offers and users, rating validation (1-5), and unique constraint for one review per offerUpdated Entity:
Userentity withaverageSellerRatingandtotalSellerReviewsfields for automatic rating aggregationAPI Endpoints:
POST /api/v1/reviews- Create a new seller reviewGET /api/v1/users/:id/reviews- Get all reviews for a specific sellerPUT /api/v1/reviews/:id- Update an existing reviewDELETE /api/v1/reviews/:id- Delete a reviewBusiness Logic:
SellerReviewServicewith comprehensive validation and business rulesSellerReviewControllerwith NestJS decorators and JWT authenticationDatabase:
seller_reviewstable with proper constraintsuserstable✅ Business Rules Implemented
wasPurchased = true)�� Testing Coverage
📚 Documentation
📸 Evidence (A photo is required as evidence)
API Endpoint Testing:
Seller Reviews Endpoint:
⏰ Time spent breakdown
Planning & Analysis: 30 minutes
Core Implementation: 2 hours
Database & Migration: 45 minutes
Testing: 1.5 hours
Documentation & Cleanup: 30 minutes
Total Time: ~5 hours
🌌 Comments
This implementation provides a robust foundation for the seller review system that can be easily extended in the future. The code follows NestJS best practices and includes comprehensive error handling, validation, and testing.
Key Features:
Future Enhancements:
The implementation is production-ready and follows all the specified requirements while maintaining code quality and best practices.
Thank you for contributing to StarShop, we are glad that you have chosen us as your project of choice and we hope that you continue to contribute to this great project, so that together we can make our mark at the top!
Summary by CodeRabbit
New Features
Documentation
Configuration