Build Event Notification Engine
Event Notification Engine
You are tasked with implementing a core component of a marketing engine for an event marketplace. The engine needs to send targeted notifications to customers based on various campaign criteria.
Available Data
Assume the following data structures are accessible:
Customer:id(unique identifier)city(customer's primary city)birth_month(month of birth)birth_day(day of birth)latitude(geographic latitude)longitude(geographic longitude)
Event:id(unique identifier)title(event name)city(event's city)start_time(timestamp of event start)latitude(geographic latitude)longitude(geographic longitude)
External Service
An external NotificationService is available with the following method:
NotificationService.send(customer_id, message): Sends a notification containingmessageto the specifiedcustomer_id.
Implementation Task
Implement a MarketingEngine class with a method signature similar to send_customer_notifications(customer, events, today). This method should process a given customer and a list of events to determine and send relevant notifications based on active campaigns, using today as the reference date.
Supported Campaigns
The engine must support the following notification campaigns:
- Local Events: Notify the customer about all upcoming events that are in the same city as the customer.
- Birthday Event: Notify the customer about the single upcoming event whose
start_timeis closest to the customer's next birthday aftertoday. - Proximity Events: Notify the customer about the 5 upcoming events closest to the customer by geographic distance. For the purpose of this interview, you may use Euclidean distance on latitude and longitude.
Design Requirements
- Extensibility: Design the code such that new campaigns can be added in the future without requiring modifications to the core
MarketingEnginelogic. - Edge Cases: Explain how your solution would handle:
- Ties (e.g., multiple events equally close for Campaign 2 or 3).
- Fewer than 5 matching events (for Campaign 3).
- Notification Formatting: Describe how the
messageparameter forNotificationService.sendwould be constructed.
AI interview prep
Core dilemma
Balancing the need for a highly extensible campaign system with efficient processing of diverse filtering criteria (geographic, temporal, categorical) against potentially large datasets of customers and events.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Build Event Notification Engine
Event Notification Engine
You are tasked with implementing a core component of a marketing engine for an event marketplace. The engine needs to send targeted notifications to customers based on various campaign criteria.
Available Data
Assume the following data structures are accessible:
Customer:id(unique identifier)city(customer's primary city)birth_month(month of birth)birth_day(day of birth)latitude(geographic latitude)longitude(geographic longitude)
Event:id(unique identifier)title(event name)city(event's city)start_time(timestamp of event start)latitude(geographic latitude)longitude(geographic longitude)
External Service
An external NotificationService is available with the following method:
NotificationService.send(customer_id, message): Sends a notification containingmessageto the specifiedcustomer_id.
Implementation Task
Implement a MarketingEngine class with a method signature similar to send_customer_notifications(customer, events, today). This method should process a given customer and a list of events to determine and send relevant notifications based on active campaigns, using today as the reference date.
Supported Campaigns
The engine must support the following notification campaigns:
- Local Events: Notify the customer about all upcoming events that are in the same city as the customer.
- Birthday Event: Notify the customer about the single upcoming event whose
start_timeis closest to the customer's next birthday aftertoday. - Proximity Events: Notify the customer about the 5 upcoming events closest to the customer by geographic distance. For the purpose of this interview, you may use Euclidean distance on latitude and longitude.
Design Requirements
- Extensibility: Design the code such that new campaigns can be added in the future without requiring modifications to the core
MarketingEnginelogic. - Edge Cases: Explain how your solution would handle:
- Ties (e.g., multiple events equally close for Campaign 2 or 3).
- Fewer than 5 matching events (for Campaign 3).
- Notification Formatting: Describe how the
messageparameter forNotificationService.sendwould be constructed.