# Climate Advisory System Configuration

# Application Settings
app:
  name: "AI Climate Advisory System"
  version: "1.0.0"
  environment: "development"  # development, staging, production
  debug: true
  base_url: "http://localhost:8000"  # Base URL for the application
  api_base_url: "http://localhost:8000/api/v1"  # Base URL for API endpoints

# Database Configuration
database:
  url: "sqlite:///./data/climate_advisory.db"
  # For PostgreSQL:
  # url: "postgresql://user:password@localhost:5432/climate_advisory"
  echo: false

# Data Sources Configuration
data_sources:
  # CHIRPS - Daily rainfall data
  chirps:
    base_url: "https://data.chc.ucsb.edu/products/CHIRPS-2.0"
    version: "daily"
    resolution: "0.05"
    cache_dir: "./data/raw/chirps"
    
  # ERA5 - Temperature and weather variables
  era5:
    base_url: "https://cds.climate.copernicus.eu"
    dataset: "reanalysis-era5-single-levels"
    variables:
      - "2m_temperature"
      - "2m_dewpoint_temperature"
      - "total_precipitation"
      - "evaporation"
    cache_dir: "./data/raw/era5"
    # Note: Requires CDS API key setup
    
  # MODIS - NDVI and land surface temperature
  modis:
    base_url: "https://e4ftl01.cr.usgs.gov"
    products:
      - "MOD13Q1"  # NDVI
      - "MOD11A2"  # LST
    cache_dir: "./data/raw/modis"
    # Note: Requires NASA Earthdata credentials
    
  # Sentinel-2 - Vegetation and crop stress
  sentinel2:
    base_url: "https://scihub.copernicus.eu/dhus"
    cache_dir: "./data/raw/sentinel2"
    # Note: Requires Copernicus Open Access Hub credentials
    
  # FAO Data
  fao:
    crop_calendar_url: "https://www.fao.org/faostat/en/#data"
    cache_dir: "./data/raw/fao"
  
  # Open-Meteo - Free weather API (no API key required!)
  openmeteo:
    base_url: "https://api.open-meteo.com/v1"
    cache_dir: "./data/raw/openmeteo"
    # No API key needed - completely free!

# Tanzania Districts Configuration
tanzania:
  # Key agricultural districts (can be expanded)
  districts:
    - name: "Arusha"
      lat: -3.3869
      lon: 36.6830
      region: "Arusha"
    - name: "Kilimanjaro"
      lat: -3.0674
      lon: 37.3556
      region: "Kilimanjaro"
    - name: "Morogoro"
      lat: -6.8240
      lon: 37.6608
      region: "Morogoro"
    - name: "Iringa"
      lat: -7.7700
      lon: 35.7000
      region: "Iringa"
    - name: "Mbeya"
      lat: -8.9000
      lon: 33.4500
      region: "Mbeya"
    - name: "Dodoma"
      lat: -6.1630
      lon: 35.7516
      region: "Dodoma"
    - name: "Tabora"
      lat: -5.0167
      lon: 32.8000
      region: "Tabora"
    - name: "Mwanza"
      lat: -2.5167
      lon: 32.9000
      region: "Mwanza"

# Crop Configuration
crops:
  maize:
    name_swahili: "Mahindi"
    planting_seasons:
      - start_month: 10  # October
        end_month: 12    # December
        name: "Masika"
      - start_month: 2   # February
        end_month: 4     # April
        name: "Vuli"
    growth_days: 90
    water_requirement_mm: 500
    critical_stages:
      - name: "Planting"
        days: [0, 7]
      - name: "Vegetative"
        days: [8, 45]
      - name: "Reproductive"
        days: [46, 75]
      - name: "Maturation"
        days: [76, 90]
        
  rice:
    name_swahili: "Mpunga"
    planting_seasons:
      - start_month: 11  # November
        end_month: 1     # January
        name: "Masika"
    growth_days: 120
    water_requirement_mm: 1000
    critical_stages:
      - name: "Planting"
        days: [0, 10]
      - name: "Vegetative"
        days: [11, 60]
      - name: "Reproductive"
        days: [61, 90]
      - name: "Maturation"
        days: [91, 120]
        
  beans:
    name_swahili: "Maharage"
    planting_seasons:
      - start_month: 10  # October
        end_month: 12    # December
        name: "Masika"
      - start_month: 2   # February
        end_month: 4     # April
        name: "Vuli"
    growth_days: 75
    water_requirement_mm: 400
    critical_stages:
      - name: "Planting"
        days: [0, 7]
      - name: "Vegetative"
        days: [8, 40]
      - name: "Reproductive"
        days: [41, 60]
      - name: "Maturation"
        days: [61, 75]
        
  sunflower:
    name_swahili: "Alizeti"
    planting_seasons:
      - start_month: 12  # December
        end_month: 2     # February
        name: "Masika"
    growth_days: 100
    water_requirement_mm: 450
    critical_stages:
      - name: "Planting"
        days: [0, 10]
      - name: "Vegetative"
        days: [11, 50]
      - name: "Reproductive"
        days: [51, 80]
      - name: "Maturation"
        days: [81, 100]

# ML Model Configuration
ml:
  # Rainfall forecasting
  rainfall_forecast:
    model_type: "prophet"  # or "arima"
    forecast_days: 14
    training_window_days: 365
    
  # Risk classification
  risk_classifier:
    model_type: "random_forest"
    features:
      - "rainfall_7d"
      - "rainfall_14d"
      - "rainfall_anomaly"
      - "ndvi_trend"
      - "soil_moisture_proxy"
    thresholds:
      dry_spell:
        consecutive_dry_days: 7
        rainfall_deficit_percent: 50
      flood_risk:
        rainfall_excess_percent: 200
        consecutive_wet_days: 5

# Decision Engine Configuration
decision_engine:
  # Rainfall thresholds (mm)
  rainfall_thresholds:
    very_low: 5
    low: 10
    moderate: 25
    high: 50
    very_high: 100
    
  # NDVI thresholds
  ndvi_thresholds:
    very_poor: 0.2
    poor: 0.3
    moderate: 0.5
    good: 0.7
    excellent: 0.8
    
  # Advisory confidence levels
  confidence_levels:
    high: 0.8
    medium: 0.6
    low: 0.4

# SMS Configuration
sms:
  provider: "twilio"  # or "africas_talking"
  twilio:
    account_sid: "your_account_sid"
    auth_token: "your_auth_token"
    from_number: "+1234567890"
  africas_talking:
    api_key: "your_api_key"
    username: "your_username"
    from_number: "CLIMATE"
  max_message_length: 160
  enable_swahili: true

# WhatsApp Configuration
whatsapp:
  enabled: false
  provider: "twilio"  # or "whatsapp_api"
  api_key: "your_api_key"
  from_number: "whatsapp:+1234567890"

# API Configuration
api:
  title: "Climate Advisory API"
  version: "1.0.0"
  docs_url: "/docs"
  base_url: "http://localhost:8000/api/v1"  # API base URL - change for production
  rate_limit:
    requests_per_minute: 60
  endpoints:
    health: "/health"
    advisory: "/advisory"
    advisory_custom: "/advisory/custom"
    advisory_batch: "/advisory/batch"
    advisory_get: "/advisory/{farmer_id}"
    farmers: "/farmers"
    farmers_get: "/farmers/{farmer_id}"
    districts: "/districts"
    districts_weather: "/districts/weather"
    data_latest: "/data/latest"
    data_sample: "/data/sample/{district_id}"
    forecast_short_term: "/forecast/short-term/{district_id}"
    forecast_year: "/forecast/year/{district_id}"
    climate_records: "/climate/records/{district_id}"
    auth_register: "/auth/register"
    auth_login: "/auth/login"
    requests_per_hour: 1000

# Logging Configuration
logging:
  level: "INFO"  # DEBUG, INFO, WARNING, ERROR
  file: "./logs/climate_advisory.log"
  max_bytes: 10485760  # 10MB
  backup_count: 5

# Scheduler Configuration
scheduler:
  # Data ingestion schedules (cron format)
  chirps_ingestion: "0 6 * * *"  # Daily at 6 AM
  era5_ingestion: "0 7 * * *"    # Daily at 7 AM
  modis_ingestion: "0 8 * * 0"   # Weekly on Sunday at 8 AM
  sentinel_ingestion: "0 9 * * 0"  # Weekly on Sunday at 9 AM
  advisory_generation: "0 10 * * *"  # Daily at 10 AM

