Design Composable Event Recommendations
Design a Composable Event Recommendation Engine
Design and implement a flexible event recommendation engine for a ticket marketplace. The core challenge is to support diverse marketing campaigns without hard-coding each campaign's specific logic, emphasizing extensibility and composability.
Provided Domain Objects and Services
You are given the following domain objects and services to interact with:
Event(id, name, city, date): Represents an event.Customer(id, name, city): Represents a user.Inventory(eventId, price, quantity): Represents ticket availability and pricing for an event.Coordinates(x, y): A simple geographical coordinate pair.
Available services:
EventsService.getEvents(): Returns a collection of all available events.InventoryService.getInventory(): Returns a collection of all inventory records.UsersService.getCustomer(): Returns the current customer for whom recommendations are being generated.LocationService.getLocationCoordsByCity(city): ReturnsCoordinatesfor a given city.LocationService.calculateDistanceInMiles(x1, y1, x2, y2): Calculates the distance between two coordinate points.
Context and Product Insights
The system should consider the following product insights to drive engagement:
- Users are more likely to engage with events within 100 miles of their home city.
- Events with inventory priced under $50 convert at a higher rate.
- Events happening this weekend or within the next 30 days drive stronger engagement.
- Users in metro areas may purchase tickets in adjacent cities.
- Campaigns that return some relevant events perform better than campaigns that return no events.
- Future signals may include artist hometown affinity, seasonal or weather effects, and handling repeated event names across multiple cities.
Core Requirements
- Event Availability: Join events with inventory data and only recommend events that have an available quantity (
quantity > 0). - Reusable Rules: Support a set of reusable recommendation rules, including:
- Events in the user's home city.
- Events within 100 miles of the user's home city.
- Events priced below $50.
- Events happening this weekend.
- Events happening within the next 30 days.
- Rule Composition: Allow campaign rules to be composed using logical operations such as
ANDandOR. - Configurable Ranking: Support configurable ranking criteria, such as:
- Nearest distance.
- Lowest price.
- Soonest date.
- A weighted score combining multiple factors.
- Fallback Behavior: Implement fallback mechanisms so a campaign can return broader recommendations if the primary rule set produces no results.
- Duplicate Handling: Ensure the final result set contains no duplicate events.
- Edge Cases: Gracefully handle edge cases such as missing coordinates for a city, missing inventory records for an event, an unknown city, zero available inventory, and ties in ranking.
- Demonstration: Demonstrate the design with at least one example campaign. For instance: recommend events that are either within 100 miles of the user OR priced under $50, then rank them first by distance and then by price.
Implementation Details
You may use Java or clear pseudocode for your solution. The primary evaluation criterion is the extensibility and composability of your design, rather than a collection of one-off, hard-coded filters.
AI interview prep
Core dilemma
Balancing the need for a highly flexible and composable rule engine with efficient data processing and retrieval for potentially large datasets, while maintaining acceptable latency.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design Composable Event Recommendations
Design a Composable Event Recommendation Engine
Design and implement a flexible event recommendation engine for a ticket marketplace. The core challenge is to support diverse marketing campaigns without hard-coding each campaign's specific logic, emphasizing extensibility and composability.
Provided Domain Objects and Services
You are given the following domain objects and services to interact with:
Event(id, name, city, date): Represents an event.Customer(id, name, city): Represents a user.Inventory(eventId, price, quantity): Represents ticket availability and pricing for an event.Coordinates(x, y): A simple geographical coordinate pair.
Available services:
EventsService.getEvents(): Returns a collection of all available events.InventoryService.getInventory(): Returns a collection of all inventory records.UsersService.getCustomer(): Returns the current customer for whom recommendations are being generated.LocationService.getLocationCoordsByCity(city): ReturnsCoordinatesfor a given city.LocationService.calculateDistanceInMiles(x1, y1, x2, y2): Calculates the distance between two coordinate points.
Context and Product Insights
The system should consider the following product insights to drive engagement:
- Users are more likely to engage with events within 100 miles of their home city.
- Events with inventory priced under $50 convert at a higher rate.
- Events happening this weekend or within the next 30 days drive stronger engagement.
- Users in metro areas may purchase tickets in adjacent cities.
- Campaigns that return some relevant events perform better than campaigns that return no events.
- Future signals may include artist hometown affinity, seasonal or weather effects, and handling repeated event names across multiple cities.
Core Requirements
- Event Availability: Join events with inventory data and only recommend events that have an available quantity (
quantity > 0). - Reusable Rules: Support a set of reusable recommendation rules, including:
- Events in the user's home city.
- Events within 100 miles of the user's home city.
- Events priced below $50.
- Events happening this weekend.
- Events happening within the next 30 days.
- Rule Composition: Allow campaign rules to be composed using logical operations such as
ANDandOR. - Configurable Ranking: Support configurable ranking criteria, such as:
- Nearest distance.
- Lowest price.
- Soonest date.
- A weighted score combining multiple factors.
- Fallback Behavior: Implement fallback mechanisms so a campaign can return broader recommendations if the primary rule set produces no results.
- Duplicate Handling: Ensure the final result set contains no duplicate events.
- Edge Cases: Gracefully handle edge cases such as missing coordinates for a city, missing inventory records for an event, an unknown city, zero available inventory, and ties in ranking.
- Demonstration: Demonstrate the design with at least one example campaign. For instance: recommend events that are either within 100 miles of the user OR priced under $50, then rank them first by distance and then by price.
Implementation Details
You may use Java or clear pseudocode for your solution. The primary evaluation criterion is the extensibility and composability of your design, rather than a collection of one-off, hard-coded filters.