# FarmAlert — SMS Market Price Alerts for Kenyan Farmers
FarmAlert is a Python system that collects crop market prices from the WFP VAM API, detects price movements, and dispatches personalised SMS alerts to subscribed smallholder farmers via Africa's Talking.
---
## Architecture
```
┌─────────────────────────────────────────────────────────────────┐
│ FarmAlert System │
│ │
│ ┌──────────────┐ prices ┌──────────────────────────────┐ │
│ │ WFP VAM API │──────────▶│ data_collector.py │ │
│ │ (external) │ │ fetch_and_store_all_prices() │ │
│ └──────────────┘ └──────────────┬───────────────┘ │
│ │ writes │
│ ▼ │
│ ┌──────────────┐ SMS ┌─────────────────────────────┐ │
│ │ Africa's │◀──────────│ message_builder.py │ │
│ │ Talking API │ │ build_alert_message() │ │
│ │ (external) │ │ dispatch_alerts() │ │
│ └──────────────┘ └──────────────▲──────────────┘ │
│ │ reads │
│ ┌─────────────────┴──────────────┐ │
│ ┌──────────────┐ R/W │ models.py (SQLite / SQLAlch.) │ │
│ │ app.py │◀──────▶│ Farmer · FarmerCrop │ │
│ │ Flask API │ │ MarketPrice · AlertLog │ │
│ └──────────────┘ └────────────────────────────────┘ │
│ ▲ ▲ │
│ HTTP │ │ reads │
│ ┌──────┴───────┐ ┌──────────┴─────────┐ │
│ │ Farmer │ │ scheduler.py │ │
│ │ (registers │ │ APScheduler jobs │ │
│ │ via SMS) │ …