AI News Hub Logo

AI News Hub

FarmSense AI - An intelligent farming companion

DEV Community
Prath

This is a submission for Weekend Challenge: Earth Day Edition Please comment if the api token is expired. I'll update it. Note: Most of the context is generated by AI reviewed by me. I think it did a pretty good job explaining, Thanks. FarmSense AI β€” an intelligent farming companion that gives small Farming is one of the largest contributors to climate change, yet small Three core AI modules: 🌿 Crop Doctor β€” Upload a photo or describe symptoms. Get disease diagnosis with severity rating and organic treatment recommendations first, chemicals only as a last resort. πŸ’§ Irrigation Advisor β€” Real-time weather (temperature, humidity, precipitation, wind) fetched from Open-Meteo and injected into every response. Get water requirements in liters per acre, optimal watering times, and drought/overwatering risk flags. πŸͺ± Soil Health Advisor β€” Soil assessment, region-specific cover crop recommendations, composting timelines, and 3-season crop rotation plans to restore soil carbon. What makes it different from just asking ChatGPT: πŸ“ Auto-detects GPS location silently on load, reverse-geocodes to city/region via OpenStreetMap β€” injected into every prompt automatically πŸ”” Proactive weather-aware alerts generated from your session history 7-day forecast, cached and refreshed every hour πŸ’° AI recommendations auto-parsed for expenses β†’ "βž• Log to Tracker" chips appear below messages β†’ one-click finance logging 🌾 Persistent multi-turn sessions per module with full conversation memory πŸ”— Live: https://radiant-axolotl-99d2d9.netlify.app/ Key flows to try: Allow location β†’ see "πŸ“ Your City" pill appear in chat header Go to Irrigation Advisor β†’ ask about your crop β†’ watch real-time weather data appear in the response Ask the AI to recommend fertilizer β†’ see "βž• Log to Tracker" chips appear below the message Check the πŸ”” bell icon on the dashboard β€” weather-based alerts generated automatically from your session / FarmSense-AI 🌱 FarmSense AI Your intelligent farming companion β€” powered by Gemini 2.5 Flash FarmSense AI is a full-stack precision agriculture assistant that gives small and mid-size farmers access to expert-level crop disease diagnosis, irrigation scheduling, soil health advice, financial tracking, and proactive weather-aware alerts β€” all in a conversational interface. πŸš€ What Makes It Different Feature FarmSense AI Generic AI Chatbot Location-aware by default βœ… Auto-detects GPS, injects region into every prompt ❌ User must describe location every time Real-time weather in responses βœ… Open-Meteo API injected into irrigation prompts ❌ No live data Proactive alerts βœ… AI scans sessions + 7-day forecast, pushes warnings ❌ Reactive only Finance loop βœ… AI recommends β†’ "Log to Tracker" chip β†’ expense logged ❌ Advice stays in chat Streaming responses βœ… Token-by-token SSE stream ❌ Full response wait Multi-module memory βœ… Persistent sessions per module per user ❌ Stateless Image diagnosis βœ… … View on GitHub The diagram above shows the full system. The browser layer handles Map entry holding full message history and Layer Tech Frontend Next.js 15, React 19, Zustand, Tailwind CSS Backend Express, TypeScript, Prisma, PostgreSQL AI Google Gemini 2.5 Flash via LangChain Weather Open-Meteo API (free, no key) Geocoding Nominatim / OpenStreetMap (free) Deploy Netlify (frontend) + Railway (backend + DB) 1. Location without asking Most farming apps ask "where are you?" on every session. FarmSense navigator.geolocation silently on app load, reverse-geocodes 2. SSE streaming to fix truncation The original implementation used model.invoke() with maxOutputTokens: 2048 β€” long irrigation schedules were getting cut model.stream() with SSE eliminated the 3. Finance loop β€” closing the adviceβ†’action gap After every AI reply, a background call to gemini-2.0-flash extracts /extract-items endpoint so it never pollutes 4. Proactive alerts without blocking Generating alerts for multiple sessions sequentially was causing 30–60 Promise.allSettled for parallel calls, 5. Why this matters for Earth Day Organic treatments recommended first β†’ less chemical runoff into soil and water Precision irrigation β†’ reduces water waste (agriculture uses 70% of global freshwater) Soil health + crop rotation β†’ carbon sequestration and reduced tillage emissions Region-specific cover crops β†’ biodiversity and natural pest control Finance tracker β†’ helps farmers measure ROI on sustainable practices, making green choices economically visible πŸ† Best Use of Google Gemini FarmSense AI uses Gemini Models as its core intelligence across Multi-turn conversational farming advice β€” full session history specialized system prompts per module streamed via SSE using LangChain's model.stream() Expense extraction β€” a lightweight background call to gemini-* after every AI reply, structured JSON output only, zero DB writes, never pollutes chat history Proactive alert generation β€” parallel Gemini calls per session with 7-day weather forecast context, strict JSON output with title/message/type/module fields, 1-hour in-memory cache Model selection is fully configurable via GEMINI_MODEL and GEMINI_FAST_MODEL Built for Earth Day 2026 β€” because every farmer deserves a precision agriculture advisor in their pocket, and because sustainable farming at scale is one of the most impactful levers we have against climate change.