Engineering KhetiSetu: Offline-First Farmland Rental in Rural India
Knowledge Hub
Technology

Engineering KhetiSetu: Offline-First Farmland Rental in Rural India

Building a marketplace for urban users is a solved problem. You throw a React frontend on a CDN, use a standard CMS, and assume everyone has a 5G connection or

KhetiSetu Agronomy Research Team
Nov 13, 2026
6 min read
11,112 views

Share this guide

Help more farmers discover useful tools

Save Time

Instant access

More Benefits

Apply for schemes

Better Decisions

Real-time data

Transparent & Safe

Official platforms

Building a marketplace for urban users is a solved problem. You throw a React frontend on a CDN, use a standard CMS, and assume everyone has a 5G connection or stable fiber. But when you are building for a farmer in a village outside Bhatinda or a smallholder in rural Karnataka, those assumptions break immediately.

In these regions, "4G" is often a polite fiction. You are dealing with high latency, frequent packet loss, and devices with limited storage. When we started building the farmland rental marketplace at KhetiSetu, we realized that a standard Next.js implementation would fail the moment a user moved 500 meters away from a cell tower.

The engineering challenge wasn't just about matching owners with tenants; it was about ensuring a listing could be uploaded and viewed on a 50kbps connection without the browser timing out.

The Bandwidth Paradox: Performance as Accessibility

In rural tech, performance isn't a luxury; it’s the baseline for accessibility. If a page takes 10 seconds to load, the user assumes the service is broken. We had to move away from heavy client-side hydration and embrace a strategy that prioritizes the "Time to Content."

Our architecture relies heavily on Next.js’s Incremental Static Regeneration (ISR). For land listings—which don't change by the second—we pre-render pages at the edge. However, the real hurdle is the "Listing Creation" flow. A farmer needs to upload 4-5 high-resolution photos of their soil and irrigation setup. On a spotty connection, a 15MB upload will fail 9 times out of 10.

We solved this by implementing a client-side compression pipeline before the data even hits the network.

// A simplified version of our client-side image processor
async function processFarmImage(file) {
  const options = {
    maxWidthOrHeight: 1200,
    useWebWorker: true,
    initialQuality: 0.6,
  };

  try {
    // We use browser-image-compression to shrink the file locally
    const compressedFile = await imageCompression(file, options);
    
    // We generate a tiny BlurHash for the loading state
    const blurDataURL = await generateBlurHash(compressedFile);
    
    return {
      file: compressedFile,
      preview: blurDataURL
    };
  } catch (error) {
    console.error("Compression failed, falling back to original", error);
    return { file, preview: null };
  }
}

By shifting the heavy lifting to the user’s device (which is often more powerful than the network it's connected to), we reduced our average payload size by 85% without sacrificing the visual clarity needed to judge land quality.

Designing for Intermittent Connectivity

A farmer might start listing their land while in the field but lose signal before hitting "Submit." If the page refreshes and they lose their data, they won't try again. We treat the local device as the primary source of truth using an "Offline-First" sync pattern.

We use IndexedDB via the Dexie.js wrapper to persist form state. This ensures that even if the browser is closed or the phone reboots, the progress remains.

The Sync Lifecycle

| State | Action | UI Feedback | | :--- | :--- | :--- | | Draft | Saved to IndexedDB | "Saved locally" icon | | Pending | Network request initiated | "Syncing when online..." | | Retrying | Exponential backoff on 5xx or timeout | "Weak signal, retrying..." | | Synced | Confirmed by KhetiSetu API | "Listed Successfully" |

This lifecycle is managed by a background Service Worker. When the browser detects the onLine event, it triggers a sync of any records sitting in the "Pending" store. This allows the user to click "Submit" while offline and put their phone back in their pocket, knowing the platform will handle the rest once they reach the village square.

Localized State and Vernacular Routing

Language is the other major barrier. A marketplace for India cannot be English-only. While Next.js provides built-in i18n support, we had to optimize it for low-memory devices. Loading a massive JSON translation file for five different languages is a waste of resources.

We split our translation bundles by page and use a custom hook to fetch only the required strings. Furthermore, we found that "Transliteration" is often more useful than pure translation. Many farmers use a mix of local dialect and English technical terms (e.g., "Borewell," "Registry," "Lease").

At KhetiSetu, we built a glossary that maps these terms to ensure that a search for "Pani" or "Water" yields the same irrigation-related results, regardless of the user's primary language setting.

The Infrastructure: Edge over Origin

To keep latency low, we can't afford a round-trip to a central server in Mumbai for every request coming from Bihar. We utilize a multi-layered caching strategy:

  1. Edge Caching: Static assets and ISR pages are cached at edge nodes closest to the user.
  2. Stale-While-Revalidate: We serve the cached version of a land listing immediately while fetching the update in the background.
  3. Regional Data Sharding: While our primary DB is centralized for consistency, we use read-replicas to speed up regional queries.

The following Mermaid diagram illustrates how we handle a listing request in a low-bandwidth scenario:

sequenceDiagram
    participant U as Farmer Device
    participant SW as Service Worker
    participant E as Edge Node (Next.js)
    participant API as KhetiSetu Backend

    U->>SW: Request Listing Page
    SW->>SW: Check Cache (IndexedDB)
    alt Is Cached?
        SW-->>U: Return Stale Content (Immediate)
    else Not Cached
        SW->>E: Fetch via Edge
        E-->>SW: Return Compressed HTML/JS
        SW-->>U: Render Page
    end
    SW->>API: Background Revalidate (if online)
    API-->>SW: New Data
    SW->>U: Update UI silently

Lessons from the Field

If you are building for the next billion users, you have to unlearn the "Move Fast and Break Things" mentality. In rural India, if you break the user's trust with a broken form or a lost listing, they won't come back.

We spent weeks testing our marketplace on old Redmi phones and 3G dongles. We learned that:

  • SVG over PNG: Every kilobyte counts. We use inline SVGs for icons to avoid extra HTTP requests.
  • System Fonts: Don't load Google Fonts. Use the device's native sans-serif stack. It's faster and supports regional glyphs better.
  • Optimistic UI: When a user likes a listing or saves a search, update the UI instantly. Don't wait for the server's 200 OK.

Building the land rental marketplace at KhetiSetu taught us that the best "feature" you can give a rural user is a fast, reliable experience that respects their data plan and their time. By focusing on offline-first persistence and aggressive asset optimization, we’ve built a bridge between traditional land-holding and the modern digital economy.

Direct Kisan Mandi

Sell or Source Direct from Verified Farmers

Connect with verified buyers and sellers across Indian mandis with zero brokerage on KhetiSetu Marketplace.

Explore Marketplace
K

Written by KhetiSetu Agronomy Research Team

Empowering Indian farmers with scientific agronomy, ICAR guidelines, and transparent digital tools.