Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/viet2811/uk-travel-recommendation/llms.txt

Use this file to discover all available pages before exploring further.

The Like endpoint records a positive interaction between the authenticated user and a specific attraction, then immediately updates the user’s preference profile vectors to move them closer to the liked attraction. The update is performed inside a database transaction with a row-level lock on the user’s profile, ensuring concurrent requests cannot corrupt the vector state. The operation is intentionally idempotent-safe — if the same attraction has already been liked, the endpoint returns a 400 error rather than silently re-applying the learning-rate update, which would skew the profile. Once a like is recorded, the attraction is excluded from all future calls to the List Recommendations endpoint for that user.

Endpoint

FieldValue
MethodPOST
Path/api/recommendations/like/{id}
AuthBearer token required
POST http://localhost:8000/api/recommendations/like/<attraction_id>
Authorization: Bearer <access_token>

Path Parameters

id
string
required
The unique identifier of the attraction to like. This matches the id field returned by the List Recommendations and Search endpoints.Example: /api/recommendations/like/tower-of-london

Request Body

This endpoint does not require a request body.

Profile Vector Update

When a like is successfully recorded, the user’s preference profile is updated using the following learning rates:
Vector ComponentUpdate RuleLearning Rate
labelMHEAdditive — profile.labelMHE += item.labelMHE * MHE_ALPHAMHE_ALPHA = 0.2
labelEmbedWeighted blend — profile.labelEmbed = (0.85 * profile.labelEmbed) + (0.15 * item.labelEmbed)LABEL_EMBED_ALPHA = 0.15
summaryEmbedWeighted blend — profile.summaryEmbed = (0.9 * profile.summaryEmbed) + (0.1 * item.summaryEmbed)SUMMARY_EMBED_ALPHA = 0.1
The resulting profile vector is normalised after each update to maintain consistent cosine similarity comparisons across all future recommendation calls.
A profile_delta value — the cosine distance between the profile vector before and after the like — is computed and stored alongside each interaction record. Additionally, after every 10th interaction (likes and dislikes combined), an Intra-List Diversity (ILD) score is computed over the last 10 interactions and stored as a UserRecommendationBatch record for analytics.

Response

200 OK — Like recorded successfully

{
  "message": "Preference updated",
  "id": "<attraction_id>"
}
message
string
Confirmation string. Always "Preference updated" on success.
id
string
The id of the attraction that was liked, echoed back in the response.

400 Bad Request — Already liked

Returned when a UserInteraction record with liked=True already exists for this user and attraction pair.
{
  "error": "Already liked"
}
error
string
Error message. Always "Already liked" when this specific condition is triggered.

Examples

curl -X POST "http://localhost:8000/api/recommendations/like/tower-of-london" \
  -H "Authorization: Bearer <access_token>"

Build docs developers (and LLMs) love