Inspiration
I am a small farmer from Sri Lanka, and I have seen how difficult it can be for farmers to understand whether a crop season is truly profitable. Expenses such as fertilizer, labour, seeds, transport, and irrigation are often written in notebooks or remembered informally. This makes it difficult to see where money is being spent and to make better decisions for the next season.
I created FarmMate AI to provide a simple, mobile-friendly farm finance assistant that works in both English and Tamil.
What it does
FarmMate AI allows a farmer to:
- Create and manage separate crop seasons.
- Record income and expenses in Sri Lankan rupees.
- Organize records using clear farming categories.
- View total income, total expenses, and profit or loss instantly.
- Identify the largest expense category and its percentage of total costs.
- Generate practical AI insights in both English and Tamil.
- Switch languages without generating the insight again.
- Keep records and summaries usable even when AI is unavailable.
The app also protects privacy. Individual records, personal notes, and season names remain in the browser. Only the crop name and calculated category totals are sent to the AI service.
How I built it
I built the user interface with React, Vite, JavaScript, and plain CSS. The design is mobile-first, with large controls, readable text, deep green and warm cream colours, and support for both English and Tamil.
The browser stores crop seasons, financial records, language preferences, and saved insights using localStorage. Financial totals are calculated directly from the farmer's records without relying on AI.
A small Node.js and Express server handles AI requests. The browser sends a calculated summary to the server, and the server privately connects to the Gemini API. The API key remains in a local environment file and is never sent to the browser or committed to GitHub.
Gemini returns structured English and Tamil insights together. The server validates the response before returning it to the app. Each season has a revision number, so an insight is automatically marked outdated whenever its records change.
Challenges I faced
One challenge was keeping the AI key private while still allowing the browser to request insights. I solved this by separating the React interface from the Express server.
Another challenge was making AI results reliable in two languages. I used structured JSON output and validated that both English and Tamil versions were present.
I also had to handle failures safely. If the API key is missing, the internet connection fails, or Gemini returns an invalid response, the farmer's records remain safe and the Basic Summary continues to work.
Other challenges included accurate currency calculations, preventing duplicate AI requests, preserving form data when saving fails, and ensuring old insights are not shown as current after a record changes.
Accomplishments that I am proud of
- A working bilingual English and Tamil experience.
- Accurate financial calculations without depending on AI.
- Privacy-focused AI requests that exclude personal notes.
- Separate records and insights for each crop season.
- Clear outdated-insight warnings after financial changes.
- Mobile layouts tested at narrow phone widths.
- 84 automated tests covering calculations, storage, API validation, failures, and insight freshness.
- A public GitHub repository with source code, planning documents, tests, and setup instructions.
For the demonstration, a carrot season records LKR 45,000 in income and LKR 30,000 in expenses, producing an LKR 15,000 profit. Fertilizer is correctly identified as 66.7% of total expenses.
What I learned
I learned that AI should explain reliable calculations rather than replace them. FarmMate AI calculates financial results in the browser first and then asks Gemini to explain those results and provide practical suggestions.
I also learned how a React browser app communicates with an Express server, why secret API keys must stay on the server, how to validate structured AI output, and how automated testing helps make an application safer.
What's next for FarmMate AI
The next version could include more major languages, optional secure cloud backup, offline installation as a progressive web app, voice-assisted record entry, additional currencies, and testing with more farmers. I would also like to improve agricultural terminology for different regions while continuing to keep farmer data private.
Built With
- css3
- express.js
- geminiapi
- html5
- javascript
- localstorage
- node.js
- react
- vite
- vitest
Log in or sign up for Devpost to join the conversation.