Build a small Rails application that posts product data to two different mock marketplaces. This exercise simulates real-world integration challenges in a simplified environment.
Create an endpoint that:
- Accepts product data
- Posts the product to both mock marketplaces:
- Direct posting to Marketplace A
- Two-step creation and publishing process for Marketplace B
- Returns the combined results including status for each step
- Implements appropriate retry strategies for failed requests
Two mock marketplace APIs are provided (running locally):
- Endpoint:
POST http://localhost:3001/api/products
- Format:
{
"name": "Product Name",
"price": 1999,
"sku": "ABC123"
}
- Returns 201 on success with response:
{
"id": "12345",
"status": "success"
}
Two-step process required:
- Create Inventory Item
- Endpoint:
POST http://localhost:3002/inventory
- Format:
{
"title": "Product Name",
"price_cents": 1999,
"seller_sku": "ABC123"
}
- Behavior:
- Fails 50% of the time with 5xx error
- Requires 2-second wait before retry
- Success Response (200):
{
"inventory_id": "67890",
"status": "created"
}
- Publish Listing
- Endpoint:
POST http://localhost:3002/inventory/{inventory_id}/publish
- Format: Empty POST body
- Behavior:
- Fails 50% of the time with 5xx error
- Requires 2-second wait before retry
- Success Response (200):
{
"listing_id": "L123",
"status": "published"
}
Note: If publishing fails, the inventory item remains in the system and can be retried. However, a new publish attempt must wait at least 2 seconds after a failed attempt.
- Use Ruby on Rails
- Implement proper error handling for both single-step and multi-step processes
- Include retry logic that:
- Handles different types of failures
- Implements appropriate waiting periods
- Manages partial success states
- Add appropriate logging that helps track the progress and debug issues
- Write tests covering various success and failure scenarios
- Consider edge cases like partial completions and system restarts
- Clean, maintainable code
- Proper error handling
- Thoughtful abstraction patterns
- Good testing practices
- Logging for debugging purposes
- Source code in a Git repository
- README with:
- Setup instructions
- Brief explanation of your approach
- Any assumptions made
- Ideas for improvements if you had more time
- 1-2 hours
- Clone this repository
- Run the mock servers:
sh setup.sh
This will start both marketplace mock servers (ports 3001 and 3002)
{
"name": "Test Product",
"price": 1999,
"sku": "TEST123"
}
- Share your Git repository with us
- Ensure your README covers setup and your approach
- Include any notes about design decisions or trade-offs made