CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/graceful-degradation

Every external call needs a timeout, every timeout needs a fallback — resilience patterns for HTTP, databases, and third-party services

88

4.72x
Quality

90%

Does it follow best practices?

Impact

85%

4.72x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-3/

Product Recommendation Service

Build a Node.js Express API for a product recommendation service. The service has two endpoints:

GET /api/recommendations/:userId

This endpoint builds personalized product recommendations by:

  1. Calling the User Profile API (https://profiles.internal.example.com/api/users/:userId) to get the user's preferences, purchase history, and demographic data.
  2. Calling the Recommendation Engine API (https://recommendations.internal.example.com/api/suggest) with the user profile data as a POST body to get recommended product IDs.
  3. Calling the Product Catalog API (https://catalog.internal.example.com/api/products/batch) with the recommended product IDs to get full product details (name, price, image, description).

Return a response like:

{
  "userId": "user-123",
  "recommendations": [
    { "id": "prod-1", "name": "Wireless Headphones", "price": 79.99, "reason": "Based on your recent purchases" },
    { "id": "prod-2", "name": "USB-C Hub", "price": 45.00, "reason": "Popular in your category" }
  ]
}

GET /api/recommendations/:userId/quick

A faster version that only calls the Recommendation Engine with a cached/default profile if the profile service is slow, returning product IDs without full catalog details.

API authentication uses a service token from the SERVICE_AUTH_TOKEN environment variable, sent as a Bearer token in the Authorization header.

Output

Produce TypeScript files in a src/ directory:

  • src/index.ts -- Express server with routes
  • src/services/userProfile.ts -- fetches user profile data
  • src/services/recommendations.ts -- calls the recommendation engine
  • src/services/productCatalog.ts -- fetches product details
  • src/types.ts -- TypeScript interfaces

Do not include test files or build configuration.

evals

tile.json