Skip to content
Thanatos9404Public

Latest commit

 

History

85 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Krishyak: Field Intelligence

An India-first farm decision-support app: private field records, crop-photo checks, satellite views, local weather, mandi prices, government scheme information, planning, voice and 22 Indian languages, built to work on low-end phones and patchy networks.

Live: krishyak.vercel.app (farmer workspace at /app/today, scenario planning at /app/more/planning).

Start here: Technical design document · Sample data and test cases · Demo farm, no sign-in · License: Apache-2.0

Release status, 10 October 2026: PR #1 and PR #2 are merged into main, which deploys production automatically. Farmer accounts are enabled in production on Neon Postgres + PostGIS, Upstash Redis and private Vercel Blob storage, with passkey sign-in. A live browser journey (sign-up, weather, photo check, satellite job, market, account deletion) passed against production. Field validation with farmers, native-language review and agronomist review have not happened yet; see known limitations.

What farmers get

  • Sign-in without SMS. Passkeys use the phone's fingerprint or screen lock; a one-time recovery code (shown once) covers a lost phone, and a family member's phone can be added. An optional mobile number is stored unverified.
  • Today. Plain weather conclusions for the field (rain, heat, wind and what they mean for spraying or irrigation), the current crop's nearest mandi price against MSP, and next steps. Weather refreshes itself; a field needs only a GPS point (rounded to about 1 km), not a drawn boundary.
  • Farm records. Farms, fields, crop cycles, observations and soil readings with an account export and deletion. Area in acres, hectares, bigha (size confirmed by the farmer), guntha, kanal or cent.
  • Check a sick plant. A photo of one leaf gives a likely cause, first non-chemical steps and the free Kisan Call Centre number (1800-180-1551). Photos are resized on the phone and stored privately.
  • Satellite view. "Greener" or "drier" than the last clear Sentinel-2 view; NDVI/NDMI/NDRE and band details stay under technical details.
  • Mandi prices. AGMARKNET prices per market with week-on-week change computed only from dated quotes of the same market, variety and grade.
  • Schemes and planning. Official scheme information (no eligibility claims) and the scenario simulator.
  • Languages and voice. English plus all 22 scheduled Indian languages, right-to-left for Urdu, Kashmiri and Sindhi. Consented voice input works in every scheduled language (browser engine as fallback); read-aloud uses a device voice or one of the 11 languages with a server voice.
  • Offline. Optional owner-scoped snapshots and a queued notes outbox that syncs on reconnection.

Permissions (location, analysis, satellite, speech) are asked in context with a reason and can be withdrawn in Settings.

How it is built

  • Frontend: Next.js 16 (App Router, React 19) on Vercel. The middleware forwards API calls same-origin with a two-minute HMAC-signed client address.
  • API: FastAPI on Vercel (region sin1) with SQLAlchemy/PostGIS, Alembic migrations (v2_0001–v2_0010), opaque hashed sessions, CSRF and Origin binding, and WebAuthn passkeys.
  • Jobs: a durable Postgres queue drained inside requests and by a daily Vercel Cron call (CRON_SECRET); a dedicated worker process is also supported.
  • Providers: Copernicus Data Space (Sentinel-2), Open-Meteo, data.gov.in AGMARKNET, Sarvam (speech and translation) and a LiteRT disease classifier. Every provider credential is budgeted in Redis per caller, per day and, where metered, per month; budgets fail closed.

See architecture, API, security and deployment.

Evidence boundaries

The disease model is publisher-efficientnet-colab-v1 (EfficientNetV2B0, 38 classes, 14 crops): 94.39% validation, 93.71% internal test and 57.21% on the external PlantDoc set (n=229). It abstains below 0.75 confidence or on a crop mismatch; on the internal test it answers 88.7% of photos at 98.5% accuracy, and on PlantDoc it cuts confident wrong answers from 42.8 to 5.2 per 100 photos. It has not been validated on Indian farm photos, so results are presented as a first opinion with expert confirmation. Disease care steps and weather advice are conservative drafts without product names or doses and need agronomist review. Satellite indices cannot diagnose disease, nutrients, yield or irrigation needs. Planning economics are assumptions and uncertainty estimates, not guarantees.

Live-verified on 9–10 October 2026: Copernicus, Sarvam, Open-Meteo, private Blob storage, Neon and Upstash. data.gov.in's API host refused connections throughout, so live mandi data is unverified; the market screen says so and serves stored prices marked stale when available.

Run locally

Use Python 3.12, Node 22+ and Docker Desktop. Install backend/requirements-dev.txt in a venv and run npm ci in frontend. Full configuration is in deployment.

docker compose -p krishyak-v2 --env-file .codex-tmp/v2-local.env -f docker-compose.v2.yml up -d
python scripts/run_v2_local.py migrate
python scripts/run_v2_local.py api
# Separate terminals:
python scripts/run_v2_local.py worker
cd frontend
npm run build
npm start

Local development may use synthetic test mobiles with code 123456 (no SMS is sent); deployments reject that configuration. Never commit env files, photos, tokens or backups.

Environment variables

Copy backend/.env.example to an ignored .env (every variable is documented there) and frontend/.env.example to frontend/.env.local. The ones that matter most:

Variable Where Required Purpose
SECRET_KEY API yes Signing key for legacy endpoints
CORS_ORIGINS API yes Exact frontend origins; also the passkey relying parties
KRISHYAK_V2_ENABLED API for accounts Turns on the v2 farmer workspace
V2_DATABASE_URL (or DATABASE_URL) API for accounts PostgreSQL + PostGIS
V2_REDIS_URL (or KV_URL / REDIS_URL) API for accounts Usage budgets and rate limits
V2_AUTH_SECRET API for accounts Session secret, 32+ random characters
V2_STORAGE_PROVIDER, BLOB_READ_WRITE_TOKEN API for photos local, s3 or vercel_blob private photo storage
CRON_SECRET, V2_WORKER_MODE API for jobs Daily worker call and worker mode (request or dedicated)
KRISHYAK_PROXY_SECRET API and frontend recommended HMAC key for the signed client header
REMOTE_SENSING_ENABLED, CDSE_CLIENT_ID, CDSE_CLIENT_SECRET API optional Copernicus Sentinel-2 satellite evidence
SARVAM_API_KEY API optional Voice input and read-aloud
DATA_GOV_IN_API_KEY API optional AGMARKNET mandi prices
KRISHYAK_API_ORIGIN frontend yes in production Where src/proxy.js forwards /api/v2 and /api/public

Without the optional keys the app still runs; the matching screens say the source is unavailable instead of inventing data. Production settings are in deployment.

Verify and operate

  • python -m unittest discover in backend/ (PostGIS integration tests need V2_TEST_DATABASE_URL), npm test, npm run build and npm run test:e2e in frontend/ (Chromium, Firefox, WebKit and a Pixel 7 profile).
  • CI runs the same with disposable PostGIS and Redis, plus migrations, Bandit, pip-audit, npm audit and a container classifier smoke.
  • Live checks against a deployment: scripts/smoke_staging.py and V2_E2E_STAGING=true npx playwright test e2e/staging.spec.js --project=chromium.
  • /health/live is liveness; /health/ready checks the schema head, PostGIS, Redis and the worker (heartbeat, or no stranded jobs in request mode).

Documentation

License

Krishyak is open source under the Apache License 2.0. See NOTICE for attribution and third-party data and font licences.

Public app · Repository

Releases

Packages

Contributors

Languages