All work

Offline-first systems / Case study

AgriSignal

Deliver farm advisories over short multilingual SMS.

Type
Open-source engineering
Release
v1.0.0
Stack
Python 3.12 · FastAPI · Pydantic v2 · HLC / LWW Sync
Automated tests
64

System architecture

  1. Explainable Crop Advisory & Uncertainty Engine (agrisignal/advisory/engine.py)
  2. Pest & Disease IPM Early-Warning Matrix (agrisignal/advisory/pest_risk.py)
  3. HLC Offline Sync & Multilingual SMS Formatter
Three layers from the project’s architecture blueprint

01 / Problem

Why it exists

Smallholder farmers and rural extension officers operate in environments with intermittent 2G/3G connectivity, missing soil sensors, and multilingual communication needs—where black-box yield predictions without uncertainty bounds can lead to costly planting mistakes.

02 / Design

How it works

Queue field records locally with Hybrid Logical Clocks and SHA-256 hashes for commutative LWW sync, and compute explicit data-completeness and confidence bounds on every recommendation.

  1. Explainable Crop Advisory & Uncertainty Engine (agrisignal/advisory/engine.py)

    Evaluates rainfall, soil moisture, pH, and growth stage across maize, robusta coffee, beans, cassava, matooke banana, and groundnuts with explicit confidence intervals.

  2. Pest & Disease IPM Early-Warning Matrix (agrisignal/advisory/pest_risk.py)

    Assesses environmental preconditions for Fall Armyworm, Coffee Berry Borer/Wilt, Cassava Mosaic, Bean Anthracnose, and Banana Bacterial Wilt.

  3. HLC Offline Sync & Multilingual SMS Formatter

    Synchronizes partitioned field records deterministically and formats <=160-char advisories in English, Luganda, and Swahili.

HLC LWW-Element-Set Outbox & Explicit Uncertainty Reporting
Context
Rural field tablets frequently lose connectivity for days, and smallholder plots rarely have complete laboratory soil telemetry.
Decision
Queue field records locally with Hybrid Logical Clocks and SHA-256 hashes for commutative LWW sync, and compute explicit data-completeness and confidence bounds on every recommendation.
Trade-offs
Requires deterministic tie-breaking on HLC node IDs, but operates with zero data loss across multi-day offline partitions.
Verification
Verified across 64 parametrized pytest tests in tests/test_agrisignal.py and tests/test_server_hardening.py.
Security and operational constraints
  • SHA-256 content hash verification on every synced field observation envelope blocks corrupted or tampered payloads.
  • Explicit epistemic disclaimers prevent unvalidated diagnostic or yield guarantees.
  • Idempotency keys prevent duplicate observation ingestion during flaky 2G retry loops.
  • Every advisory includes an explicit UncertaintyBounds object; missing optional sensors deterministically widen the confidence interval.
  • Every formatted SMS advisory is strictly <= 160 characters across all languages and crop stages.
  • Tampered observation payloads failing SHA-256 digest verification are rejected by CentralSyncHub.

03 / Evidence

How to verify it

Repository-reported / Multilingual SMS & Sync Guarantee

≤160 Chars (en, lg, sw) · 64 Tests

100% deterministic LWW conflict resolution across 20 offline records and 3 rural devices

Reproduce from the command line
git clone https://github.com/codesphere-u/agrisignal.git
cd agrisignal && pytest -v
python -m agrisignal.cli advise --crop maize --zone lake_victoria_crescent --rain-14d 85 --lang lg
Next case study · Digital health Clinical Virtual Health Platform Coordinate virtual appointments across web, mobile, and video.