Agricultural weather intelligence for Kenyan farmers — live forecasts, AI-powered advisories, farm-image analysis, and English/Swahili support, built with Next.js and Google Gemini.
# AgriWeather
Agricultural weather intelligence for Kenyan farmers, built with Next.js 16,
Open-Meteo, and Google Gemini. The interface supports English and Swahili,
metric and imperial units, consent-based location fallback, weather advisories,
and farm-image analysis.
## Product Behavior
- Live current weather, seven-day forecast, and next-24-hour chart from
Open-Meteo.
- Browser geolocation is attempted first.
- If precise location fails, the user must explicitly consent before their IP
address is sent to `ipapi.co`.
- Declining IP lookup falls back to Nairobi while manual search remains
available.
- In `live` mode every visitor gets live Gemini advisories and farm-image
analysis, rate-limited per client IP.
- In `fixture` mode (used for local development without a key) AI requests
return clearly labelled, localized samples and spend no Gemini quota.
- Live Gemini failures are returned honestly; they are never disguised as
successful fixtures.
## Local Setup
Requirements:
- Node.js 20.9 or newer
- npm
```bash
cp .env.example .env.local
npm ci
npm run dev
```
Open . The committed example uses `AI_MODE=fixture`, so
the application works without a Gemini key.
Run the complete local gate after installing Playwright browsers:
```bash
npx playwright install chromium webkit
npm run validate
```
## Environment
| Variable | Required | Purpose |
| --- | --- | --- |
| `AI_MODE` | Yes | `fixture` or `live`. |
| `GEMINI_API_KEY` | In live mode | Server-only Google AI Studio key. |
| `GEMINI_MODEL` | No | Defaults to `gemini-3.5-flash`. |
| `AI_LIVE_DISABLED` | No | Emergency kill switch for live Gemini calls. |
| `OPEN_METEO_BASE_URL` | No | Forecast API base URL. |
| `GEOCODING_BASE_URL` | No | Geocoding API base URL. |
| `NEXT_PUBLIC_DEFAULT_LAT` | No | Nairobi fallback latitude. |
| `NEXT_PUBLIC_DEFAULT_LON` | No | Nairobi fallback longitude. |
Never commit `.env.local`, `.env.prod`, or the Gemini key; only `.env.example`
is tracked.
### AI Modes
| Mo …