(02/02)

Farm-planning web app, NASA Space Apps · 2026

SoilSight

Draw a field, pull NASA climate data, and compare three crop rotations side by side.

Role
Team lead. Map and planner UI, data and server, tests and CI
Timeline
NASA Space Apps Challenge 2026
Team
Team of 5
Stack
TypeScript, React, Vite, Leaflet, Zustand, Tailwind, Vitest, Playwright
SoilSight field overview: a farm workspace with rainfall, temperature, risk months and topsoil pH for one field

Results

Results

  • 44

    Calculation and data tests

    As of 13 Nov 2026. SoilSight demo deck, slide 12.

  • 8

    Browser journeys tested end to end

    As of 13 Nov 2026. SoilSight demo deck, slide 12.

  • 3

    Crop rotations compared per field

    As of 13 Nov 2026. Repo README.

Story

Context

NASA Space Apps is a global hackathon built on NASA’s open data. In 2026 I led a team of five from NST, NED.

Problem

Farmers plan crop rotations from habit and guesswork, while NASA publishes years of climate and soil-moisture data for free. We wanted to put that data behind a map a farmer can actually use, without ever passing off a guess as a measurement.

What I built

A farm-planning prototype for the NASA Space Apps Challenge. You draw a field on a map, load NASA POWER climate data for it, and compare three crop rotations: your current one, a soil-first plan and a water-saver plan.

  • Six priority sliders re-rank the plans live and show what each score is made of.
  • A twelve-month climate-risk calendar and monthly irrigation estimates.
  • Soil estimates from ISRIC SoilGrids, with clear labels when it falls back to example data.
  • Urdu navigation and crop names, with a right-to-left layout.
  • Earthdata credentials stay on a small server, never in the browser bundle.
  • Lint, unit tests and Playwright browser tests run in GitHub Actions on every push.

Demo data is always labelled as synthetic. A failed request never shows demo numbers as real NASA data.

What I’d do differently

The public data runs in the browser, but the NASA Earthdata products (SMAP soil moisture, GPM rainfall) needed a server we only finished the skeleton of. Next time I’d build that server path first, because it holds the most useful data. I’d also keep the live demo deployed after judging. Right now the link is down.

Inside the code

Four moments from the real source Repo ↗

cropScoring.ts
// src/lib/cropScoring.ts
export function normalizedWeights(priorities: FarmerPriorities): FarmerPriorities {
  const clean = Object.fromEntries(
    PRIORITY_KEYS.map((k) => [k, Number.isFinite(priorities[k]) ? clamp(priorities[k]) : 0]),
  ) as unknown as FarmerPriorities
  const sum = Object.values(clean).reduce((a, b) => a + b, 0)
  return Object.fromEntries(
    PRIORITY_KEYS.map((k) => [k, sum ? clean[k] / sum : 1 / PRIORITY_KEYS.length]),
  ) as unknown as FarmerPriorities
}
export function rankStrategies(
  strategies: RotationStrategy[],
  priorities: FarmerPriorities,
): RotationStrategy[] {
  const weights = normalizedWeights(priorities)
  return strategies
    .map((s) => ({
      ...s,
      scores: {
        ...s.scores,
        overall: round(PRIORITY_KEYS.reduce((sum, k) => sum + s.scores[k] * weights[k], 0)),
      },
    }))
    .sort((a, b) => b.scores.overall - a.scores.overall || a.type.localeCompare(b.type))
}
export function applyClimateStress(
  strategies: RotationStrategy[],
  nasa: NASAClimateData,
  scenario: ClimateScenario,
  soil: SoilData | null,
  priorities: FarmerPriorities,
): RotationStrategy[] {
  const stressed = stressClimate(nasa, scenario.tempDelta, scenario.rainfallDelta)
  // Hold crops and planting windows fixed so before/after comparisons measure climate sensitivity.
  return rankStrategies(
    strategies.map((s) => {
      const result = evaluate(s.type, s.crops, stressed, soil)

// tests/planning.test.ts
it('uses equal weights for all-zero priorities', () => {
  const weights = normalizedWeights(
    Object.fromEntries(PRIORITY_KEYS.map((k) => [k, 0])) as unknown as typeof DEFAULT_PRIORITIES,
  )
  expect(Object.values(weights).every((x) => x === 1 / 6)).toBe(true)
})
  1. 01 · cropScoring.ts · lines 11–24

    The entry point

    Every plan gets one overall score: each of its six sub-scores times the farmer's weight for it. Ties sort by name, so the order never flickers between renders.

  2. 02 · cropScoring.ts · lines 2–10

    The tricky part

    Six sliders never add up to 100, and a cleared slider can be NaN. So weights are clamped, then divided by their sum. If every slider is zero, each gets an equal 1/6 instead of a divide by zero.

  3. 03 · cropScoring.ts · lines 34–37

    The fix

    If the stress test re-picked crops for the hotter, drier climate, before and after would compare two different plans. So it holds crops and planting windows fixed, and only the climate changes.

  4. 04 · planning.test.ts · lines 40–45

    The test

    The edge case gets its own test: all six sliders at zero must give six equal weights of exactly 1/6.

Architecture

Public data in the browser, secrets on a server

The browser app (React, Leaflet, a Zustand store and the scoring library) calls NASA POWER, ISRIC SoilGrids and OpenStreetMap directly. NASA Earthdata products go through a small server that holds the login token, so no secret ever ships in the browser bundle.Browser appReact · Leaflet mapZustand storeScoring + irrigation (pure TS)Vitest · PlaywrightNASA POWER climateISRIC SoilGridsOSM · Nominatim · GIBS/api serverholds the tokenNASA EarthdataSMAP · GPM · server onlysecrets never cross this line

Gallery