A comprehensive AI-powered agricultural advisory system that provides farmers with expert guidance through chat, image analysis, and voice queries in multiple Indian languages.
- Multilingual Chat: Ask farming questions in Hindi, Bengali, Tamil, Telugu, Marathi, Gujarati, Punjabi, and English
- Image Analysis: Upload crop images for disease detection and treatment recommendations
- Voice Queries: Record voice messages in any supported language for hands-free interaction
- Weather Integration: Real-time weather data for location-specific advice
- Market Insights: Current market prices and trends
- AI-Powered Responses: Advanced machine learning models for accurate recommendations
- Text-to-Speech: Audio responses in the user's preferred language
- Price Prediction : Predict future crop prices using trained ML models.
- Docker and Docker Compose installed
- OpenAI API key (optional but recommended)
- Weather API key (OpenWeatherMap)
git clone https://github.com/opbot-xd/AgriAgent.git
cd agriagentCreate a .env file in the root directory:
# Database
DATABASE_URL=sqlite+aiosqlite:///./agriagent.db
# Security
SECRET_KEY=your_super_secret_key
# Token
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60
# Google Gemini/Generative AI
GOOGLE_API_KEY=your_google_api_key
GEMINI_API_KEY=your_gemini_api_key
# Dhenu AI
DHENU_API_KEY=your_dhenu_api_key
# Weather API
WEATHER_API_KEY=your_weather_api_key
# CORS
FRONTEND_URL=http://localhost:3000
#huggingface
HF_TOKEN=your_huggingface_token
HF_API_URL=https://api-inference.huggingface.co/models/linkanjarad/mobilenet_v2_10_224-plant-disease-identification
# OpenAI
OPENAI_API_KEY=your_openai_api_key# Build and start all services
docker-compose up --build
# Or run in detached mode
docker-compose up -d --build- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Create Virtual Environment
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install Dependencies
pip install -r requirements.txt- Create a .env file
# Database
DATABASE_URL=sqlite+aiosqlite:///./agriagent.db
# Security
SECRET_KEY=your_super_secret_key
# Token
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60
# Google Gemini/Generative AI
GOOGLE_API_KEY=your_google_api_key
GEMINI_API_KEY=your_gemini_api_key
# Dhenu AI
DHENU_API_KEY=your_dhenu_api_key
# Weather API
WEATHER_API_KEY=your_weather_api_key
# CORS
FRONTEND_URL=http://localhost:3000
#huggingface
HF_TOKEN=your_huggingface_token
HF_API_URL=https://api-inference.huggingface.co/models/linkanjarad/mobilenet_v2_1.0_224-plant-disease-identification
# OpenAI
OPENAI_API_KEY=your_openai_api_key- Start Backend Server
uvicorn main:app --reload --host 0.0.0.0 --port 8000- Install Node.js Dependencies
cd frontend
npm install- Configure Environment
Create .env in frontend directory:
REACT_APP_API_URL=http://localhost:8000- Start Frontend Server
npm startAgriAgent/
βββ backend/ # FastAPI backend
β βββ dataset/ # Training / data files
β βββ models/ # AI/ML models
β βββ routes/ # API route definitions
β βββ schemas/ # Pydantic schemas
β βββ services/ # Business logic and services
β βββ utils/ # Utility/helper functions
β βββ venv/ # Python virtual environment (local only, not in Docker)
β βββ agriagent.db # SQLite database (dev)
β βββ database.py # Database connection setup
β βββ Dockerfile # Backend Docker configuration
β βββ main.py # FastAPI entry point
β βββ requirements.txt # Python dependencies
β βββ schema.sql # Database schema (optional if using migrations)
β βββ .env # Environment variables (local)
β βββ .env.sample # Example environment file
β βββ README.md # Backend documentation
β
βββ frontend/ # Next.js frontend
β βββ app/ # App router (Next.js 13+)
β βββ components/ # UI components
β βββ lib/ # Utility libraries
β βββ public/ # Static assets
β βββ .next/ # Next.js build output (ignored in git)
β βββ Dockerfile # Frontend Docker configuration
β βββ package.json # Node.js dependencies
β βββ package-lock.json # Lockfile
β βββ tsconfig.json # TypeScript configuration
β βββ next.config.ts # Next.js config
β βββ eslint.config.mjs # ESLint config
β βββ postcss.config.mjs # PostCSS config
β βββ tailwind.config.js # Tailwind CSS configuration
β βββ components.json # ShadCN components registry
β βββ .env # Frontend environment variables
β βββ .env.sample # Example environment file
β βββ README.md # Frontend documentation
β
βββ docker-compose.yml # Docker services configuration
βββ README.md # Main project documentation
βββ .gitignore # Git ignore file
AgriAgent requires several API keys for different features.
All keys should be added in the .env file located in the backend/ directory.
- DATABASE_URL
Default:sqlite+aiosqlite:///./agriagent.db
You can change this to PostgreSQL, MySQL, etc. if required.
- SECRET_KEY β Any random secure string for JWT tokens.
- ALGORITHM β Default:
HS256 - ACCESS_TOKEN_EXPIRE_MINUTES β Token validity in minutes (default:
60).
-
GOOGLE_API_KEY
- Sign up at Google AI Studio
- Generate an API key
- Add it here.
-
GEMINI_API_KEY
- Alternative Gemini key (if using a different project setup).
- DHENU_API_KEY
- Required if using Dhenu AI services.
- WEATHER_API_KEY
- Sign up at OpenWeather
- Generate a free API key
- Add it here.
- FRONTEND_URL
- The URL of your frontend app.
- Example:
http://localhost:3000
-
HF_TOKEN
- Get token from Hugging Face
- Required for model access.
-
HF_API_URL
- Default:
https://api-inference.huggingface.co/models/linkanjarad/mobilenet_v2_1.0_224-plant-disease-identification - Used for plant disease detection.
- Default:
- OPENAI_API_KEY
- Sign up at OpenAI
- Generate API key
- Add it here.
POST /auth/signup- Register new userPOST /auth/login- User login
POST /chat- Text chat queries and also voice queriesPOST /upload- Image analysisPOST /forecast- predict future rates of your crop
Visit http://localhost:8000/docs for interactive API documentation.
- English (en)
- Hindi (hi)
- Bengali (bn)
- Tamil (ta)
- Telugu (te)
- Marathi (mr)
- Gujarati (gu)
- Punjabi (pa)
- JWT-based authentication
- Password hashing with bcrypt
- HTTPS support (configure in production)
- Input validation and sanitization
- Rate limiting (Redis-based)
-
Database Connection Error
- Ensure PostgreSQL is running
- Check DATABASE_URL configuration
- Verify user permissions
-
Redis Connection Error
- Ensure Redis server is running
- Check REDIS_URL configuration
-
AI Model Loading Issues
- Ensure sufficient disk space (models can be large)
- Check internet connection for model downloads
- Verify write permissions in models directory
-
Audio Processing Issues
- Install ffmpeg:
sudo apt-get install ffmpeg - Check microphone permissions in browser
- Install ffmpeg:
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue on GitHub
- Check documentation at
/docsendpoint - Review troubleshooting section above
- β Multilingual chat support (Hindi, Bengali, Tamil, Telugu, Marathi, Gujarati, Punjabi, English)
- β Crop image upload and disease detection (Hugging Face model)
- β Voice query support with text-to-speech responses
- β Weather integration and market insights
- β AI-powered price prediction
- SMS/WhatsApp/IVR integration for wider accessibility
- Farmer community features for peer-to-peer learning and sharing
- Mobile application (Flutter) for better farmer experience
- Improved ML models for accurate disease diagnosis and recommendations
- Offline/low-connectivity mode for remote villages
- Partnerships with NGOs, AgriTech companies, and government bodies
- Advanced analytics dashboard for farmers
- Continuous AI learning from farmer queries and images
- OpenAI and Google Gemini for providing powerful AI language models.
- Hugging Face for open-source transformer models and APIs.
- Weather APIs (for real-time weather and climate data integration).
- Dhenu β for agri advices
- The agricultural research community for datasets, insights, and continued innovation.
- Open-source contributors whose projects, tools, and libraries made this work possible.
AgriAgent