AI-Powered Agriculture Platform
KhetiAI started from a simple observation: farmers in my area struggled with crop diseases but had no quick way to identify or treat them. Having helped farmers at my family's agriculture shop, I saw this problem firsthand.
So in June 2025, I started building KhetiAI - a mobile app that uses AI to detect crop diseases instantly. But it became more than that. Farmers also needed help managing budgets, finding equipment to rent, checking weather, and planning their tasks. So we built all of that into one platform.
I led a team of 7 people from different countries to build this. The app uses Google's **Gemini 2.5 Flash** AI model, which analyzes crop photos and tells farmers exactly what's wrong and how to fix it. We also added a marketplace where farmers can rent tractors and equipment, a budget tracker, weather forecasts, and a task scheduler.
Snap a photo of your crop. Our AI tells you the plant type, what disease it has, how severe it is, and exactly what treatment to use
Ask the AI anything about farming, soil health, fertilizer ratios, or market prices in your local language. Get instant, reliable answers.
Track your income and expenses daily, monthly, or yearly. See where your money goes and plan better
Need a tractor or harvester? Browse local listings to buy or rent farming equipment
Get real-time weather data - temperature, humidity, wind speed. Plan your farming activities accordingly
Set reminders for watering, fertilizing, harvesting. Never miss an important farming task
I built a **Cloudflare Worker** to handle the AI requests. The tricky part was handling rate limits from Google's API. Here's how I implemented **retry logic with exponential backoff**:
let apiResponse;
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
try {
const response = await fetch(apiUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
if (response.ok) {
apiResponse = await response.json();
break;
}
if (response.status === 429 || response.status >= 500) {
if (attempt < MAX_RETRIES - 1) {
const delay = getExponentialBackoffDelay(attempt);
await new Promise(resolve => setTimeout(resolve, delay));
continue;
}
}
} catch (networkError) {
if (attempt < MAX_RETRIES - 1) {
const delay = getExponentialBackoffDelay(attempt);
await new Promise(resolve => setTimeout(resolve, delay));
continue;
}
throw networkError;
}
}
The AI needs to return consistent data every time. I enforce this using a **JSON schema** that guarantees we always get plant type, disease name, severity, and treatment steps:
const responseSchema = {
type: "OBJECT",
properties: {
"plant_type": {
"type": "STRING",
"description": "Type of plant (e.g., 'Tomato', 'Rose')"
},
"disease_name": {
"type": "STRING",
"description": "Disease name or 'Healthy'"
},
"severity": {
"type": "STRING",
"description": "'Low', 'Medium', or 'High'"
},
"treatment_steps": {
"type": "ARRAY",
"items": { "type": "STRING" }
}
},
required: ["plant_type", "disease_name", "severity", "treatment_steps"]
};
Here's how the disease detection works from start to finish:
Full walkthrough showing disease detection, marketplace browsing, weather updates, and budget management
AI Fertilizer Recommendations: Tell farmers which fertilizers to use based on their soil and crops
Government Form Automation: Auto-fill subsidy forms for farmers so they don't have to deal with paperwork
Agriculture News: Daily updates on farming policies, weather alerts, and market prices
More Languages: Add support for regional Indian languages beyond English and Hindi
Offline Mode: Let farmers use basic features even without internet