🌾 AgriBot — Full Case Study & Technical Playbook 🌾 एग्रीबॉट — पूर्ण केस स्टडी और तकनीकी प्लेबुक

Author’s Perspective लेखक का दृष्टिकोण

I built AgriBot (FarmerChatBot) as a hybrid Android + serverless AI platform that enables farmers to ask agricultural questions in Hindi and English, both via voice and text, and receive helpful, structured replies powered by Google Gemini LLMs. This case study is my complete documentation of the project — why I built it the way I did, the technical choices I made, the exact workflows and commands I used to set up infrastructure, the issues I faced during development, how I debugged and solved them, and the lessons I took away. मैंने एग्रीबॉट (फार्मरचैटबॉट) को एक हाइब्रिड एंड्रॉयड + सर्वरलेस AI प्लेटफॉर्म के रूप में बनाया, जो किसानों को हिंदी और अंग्रेजी में, वॉयस और टेक्स्ट दोनों के माध्यम से कृषि संबंधी प्रश्न पूछने और Google Gemini LLMs द्वारा संचालित उपयोगी, संरचित जवाब प्राप्त करने में सक्षम बनाता है। यह केस स्टडी मेरे प्रोजेक्ट का पूर्ण दस्तावेजीकरण है — मैंने इसे इस तरह क्यों बनाया, मैंने जो तकनीकी विकल्प चुने, बुनियादी ढांचे को स्थापित करने के लिए मैंने जिन सटीक वर्कफ्लो और कमांड का उपयोग किया, विकास के दौरान मुझे जिन समस्याओं का सामना करना पड़ा, मैंने उन्हें कैसे डिबग और हल किया, और मेरे द्वारा सीखे गए सबक।

This document is both a case study and a reproducible technical guide, structured around: यह दस्तावेज एक केस स्टडी और एक पुनरुत्पादनीय तकनीकी गाइड दोनों है, जो निम्नलिखित के आसपास संरचित है:

  • Architecture & design decisions आर्किटेक्चर और डिज़ाइन निर्णय
  • Detailed tech stack explanations विस्तृत तकनीकी स्टैक व्याख्या
  • Setup & configuration commands सेटअप और कॉन्फ़िगरेशन कमांड
  • Problems I faced, root causes, and how I solved them मुझे जिन समस्याओं का सामना करना पड़ा, उनके मूल कारण, और मैंने उन्हें कैसे हल किया
  • Trade-offs & alternatives I considered मैंने जिन ट्रेड-ऑफ्स और विकल्पों पर विचार किया
  • Actionable lessons for future projects भविष्य के प्रोजेक्ट्स के लिए कार्यसाध्य सबक

Project Vision and Problem Context प्रोजेक्ट विजन और समस्या संदर्भ

Overview अवलोकन

AgriBot was born from the observation that farmers need accessible, real-time agricultural knowledge but often face barriers with literacy, language, and digital interfaces. Most mobile solutions are text-heavy or English-only. I wanted to design a voice-first assistant that felt as natural as speaking to a person. एग्रीबॉट इस अवलोकन से उत्पन्न हुआ कि किसानों को सुलभ, वास्तविक समय में कृषि ज्ञान की आवश्यकता है, लेकिन वे अक्सर साक्षरता, भाषा और डिजिटल इंटरफेस के साथ बाधाओं का सामना करते हैं। अधिकांश मोबाइल समाधान टेक्स्ट-भारी या केवल अंग्रेजी में हैं। मैं एक वॉयस-फर्स्ट सहायक डिज़ाइन करना चाहता था जो किसी व्यक्ति से बात करने जितना स्वाभाविक लगे।

The goals of AgriBot were shaped by three priorities. The first was voice-first, multilingual UX: Hindi and English speech recognition, and Hindi text-to-speech replies. The second was lightweight APK distribution: the app needed to run smoothly even on mid-range or older Android phones. The third was scalability of AI compute: the heavy LLM logic had to be offloaded to a backend rather than bundled into the APK, so that the app remained small and secure. एग्रीबॉट के लक्ष्य तीन प्राथमिकताओं द्वारा आकार लिए गए थे। पहला था वॉयस-फर्स्ट, बहुभाषी UX: हिंदी और अंग्रेजी में भाषण पहचान, और हिंदी टेक्स्ट-टू-स्पीच जवाब। दूसरा था हल्का APK वितरण: ऐप को मध्यम-श्रेणी या पुराने एंड्रॉयड फोनों पर भी सुचारू रूप से चलना था। तीसरा था AI कम्प्यूट की स्केलेबिलिटी: भारी LLM तर्क को APK में शामिल करने के बजाय बैकएंड पर ऑफलोड करना था, ताकि ऐप छोटा और सुरक्षित रहे।

From these goals, AgriBot’s design crystallized as a hybrid mobile + cloud system: a native Android app for user interaction, with serverless backend APIs for large language model orchestration. इन लक्ष्यों से, एग्रीबॉट का डिज़ाइन एक हाइब्रिड मोबाइल + क्लाउड सिस्टम के रूप में स्पष्ट हुआ: उपयोगकर्ता इंटरैक्शन के लिए एक मूल एंड्रॉयड ऐप, और बड़े भाषा मॉडल ऑर्केस्ट्रेशन के लिए सर्वरलेस बैकएंड API।

System Architecture सिस्टम आर्किटेक्चर

Overview अवलोकन

AgriBot consists of two distinct halves that communicate via HTTPS: एग्रीबॉट दो अलग-अलग हिस्सों से बना है जो HTTPS के माध्यम से संचार करते हैं:

  • The Android client, written primarily in Kotlin, which handles user interaction, voice input/output, message history, reactions, pinned messages, and lightweight local logic. Some Python logic is retained on-device through Chaquopy, mainly as a bridge from the original prototype. एंड्रॉयड क्लाइंट, मुख्य रूप से कोटलिन में लिखा गया, जो उपयोगकर्ता इंटरैक्शन, वॉयस इनपुट/आउटपुट, संदेश इतिहास, रिएक्शन्स, पिन किए गए संदेश, और हल्के स्थानीय तर्क को संभालता है। कुछ पायथन तर्क को चक्वोपी के माध्यम से डिवाइस पर बनाए रखा गया है, मुख्य रूप से मूल प्रोटोटाइप से एक पुल के रूप में।
  • The backend AI service, hosted on AWS Lambda and exposed through API Gateway, which manages prompt orchestration with LangChain and integrates with the Google Gemini API to generate replies. बैकएंड AI सेवा, AWS Lambda पर होस्ट की गई और API गेटवे के माध्यम से उजागर की गई, जो लैंगचेन के साथ प्रॉम्प्ट ऑर्केस्ट्रेशन को प्रबंधित करती है और जवाब उत्पन्न करने के लिए Google Gemini API के साथ एकीकृत होती है।

On the device, the user can speak or type a question. SpeechRecognizer converts speech to text. This is displayed in a WhatsApp-style chat interface and simultaneously sent to the backend. While the backend processes the request, the UI shows a “Typing…” placeholder to mimic a real conversational agent. The backend Lambda function receives the input, orchestrates a Gemini prompt through LangChain, and sends back a structured reply. The Android app receives this reply, displays it as a bot message, and reads it aloud with TextToSpeech. डिवाइस पर, उपयोगकर्ता बोलकर या टाइप करके प्रश्न पूछ सकता है। SpeechRecognizer भाषण को टेक्स्ट में परिवर्तित करता है। यह एक व्हाट्सएप-शैली चैट इंटरफेस में प्रदर्शित होता है और साथ ही बैकएंड को भेजा जाता है। जब बैकएंड अनुरोध को प्रोसेस करता है, तो UI एक "टाइपिंग..." प्लेसहोल्डर दिखाता है ताकि एक वास्तविक संवादी एजेंट की नकल हो। बैकएंड Lambda फंक्शन इनपुट प्राप्त करता है, लैंगचेन के माध्यम से एक Gemini प्रॉम्प्ट को ऑर्केस्ट्रेट करता है, और एक संरचित जवाब वापस भेजता है। एंड्रॉयड ऐप इस जवाब को प्राप्त करता है, इसे बॉट संदेश के रूप में प्रदर्शित करता है, और TextToSpeech के साथ इसे जोर से पढ़ता है।

Pinned messages and reactions are handled locally and persisted in SharedPreferences as a JSON array. When users choose to view pinned messages, a dedicated activity (PinnedActivity) renders them. The backend is not aware of pinned state — this remains a client-only feature for responsiveness. पिन किए गए संदेश और रिएक्शन्स स्थानीय रूप से संभाले जाते हैं और SharedPreferences में JSON ऐरे के रूप में संग्रहीत किए जाते हैं। जब उपयोगकर्ता पिन किए गए संदेश देखना चुनते हैं, तो एक समर्पित गतिविधि (PinnedActivity) उन्हें रेंडर करती है। बैकएंड को पिन की स्थिति के बारे में जानकारी नहीं होती — यह प्रतिक्रियाशीलता के लिए केवल क्लाइंट-विशिष्ट सुविधा बनी रहती है।

ASCII Overview ASCII अवलोकन

+-------------------------------+
|         Android Client        |
|-------------------------------|
| - Kotlin UI (RecyclerView)    |
| - Voice Input (SpeechRecognizer)
| - TTS Output (TextToSpeech)   |
| - Local Storage (SharedPrefs) |
| - Pinned/Reactions logic      |
| - Python bridge (Chaquopy)    |
+-------------------+-----------+
                    |
              HTTPS Requests
                    |
+-------------------v------------------+
|        AWS API Gateway (REST)       |
+-------------------+------------------+
                    |
                    v
+-------------------+------------------+
|   AWS Lambda (Python runtime)       |
| - LangChain orchestration           |
| - Gemini LLM API client             |
| - Error handling / logging          |
+-------------------+------------------+
                    |
                    v
+-------------------+------------------+
|     CloudWatch Logs / Analytics     |
+-------------------------------------+
    

System Architecture Image System Architecture of AgriBot showing Android client and AWS backend सिस्टम आर्किटेक्चर छवि एग्रीबॉट का सिस्टम आर्किटेक्चर जो एंड्रॉयड क्लाइंट और AWS बैकएंड दिखाता है

This architecture allowed me to keep the mobile client fast and lightweight, while placing all heavy computation and sensitive API key storage in the backend. इस आर्किटेक्चर ने मुझे मोबाइल क्लाइंट को तेज और हल्का रखने की अनुमति दी, जबकि सभी भारी गणना और संवेदनशील API कुंजी भंडारण को बैकएंड में रखा गया।

Tech Stack and Deep Technical Rationale तकनीकी स्टैक और गहन तकनीकी तर्क

3.1 Kotlin + Android 3.1 कोटलिन + एंड्रॉयड

The Android client was rewritten in Kotlin after the initial prototype. Kotlin is the official Android-first language, offers concise syntax, and allows direct access to native APIs like microphone and TTS. The Android Studio + Gradle build system provided packaging into APKs, device deployment, and integration with Chaquopy. एंड्रॉयड क्लाइंट को प्रारंभिक प्रोटोटाइप के बाद कोटलिन में फिर से लिखा गया। कोटलिन आधिकारिक एंड्रॉयड-प्रथम भाषा है, जो संक्षिप्त वाक्यविन्यास प्रदान करती है और माइक्रोफोन और TTS जैसे मूल API तक सीधे पहुंच की अनुमति देती है। एंड्रॉयड स्टूडियो + ग्रैडल बिल्ड सिस्टम ने APK में पैकेजिंग, डिवाइस तैनाती, और चक्वोपी के साथ एकीकरण प्रदान किया।

The chat interface was implemented with RecyclerView, MessageAdapter, and custom XML layouts for user and bot messages. Features such as pinned messages and reactions were added incrementally. The lifecycle of the app was managed through MainActivity, with speech recognition and text-to-speech tied into it. चैट इंटरफेस को RecyclerView, MessageAdapter, और उपयोगकर्ता और बॉट संदेशों के लिए कस्टम XML लेआउट के साथ लागू किया गया। पिन किए गए संदेश और रिएक्शन्स जैसी सुविधाएँ क्रमिक रूप से जोड़ी गईं। ऐप का जीवनचक्र MainActivity के माध्यम से प्रबंधित किया गया, जिसमें भाषण पहचान और टेक्स्ट-टू-स्पीच को शामिल किया गया।

An important lesson was the strict requirement of AppCompat themes when extending AppCompatActivity. At one point, a misconfigured theme (MaterialComponents without proper dependencies) caused runtime crashes. The final fix was to explicitly inherit from Theme.AppCompat.Light.NoActionBar. एक महत्वपूर्ण सबक AppCompatActivity का विस्तार करते समय AppCompat थीम्स की सख्त आवश्यकता थी। एक समय पर, एक गलत कॉन्फ़िगर की गई थीम (उचित निर्भरताओं के बिना MaterialComponents) ने रनटाइम क्रैश का कारण बना। अंतिम सुधार Theme.AppCompat.Light.NoActionBar से स्पष्ट रूप से इनहेरिट करना था।

3.2 Chaquopy (Python on Android) 3.2 चक्वोपी (एंड्रॉयड पर पायथन)

AgriBot’s first prototype was entirely Python-based using KivyMD. Rather than discarding that work, I used Chaquopy to embed Python into the Android app. Chaquopy provides a Python runtime inside the APK and lets Kotlin call Python modules directly. एग्रीबॉट का पहला प्रोटोटाइप पूरी तरह से KivyMD का उपयोग करके पायथन-आधारित था। उस काम को त्यागने के बजाय, मैंने चक्वोपी का उपयोग करके एंड्रॉयड ऐप में पायथन को एम्बेड किया। चक्वोपी APK के अंदर एक पायथन रनटाइम प्रदान करता है और कोटलिन को पायथन मॉड्यूल को सीधे कॉल करने की अनुमति देता है।

This gave me rapid reuse of Python code, but introduced build complexities. Chaquopy requires explicit NDK ABI filters, otherwise native libraries are missing at runtime. Gradle also had to be carefully configured with settings.gradle and pluginManagement to avoid plugin conflicts. इसने मुझे पायथन कोड का तेजी से पुन: उपयोग करने की सुविधा दी, लेकिन बिल्ड जटिलताएँ लाईं। चक्वोपी को स्पष्ट NDK ABI फ़िल्टर की आवश्यकता होती है, अन्यथा रनटाइम पर मूल लाइब्रेरीज़ गायब हो जाती हैं। ग्रैडल को भी सावधानीपूर्वक settings.gradle और pluginManagement के साथ कॉन्फ़िगर करना पड़ा ताकि प्लगइन टकराव से बचा जा सके।

ndk {
    abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
python {
    buildPython "3.10"
}
    

Chaquopy was invaluable during prototyping, but I gradually migrated UI responsibilities to Kotlin to achieve a more native look and stability. The Python layer was retained only for lightweight logic, not heavy ML. प्रोटोटाइपिंग के दौरान चक्वोपी अमूल्य था, लेकिन मैंने धीरे-धीरे UI जिम्मेदारियों को कोटलिन में स्थानांतरित किया ताकि अधिक मूल रूप और स्थिरता प्राप्त हो। पायथन परत को केवल हल्के तर्क के लिए बनाए रखा गया, न कि भारी ML के लिए।

3.3 AWS Lambda + LangChain + Gemini 3.3 AWS Lambda + लैंगचेन + Gemini

The backend was designed to host the heavy AI logic. I chose AWS Lambda for its serverless deployment model: I could deploy a function without maintaining servers, and API Gateway gave me an easy HTTPS endpoint to call from the Android client. बैकएंड को भारी AI तर्क को होस्ट करने के लिए डिज़ाइन किया गया था। मैंने AWS Lambda को इसके सर्वरलेस डिप्लॉयमेंट मॉडल के लिए चुना: मैं सर्वर बनाए रखे बिना एक फंक्शन डिप्लॉय कर सकता था, और API गेटवे ने मुझे एंड्रॉयड क्लाइंट से कॉल करने के लिए एक आसान HTTPS एंडपॉइंट दिया।

Inside Lambda, I used LangChain for orchestration. LangChain let me define prompt templates and manage flows between input, context, and Gemini API calls. The Gemini model was used as the LLM for agricultural Q&A. Lambda के अंदर, मैंने ऑर्केस्ट्रेशन के लिए लैंगचेन का उपयोग किया। लैंगचेन ने मुझे प्रॉम्प्ट टेम्पलेट्स को परिभाषित करने और इनपुट, संदर्भ, और Gemini API कॉल्स के बीच प्रवाह को प्रबंधित करने की अनुमति दी। Gemini मॉडल को कृषि प्रश्नोत्तर के लिए LLM के रूप में उपयोग किया गया।

The Lambda function was implemented in Python (lambda_function.py). It handled multiple input cases: query string, raw body, JSON with message fields, and fallbacks. It returned structured JSON with a reply field, ensuring the client always had a consistent contract. Lambda फंक्शन को पायथन में लागू किया गया (lambda_function.py)। इसने कई इनपुट मामलों को संभाला: क्वेरी स्ट्रिंग, कच्चा बॉडी, JSON संदेश फ़ील्ड्स के साथ, और फॉलबैक। इसने एक रिप्लाई फ़ील्ड के साथ संरचित JSON लौटाया, जिससे क्लाइंट को हमेशा एक सुसंगत अनुबंध मिला।

# Example Lambda Handler
import json
import boto3
from langchain.prompts import PromptTemplate
from langchain.llms import GoogleGemini

def lambda_handler(event, context):
    body = json.loads(event['body'])
    user_input = body['query']
    language = body.get('language', 'en')

    # Fetch API key from Secrets Manager
    secrets_client = boto3.client('secretsmanager')
    secret = secrets_client.get_secret_value(SecretId='gemini-api-key')
    api_key = json.loads(secret['SecretString'])['api_key']

    # Initialize Gemini LLM
    llm = GoogleGemini(api_key=api_key)

    # Define prompt template
    template = """
    You are an agricultural expert. Answer the following question in {language}:
    Question: {question}
    Provide a concise, accurate, and practical answer suitable for farmers.
    """
    prompt = PromptTemplate(input_variables=["language", "question"], template=template)
    formatted_prompt = prompt.format(language=language, question=user_input)

    # Get response from Gemini
    response = llm(formatted_prompt)
    
    return {
        'statusCode': 200,
        'body': json.dumps({'response': response})
    }
    

This separation allowed me to update prompts and LLM logic on the server without shipping new APKs. It also meant API keys stayed on the server and never leaked into the APK. इस अलगाव ने मुझे नए APK शिपिंग किए बिना सर्वर पर प्रॉम्प्ट्स और LLM तर्क को अपडेट करने की अनुमति दी। इसका मतलब यह भी था कि API कुंजियाँ सर्वर पर रहीं और कभी भी APK में लीक नहीं हुईं।

3.4 Docker and Lambda Layers 3.4 डॉकर और Lambda लेयर्स

One of the hardest backend challenges was dependency packaging. LangChain and Gemini clients required Python libraries with C extensions. These cannot simply be zipped and uploaded, because Lambda’s runtime requires binaries compiled against Amazon Linux. बैकएंड की सबसे कठिन चुनौतियों में से एक थी डिपेंडेंसी पैकेजिंग। लैंगचेन और Gemini क्लाइंट्स को C एक्सटेंशन्स के साथ पायथन लाइब्रेरीज़ की आवश्यकता थी। इन्हें केवल ज़िप करके अपलोड नहीं किया जा सकता, क्योंकि Lambda का रनटाइम Amazon Linux के खिलाफ संकलित बाइनरीज़ की मांग करता है।

The solution was to use Docker to build a Lambda layer. I wrote a Dockerfile based on the official AWS Lambda Python image (public.ecr.aws/lambda/python:3.10). Inside it, I installed the required dependencies into a python/ directory, zipped it, and extracted the artifact. समाधान था Docker का उपयोग करके Lambda लेयर बनाना। मैंने आधिकारिक AWS Lambda पायथन इमेज (public.ecr.aws/lambda/python:3.10) पर आधारित एक Dockerfile लिखा। इसके अंदर, मैंने आवश्यक डिपेंडेंसीज़ को python/ डायरेक्टरी में स्थापित किया, इसे ज़िप किया, और आर्टिफैक्ट निकाला।

FROM public.ecr.aws/lambda/python:3.10
WORKDIR /opt
COPY requirements.txt .
RUN pip install --target ./python -r requirements.txt
RUN zip -r /tmp/python_layer.zip python
    

The build process was: निर्माण प्रक्रिया थी:

docker build -t agribot-layer .
CONTAINER_ID=$(docker create agribot-layer)
docker cp :{CONTAINER_ID}:/tmp/python_layer.zip ./python_layer.zip
docker rm :{CONTAINER_ID}
    

Once built, I published the layer: एक बार बनने के बाद, मैंने लेयर को प्रकाशित किया:

aws lambda publish-layer-version   --layer-name agribot-deps   --zip-file fileb://python_layer.zip   --compatible-runtimes python3.10
    

Then I attached the layer to the function: फिर मैंने लेयर को फंक्शन से जोड़ा:

aws lambda create-function   --function-name agribot-llm   --runtime python3.10   --handler lambda_function.lambda_handler   --role arn:aws:iam:::role/lambda-exec-role   --zip-file fileb://function.zip   --layers arn:aws:lambda:::layer:agribot-deps:
    

This workflow ensured that all dependencies matched Lambda’s environment. Without Docker, I repeatedly hit “cannot load shared library” errors. इस वर्कफ्लो ने सुनिश्चित किया कि सभी डिपेंडेंसीज़ Lambda के पर्यावरण से मेल खाती हों। Docker के बिना, मुझे बार-बार "cannot load shared library" त्रुटियाँ मिलीं।

3.5 Android Speech APIs 3.5 एंड्रॉयड स्पीच API

For speech recognition, I used the built-in SpeechRecognizer. It required runtime microphone permissions and returned recognition results asynchronously. Text-to-speech was handled by TextToSpeech, initialized with the Hindi locale. भाषण पहचान के लिए, मैंने अंतर्निहित SpeechRecognizer का उपयोग किया। इसके लिए रनटाइम माइक्रोफोन अनुमतियों की आवश्यकता थी और यह पहचान परिणामों को असिंक्रोनस रूप से लौटाता था। टेक्स्ट-टू-स्पीच को TextToSpeech द्वारा संभाला गया, जिसे हिंदी लोकेल के साथ प्रारंभ किया गया।

One issue was that speech recognition quality varied between devices. To handle this, I added clear error messages in the UI (statusLabel) and allowed users to retry. For TTS, I defaulted to Indian English (en-IN) voice, but gracefully handled devices where Hindi voices were missing. एक समस्या यह थी कि भाषण पहचान की गुणवत्ता डिवाइसों के बीच भिन्न थी। इसे संभालने के लिए, मैंने UI में स्पष्ट त्रुटि संदेश (statusLabel) जोड़े और उपयोगकर्ताओं को पुन: प्रयास करने की अनुमति दी। TTS के लिए, मैंने डिफ़ॉल्ट रूप से भारतीय अंग्रेजी (en-IN) आवाज का उपयोग किया, लेकिन उन डिवाइसों को सुचारू रूप से संभाला जहां हिंदी आवाजें गायब थीं।

Development & Deployment Workflow विकास और तैनाती वर्कफ्लो

My workflow alternated between client debugging and backend deployment. मेरा वर्कफ्लो क्लाइंट डिबगिंग और बैकएंड तैनाती के बीच बारी-बारी से था।

For client builds, I used Gradle and adb: क्लाइंट बिल्ड के लिए, मैंने Gradle और adb का उपयोग किया:

./gradlew clean assembleDebug
adb install -r app/build/outputs/apk/debug/app-debug.apk
adb logcat | grep org.test.agribot
    

For backend builds, the steps were: बैकएंड बिल्ड के लिए, चरण थे:

  1. Write requirements.txt with langchain, langchain-google-genai, and dependencies. langchain, langchain-google-genai, और डिपेंडेंसीज़ के साथ requirements.txt लिखें।
  2. Build Docker image and extract python_layer.zip. Docker इमेज बनाएँ और python_layer.zip निकालें।
  3. Publish Lambda layer and attach it to the function. Lambda लेयर प्रकाशित करें और इसे फंक्शन से जोड़ें।
  4. Deploy function with aws lambda create-function or update-function-code. aws lambda create-function या update-function-code के साथ फंक्शन डिप्लॉय करें।
  5. Expose endpoint through API Gateway and test it via console. API गेटवे के माध्यम से एंडपॉइंट उजागर करें और इसे कंसोल के माध्यम से परीक्षण करें।

This reproducible workflow allowed me to move quickly despite the multi-language complexity of the project. इस पुनरुत्पादनीय वर्कफ्लो ने मुझे प्रोजेक्ट की बहु-भाषा जटिलता के बावजूद तेजी से आगे बढ़ने की अनुमति दी।

Features & Implementation सुविधाएँ और कार्यान्वयन

AgriBot offers a set of farmer-focused features: एग्रीबॉट किसान-केंद्रित सुविधाओं का एक सेट प्रदान करता है:

  • Voice-first interaction: Users can tap the microphone, speak in Hindi or English, and see their query transcribed. Replies are spoken back using TTS. वॉयस-फर्स्ट इंटरैक्शन: उपयोगकर्ता माइक्रोफोन पर टैप कर सकते हैं, हिंदी या अंग्रेजी में बोल सकते हैं, और अपनी क्वेरी को ट्रांसक्राइब देख सकते हैं। जवाब TTS का उपयोग करके वापस बोले जाते हैं।
  • Chat UI: The interface mimics WhatsApp, with user messages on the right in green bubbles and bot replies on the left in grey bubbles. चैट UI: इंटरफेस व्हाट्सएप की नकल करता है, जिसमें उपयोगकर्ता संदेश दाईं ओर हरे बुलबुले में और बॉट जवाब बाईं ओर ग्रे बुलबुले में होते हैं।
  • Pinned messages: Farmers can pin critical advice. Pins are stored in local JSON and rendered in a separate pinned window with unpin options. पिन किए गए संदेश: किसान महत्वपूर्ण सलाह को पिन कर सकते हैं। पिन स्थानीय JSON में संग्रहीत किए जाते हैं और अनपिन विकल्पों के साथ एक अलग पिन किए गए विंडो में रेंडर किए जाते हैं।
  • Emoji reactions: Each message supports quick reactions (👍 ❤️ 😂). These are stored per message and survive restarts. इमोजी रिएक्शन्स: प्रत्येक संदेश त्वरित रिएक्शन्स (👍 ❤️ 😂) का समर्थन करता है। ये प्रति संदेश संग्रहीत होते हैं और रीस्टार्ट के बाद भी बने रहते हैं।
  • Searchable history: A search box filters messages in real time by text match. खोज योग्य इतिहास: एक खोज बॉक्स टेक्स्ट मिलान द्वारा वास्तविक समय में संदेशों को फ़िल्टर करता है।
  • Suggested questions: Predefined buttons let users quickly ask common queries such as “चैटजीपीटी क्या है?” or “जैविक खेती के तरीके”. सुझाए गए प्रश्न: पूर्वनिर्धारित बटन उपयोगकर्ताओं को सामान्य प्रश्नों को जल्दी से पूछने की अनुमति देते हैं जैसे कि “चैटजीपीटी क्या है?” या “जैविक खेती के तरीके”।
  • Clear chat: Users can reset history, which keeps the bot’s intro greeting but wipes other messages. चैट साफ करें: उपयोगकर्ता इतिहास को रीसेट कर सकते हैं, जो बॉट के परिचय अभिवादन को रखता है लेकिन अन्य संदेशों को मिटा देता है।

The feature set reflects a balance between farmer usability (voice, pinned advice, familiar UI) and AI integration (cloud-hosted LLMs). सुविधा सेट किसान उपयोगिता (वॉयस, पिन की गई सलाह, परिचित UI) और AI एकीकरण (क्लाउड-होस्टेड LLMs) के बीच संतुलन को दर्शाता है।

Challenges, Errors & Fixes चुनौतियाँ, त्रुटियाँ और सुधार

AgriBot’s development was defined by recurring obstacles that I systematically debugged and solved. एग्रीबॉट का विकास आवर्ती बाधाओं द्वारा परिभाषित था जिन्हें मैंने व्यवस्थित रूप से डिबग और हल किया।

One class of errors was Gradle plugin conflicts. For example, Chaquopy failed with “Could not find com.chaquo.python:gradle” until I added the Chaquopy Maven repo to both pluginManagement and dependencyResolutionManagement. Another was Kotlin JVM target mismatches, fixed by setting both Java and Kotlin targets to version 17. एक प्रकार की त्रुटियाँ Gradle प्लगइन टकराव थीं। उदाहरण के लिए, चक्वोपी तब तक विफल रहा जब तक मैंने pluginManagement और dependencyResolutionManagement दोनों में चक्वोपी Maven repo को नहीं जोड़ा, “Could not find com.chaquo.python:gradle”। एक और था कोटलिन JVM लक्ष्य बेमेल, जिसे जावा और कोटलिन दोनों लक्ष्यों को संस्करण 17 पर सेट करके ठीक किया गया।

UI crashes were another major issue. At one point, the app crashed at launch because I had set the theme to Theme.MaterialComponents while using AppCompatActivity. The fix was to explicitly use Theme.AppCompat.Light.NoActionBar. UI क्रैश एक और प्रमुख समस्या थी। एक समय पर, ऐप लॉन्च के समय क्रैश हो गया क्योंकि मैंने थीम को Theme.MaterialComponents सेट किया था जबकि AppCompatActivity का उपयोग कर रहा था। सुधार Theme.AppCompat.Light.NoActionBar का स्पष्ट रूप से उपयोग करना था।

Backend deployment introduced its own errors. The most difficult were “cannot import numpy” errors inside Lambda. These were resolved only after I switched to Docker-based layer builds to guarantee binary compatibility. बैकएंड तैनाती ने अपनी त्रुटियाँ पेश कीं। सबसे कठिन थीं Lambda के अंदर “cannot import numpy” त्रुटियाँ। इन्हें केवल Docker-आधारित लेयर बिल्ड्स में स्विच करने के बाद हल किया गया ताकि बाइनरी संगतता की गारंटी हो।

SpeechRecognizer also caused problems, often failing silently on devices without Google speech services. I solved this by detecting availability and showing “Speech recognition not available” messages. SpeechRecognizer ने भी समस्याएँ पैदा कीं, अक्सर Google भाषण सेवाओं के बिना डिवाइसों पर चुपचाप विफल हो रहा था। मैंने उपलब्धता का पता लगाकर और “Speech recognition not available” संदेश दिखाकर इसे हल किया।

Finally, Lambda cold starts occasionally delayed replies. I mitigated this by trimming layer size and considering provisioned concurrency for production scaling. अंत में, Lambda कोल्ड स्टार्ट्स ने कभी-कभी जवाबों में देरी की। मैंने लेयर आकार को कम करके और प्रोडक्शन स्केलिंग के लिए प्रोविज़न्ड कॉनकरेंसी पर विचार करके इसे कम किया।

Lessons Learned सीखे गए सबक

AgriBot taught me three categories of lessons. एग्रीबॉट ने मुझे तीन श्रेणियों के सबक सिखाए।

From the build system, I learned to centralize all plugin versions in settings.gradle to avoid mismatches, and to always align Java and Kotlin targets. बिल्ड सिस्टम से, मैंने सभी प्लगइन संस्करणों को settings.gradle में केंद्रीकृत करना सीखा ताकि बेमेल से बचा जा सके, और हमेशा जावा और कोटलिन लक्ष्यों को संरेखित करना सीखा।

From the architecture, I learned that heavy compute should never be on-device for mobile AI apps. Instead, backend LLM orchestration provides flexibility, smaller APKs, and secure key management. आर्किटेक्चर से, मैंने सीखा कि मोबाइल AI ऐप्स के लिए भारी गणना कभी भी डिवाइस पर नहीं होनी चाहिए। इसके बजाय, बैकएंड LLM ऑर्केस्ट्रेशन लचीलापन, छोटे APK, और सुरक्षित कुंजी प्रबंधन प्रदान करता है।

From the UX, I learned that rural users depend on pinned advice and voice-first interaction. Reactions and WhatsApp-like chat design increased comfort and adoption. UX से, मैंने सीखा कि ग्रामीण उपयोगकर्ता पिन की गई सलाह और वॉयस-फर्स्ट इंटरैक्शन पर निर्भर करते हैं। रिएक्शन्स और व्हाट्सएप जैसे चैट डिज़ाइन ने आराम और अपनाने को बढ़ाया।

Future Roadmap भविष्य का रोडमैप

The immediate roadmap for AgriBot is to migrate the remaining Python code out of Chaquopy, making the app 100% Kotlin-native for stability. Future iterations will add multilingual support beyond Hindi and English, offline fallback with lightweight local models, and Play Store release with obfuscation and security hardening. एग्रीबॉट के लिए तत्काल रोडमैप चक्वोपी से शेष पायथन कोड को हटाना है, जिससे ऐप स्थिरता के लिए 100% कोटलिन-नेटिव हो। भविष्य के पुनरावृत्तियों में हिंदी और अंग्रेजी से परे बहुभाषी समर्थन, हल्के स्थानीय मॉडलों के साथ ऑफलाइन फॉलबैक, और ऑब्फसकेशन और सुरक्षा सख्ती के साथ Play Store रिलीज़ जोड़ा जाएगा।

Interview Summary साक्षात्कार सारांश

In an interview, I would describe AgriBot as follows: एक साक्षात्कार में, मैं एग्रीबॉट का वर्णन निम्नलिखित रूप से करूँगा:

“I built AgriBot, a multilingual, voice-first Android chatbot for farmers. It started as a Python prototype but evolved into a hybrid Kotlin app with a serverless backend. I solved cross-stack challenges from Gradle conflicts and Chaquopy ABI packaging to Docker-based Lambda layer builds for LangChain and Gemini. The app provides WhatsApp-like chat UX with pinned messages, reactions, voice I/O, and integrates securely with a Gemini backend. The project reflects my ability to handle end-to-end full-stack development — from Android UI to serverless AI orchestration on AWS.” “मैंने एग्रीबॉट बनाया, जो किसानों के लिए एक बहुभाषी, वॉयस-फर्स्ट एंड्रॉयड चैटबॉट है। यह एक पायथन प्रोटोटाइप के रूप में शुरू हुआ लेकिन एक हाइब्रिड कोटलिन ऐप में विकसित हुआ जिसमें सर्वरलेस बैकएंड है। मैंने Gradle टकराव और चक्वोपी ABI पैकेजिंग से लेकर लैंगचेन और Gemini के लिए Docker-आधारित Lambda लेयर बिल्ड्स तक क्रॉस-स्टैक चुनौतियों को हल किया। ऐप व्हाट्सएप जैसे चैट UX प्रदान करता है जिसमें पिन किए गए संदेश, रिएक्शन्स, वॉयस I/O, और एक Gemini बैकएंड के साथ सुरक्षित एकीकरण शामिल है। यह प्रोजेक्ट एंड्रॉयड UI से लेकर AWS पर सर्वरलेस AI ऑर्केस्ट्रेशन तक एंड-टू-एंड फुल-स्टैक विकास को संभालने की मेरी क्षमता को दर्शाता है।”