FarmSense AI - An intelligent farming companion
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.
