Intelligent Q&A System for Indian Agricultural & Climate Data
AI-powered system that answers natural language questions about Indian agriculture and climate using live data from data.gov.in APIs.
- 🔍 Real-time data fetching from government APIs
- 💬 Natural language query processing
- 🤖 AI-powered answers with source citations
- 📊 Automatic query analysis
- 🎨 Clean web interface
- Crop Production API: 246,091 records (1997-2014)
- District-wise, season-wise crop production statistics
- Daily Rainfall API: 3.4M+ records (2018-present)
- District-wise daily rainfall data
- Source: data.gov.in
- Python 3.11+
- Streamlit (Web Interface)
- Groq AI (Free LLM)
- Pandas (Data Processing)
- data.gov.in REST APIs
# Clone repository
git clone https://github.com/priyanka7411/project-samarth.git
cd project-samarth
# Install dependencies
pip install -r requirements.txt
# Set up environment
echo "GROQ_API_KEY=your_key_here" > .env
# Run app
streamlit run app.pyGet free Groq API key: https://console.groq.com/
Try asking:
- "Compare rice production in Punjab and Tamil Nadu for 2013"
- "Show wheat production in Haryana for 2012"
- "What is the rainfall pattern in Kerala for 2020?"
- "Which districts have highest sugarcane production in 2011?"
-
Query Analyzer (
query_analyzer.py)- Extracts states, crops, years using pattern matching
- Identifies query type (comparison, trend, ranking)
-
Data Handler (
data_handler.py)- Manages API pagination and rate limiting
- Fetches from multiple data.gov.in APIs
- Handles different data formats
-
AI Engine (
ai_system.py)- Coordinates data fetching and analysis
- Uses Groq LLM for natural language generation
- Ensures all answers cite sources
-
Web Interface (
app.py)- Streamlit-based UI
- Query history management
- Real-time analysis display
┌─────────────────┐
│ User Query │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Query Analyzer │ ← Extracts states, crops, years
└────────┬────────┘
│
▼
┌─────────────────┐
│ Data Handler │ ← Fetches from data.gov.in APIs
└────────┬────────┘
│
▼
┌─────────────────┐
│ AI Engine │ ← Groq LLM generates answer
└────────┬────────┘
│
▼
┌─────────────────┐
│ Answer + Cites │
└─────────────────┘
User Query → Query Analysis → Data Fetching → AI Processing → Answer + Citations
Real-time API Fetching
- Ensures data accuracy and freshness
- No local storage needed (better for security)
- Can be deployed in air-gapped environments
Free Groq API
- No cost barriers
- Better data sovereignty vs paid services
- Fast inference times
Source Citations
- Every answer includes data.gov.in API references
- Builds trust in AI-generated responses
- Enables verification of claims
Modular Architecture
- Easy to add new data sources
- Separation of concerns
- Testable components
project-samarth/
├── app.py # Streamlit web interface
├── ai_system.py # Main AI Q&A system
├── data_handler.py # API data fetching logic
├── query_analyzer.py # Query parsing and analysis
├── requirements.txt # Python dependencies
├── .env # Environment variables (gitignored)
├── .gitignore # Git ignore rules
├── README.md # This file
└── screenshots/ # App screenshots
- ✅ No data stored locally
- ✅ API keys secured via environment variables
- ✅ Can be deployed in private/secure environments
- ✅ All data fetched in real-time from government sources
- ✅ No third-party data collection
- 📹 Demo Video: Loom Recording
- 💻 Live Demo: Streamlit App
- 📂 GitHub Repo: priyanka7411/project-samarth
Problem Solving & Initiative:
- Successfully discovered and integrated 2 different data.gov.in APIs
- Handled inconsistent data formats and structures
- Built end-to-end working prototype
System Architecture:
- Modular design with clear separation of concerns
- Real-time data integration from multiple sources
- Scalable and extensible architecture
Accuracy & Traceability:
- All answers include specific data points
- Every claim cites the source API
- Data fetched directly from government sources
Core Values:
- Data sovereignty: Uses free APIs, can be self-hosted
- Privacy: No data storage, secure deployment possible
- Accuracy: Real-time fetching ensures data freshness
Priyanka - Built for Project Samarth Challenge
- Ministry of Agriculture & Farmers Welfare
- India Meteorological Department (IMD)
- data.gov.in for open data APIs
🌾 Built for data-driven agricultural insights | Powered by data.gov.in APIs
