Recommendation Service โ API Reference ๐ค
This document describes the recommendation APIs exposed by the Recommendation Service in ShopVerse.
The service provides personalized product recommendations based on user interactions, processed asynchronously using Kafka.
๐ Base URLโ
/api/recommendations
๐ Authentication & Authorizationโ
- JWT is validated at the API Gateway
- Gateway injects:
X-User-EmailX-User-Role
- Only authenticated users with role
CUSTOMERcan access recommendations - Admin access is not applicable
๐ฏ Get Recommendations (Customer)โ
Fetch recommended products for the authenticated user.
โค Endpointโ
GET /api/recommendations
โค Query Parameters (Optional)โ
| Param | Description |
|---|---|
limit | Number of recommendations (default: 10) |
โค Success Response (200 OK)โ
[
{
"productId": "PROD123",
"score": 12.5,
"source": "PERSONAL"
},
{
"productId": "PROD456",
"score": 9.0,
"source": "POPULAR"
}
]
๐ง Recommendation Logic (High-Level)โ
- If user interaction data exists โ Personalized recommendations
- If insufficient data โ Popular products fallback
- Recommendations are read-only
- Scores are calculated using weighted interaction events
๐ Request Flowโ
๐ก Data Sourceโ
Recommendations are generated from Kafka events:
| Event Type | Source |
|---|---|
| VIEW_PRODUCT | Product Service |
| ADD_TO_CART | Order Service |
| ORDER_PLACED | Order Service |
These events are processed asynchronously and stored in MongoDB.
๐ก๏ธ Security Rulesโ
| Role | Access |
|---|---|
| CUSTOMER | Fetch own recommendations |
| ADMIN | โ Not allowed |
โ ๏ธ Common Errorsโ
| Status | Meaning |
|---|---|
| 401 | Unauthorized |
| 403 | Forbidden |
| 500 | Recommendation generation failure |
๐ Summaryโ
The Recommendation API provides:
- Personalized product discovery
- Event-driven scalability
- Clean read-only access
- Secure, customer-only endpoints
It enhances user engagement without affecting core transactions.