Skip to content
LancekyPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Reverse Drought Engine

The Reverse Drought Engine is a Kenyan drought decision-support MVP that combines Conduit weather data, local drought signatures, Machakos climate analogues, resource-aware recommendations, trusted delivery, and a three-view demo dashboard.

Local development

  1. Copy .env.example to .env. Leave RDE_DATA_SOURCE=fixture until the authenticated Conduit endpoint and field contract are confirmed.

  2. Create a backend environment and install its dependencies:

    python3 -m venv .venv
    . .venv/bin/activate
    python -m pip install -e 'backend[dev]'
  3. Start the API from the repository root:

    uvicorn app.main:app --app-dir backend --reload
  4. In another terminal, install and start the frontend:

    cd frontend
    npm install
    npm run dev

For the reproducible deployment path, build the two-container stack instead:

docker compose up --build

Open http://localhost:8080; the frontend proxies API calls to the healthy backend container. The compose stack defaults to the normal fixture profile. Set RDE_DATA_SOURCE=recorded before docker compose up --build to replay the checked-in Conduit-shaped response at backend/app/data/conduit_recorded_normal.json, or set it to conduit only after the authenticated API contract is confirmed.

The API health check is available at http://localhost:8000/healthz. The normalized fixture reading is available at http://localhost:8000/api/v1/readings/current. The complete data-to-impact chain is available at http://localhost:8000/api/v1/pipeline/current.

Demo API

  • GET /api/v1/pipeline/current runs the live/fixture reading through ET0, water-deficit, Mode 1, Mode 2, feasibility, delivery, and trust services. Query parameters include resource_tier, land_size_ha, distance_to_water_km, channel, and language.
  • POST /api/v1/pipeline/what-if accepts overrides for rainfall, temperature, humidity, wind, or solar values and recalculates in memory without writing to the source.
  • GET /api/v1/explanation/current returns the same complete response for the Why view, including assumptions, evidence URLs, and warnings.
  • GET /api/v1/trust/summary and GET /api/v1/trust/records expose the visible recommendation track record. The seeded records are explicitly illustrative and should be replaced with farmer confirmations or follow-up satellite evidence.

The browser UI provides Now, Why, and What-if views. The default fixture profiles (dry, normal, and wet) make the demo reproducible without a live station.

To print a deterministic recorded-response pipeline result without starting containers:

PYTHONPATH=backend .venv/bin/python scripts/replay_recorded_demo.py

The replay source preserves the captured timestamp, so the response can correctly report stale data when the configured freshness window is exceeded.

Deploying to Render and Vercel

The repository includes a Render Blueprint for the FastAPI backend at render.yaml and a Vercel configuration for the frontend at frontend/vercel.json.

  1. In Render, create a Blueprint from this repository. Render will detect render.yaml, build deploy/backend.Dockerfile, and expose the API health check at /healthz. The Blueprint uses the normal fixture profile for a reproducible demo.
  2. Copy the deployed Render service URL, for example https://reverse-drought-engine-api.onrender.com.
  3. In Vercel, import the repository and set Root Directory to frontend. Vercel will use the Vite build configuration. Add VITE_API_BASE_URL with the Render service URL, then deploy.
  4. Open the Vercel URL. The browser calls the Render API for /healthz, /api/v1/pipeline/current, and the What-if endpoint.

The Render Blueprint allows all origins for the public hackathon demo (RDE_CORS_ORIGINS=["*"]). Restrict that variable to the final Vercel URL before using the service beyond a demo. Live Conduit mode remains opt-in and requires the confirmed endpoint and credentials to be added as Render environment variables.

Calculation assumptions

The ET0 implementation is a deterministic Hargreaves-style approximation. It uses a configurable extraterrestrial-radiation proxy and treats SI1145 visible irradiance as a relative multiplier until Conduit units are confirmed. Rainfall is reduced by a configurable effective-infiltration factor; maize Kc, rolling-window length, rainfall baseline, soil-water buffer, and analogue thresholds are environment-backed settings. Every response includes these assumptions and any missing/stale-field warnings.

Conduit configuration

The public Conduit station page documents field labels but does not publish the authenticated API endpoint, historical range, or request limits. Configure RDE_CONDUIT_CURRENT_ENDPOINT and the appropriate auth variables only after those details are confirmed. The adapter supports none, api_key, bearer, and basic transport authentication; it does not pretend that the public HTML login form is an API session.

See docs/conduit.md for the confirmed fields, normalization rules, and explicitly unresolved integration questions.

See docs/demo-rehearsal.md for the three-minute presentation flow and the validation checklist used before showing the demo.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages