Inspiration
India has 140 million farmers, yet most sell their crops at the nearest local mandi without knowing whether a market 20 km away would give them ₹500 more per quintal. That information gap costs farmers thousands of rupees every harvest. We wanted to fix that with AI — and make it accessible in the farmer's own language, on any device, through a simple web interface.
What it does
Mandi Mitra is a multilingual AI web app that tells farmers exactly which mandi (agricultural market) to sell their crop at, for the highest price. A farmer opens the app, types a question in Hindi, Tamil, Marathi, Bengali, Punjabi, Telugu, Hinglish, or English — and instantly gets the best mandi name, predicted price per quintal, and estimated profit for their quantity.
Supported crops: Tomato, Onion, Potato, Wheat Supported languages: 8 Indian languages and scripts
How we built it
We built the full stack using Databricks and Python:
Frontend: A Gradio web app (app.py) with a fully translated UI — every label, placeholder, button and example question switches language dynamically when the farmer changes the language dropdown. Runs on port 8000.
LLM layer: We use Llama 4 Maverick via Databricks Model Serving, called through the Databricks SDK (WorkspaceClient). Three separate LLM calls handle: (1) translating the district name from any Indian script to English, (2) extracting crop and district as structured JSON from the free-form query, and (3) generating the final reply in the farmer's native language and script.
Data layer: Mandi price data is served from a pre-aggregated mandi_data.json file — no live database connection needed at runtime. The app filters by crop and district, ranks mandis by average price, and calculates net return as (avg_price × quintals) − ₹250 transport cost.
Offline training pipeline (Databricks): The mandi data was originally built on Databricks using Apache Spark and Delta Lake (Medallion Architecture: Bronze → Silver → Gold). A Random Forest Regressor trained with Spark MLlib predicts modal prices per mandi. All experiments tracked with MLflow. The Gold table was exported to mandi_data.json for use in the live app.
Challenges we faced
- Getting Llama 4 to reliably output valid JSON for intent extraction required careful prompt engineering and stripping of markdown code fences
- Supporting 8 Indian scripts (Devanagari, Tamil, Telugu, Bengali, Gurmukhi, Latin) in both input and output required thorough multilingual testing
- Translating every UI element (labels, placeholders, buttons, examples) dynamically in Gradio required careful state management across multiple
gr.change()handlers - Decoupling Mandi Mitra from a live Databricks SQL connection so it can run anywhere, not just inside a workspace
What we learned
- How to build a production Gradio app powered by a Databricks LLM endpoint using the Databricks SDK
- How to combine a one-time offline ML pipeline (Spark MLlib + MLflow + Delta Lake) with a lightweight live inference app
- The power of prompt chaining — three small, focused LLM calls outperform one large complex prompt
- The real value of the Medallion Architecture for clean, reproducible data that can be exported and reused
What's next for Mandi Mitra
- Add more crops and districts with richer data
- Integrate real transport cost APIs instead of a flat ₹250 estimate
- Build a voice interface so farmers who can't type can use it
- Deploy as a WhatsApp bot for zero-friction access on any phone
Log in or sign up for Devpost to join the conversation.