Design a Farm Pest Alert System
Join pest observations with a stable farm catalog and deliver traceable alerts without losing work on retries.
Problem statement
For this exercise, assume a Pest DB supplies immutable observations with an ID, pest type, one affected crop, geographic point and observed time. A separate Farm DB supplies complete catalog revisions containing farm ID, owner, active status, crop and geographic point.
For each newly accepted observation, alert every active farm with the affected crop whose point is within 10 km, including the boundary. Use the latest fully published farm revision no more than 60 seconds old when matching begins; otherwise retain the observation as pending.
Keep that revision fixed for the whole matching job. A farm change does not cause old observations to be matched again. Create one logical in-app alert per observation and farm, and attempt email separately. Show pending or uncertain delivery honestly; exactly-once external email is not assumed.
Design the data integration, matching, durable alert flow, farmer reads and failure recovery. Pest detection, biological recommendations, editing old observations and retroactive farm rematching are outside scope.
What to build
- Accept or recover immutable observations and publish only complete farm-catalog revisions.
- Find every eligible farm in one fixed catalog revision and create one traceable logical alert per observation and farm.
- Let farmers read their in-app alerts and inspect email delivery state, including pending and uncertain outcomes.
At scale
- For this exercise, assume 100,000 active farms and a peak of 10 new observations per minute; a dense observation may match many farms.
- For this exercise, aim to make in-app alerts visible within two minutes of acceptance while a fresh catalog and provisioned processing capacity are available; expose input or processing delay instead of dropping work.
- For this exercise, retain observations, alert identities, matching evidence and delivery history for 30 days.