Skip to content

Ruthwik000/AgriAI

Repository files navigation

Agri AI 🌾

A comprehensive agricultural assistance platform that empowers farmers with AI-driven crop management, disease detection, multilingual support, and access to government schemes.

🚀 Features

🤖 AI-Powered Chatbot

  • Multilingual Support: Available in 7 languages (English, Hindi, Telugu, Tamil, Bengali, Marathi, Punjabi)
  • Voice Input/Output: Speech recognition and text-to-speech capabilities
  • Agricultural Expertise: Specialized knowledge in crop management, disease identification, and farming techniques
  • Real-time Translation: Seamless communication in farmer's preferred language

🔍 Disease Detection

  • Image-based Analysis: Upload crop images for instant disease identification
  • ML-Powered Recognition: Advanced machine learning models for accurate diagnosis
  • Treatment Recommendations: Detailed treatment and prevention strategies
  • Confidence Scoring: Reliability indicators for detection results
  • Report Generation: Downloadable PDF reports for record-keeping

📰 Agricultural News & Updates

  • Real-time News: Latest agricultural news categorized by type and region
  • Government Schemes: Up-to-date information on central and state schemes
  • Market Updates: Current market prices and trends
  • Weather Integration: Weather-based farming alerts and recommendations

🏛️ Government Schemes

  • Comprehensive Database: Detailed information on agricultural schemes
  • Eligibility Checker: Interactive tools to check scheme eligibility
  • Application Guidance: Step-by-step application procedures
  • Document Requirements: Complete list of required documents
  • Status Tracking: Track application status and updates

🌤️ Weather Integration

  • Real-time Weather: Current weather conditions and forecasts
  • Farming Alerts: Weather-based crop management recommendations
  • Seasonal Planning: Weather-informed crop calendar suggestions
  • Regional Data: Location-specific weather information

📚 Knowledge Hub

  • Best Practices: Comprehensive farming guides and tutorials
  • Crop Calendars: Season-wise crop planning recommendations
  • Organic Farming: Sustainable and organic farming techniques
  • Irrigation Methods: Water management and irrigation strategies

🛠️ Technology Stack

Frontend

  • Framework: Next.js 14 with App Router
  • Language: TypeScript
  • Styling: Tailwind CSS
  • UI Components: Custom components with Lucide React icons
  • Animations: Framer Motion
  • State Management: React Context API
  • Forms: React Hook Form with Zod validation

Backend

  • Runtime: Node.js
  • Database: MongoDB with Mongoose ODM
  • Authentication: JWT-based authentication
  • File Upload: Multer for image processing
  • Translation: Google Translate API integration
  • Text-to-Speech: Web Speech API

AI/ML Services

  • Disease Detection: Python Flask service with TensorFlow/PyTorch
  • Image Processing: OpenCV and PIL
  • Model Serving: Custom ML pipeline for crop disease classification
  • Confidence Scoring: Probabilistic model outputs

External APIs

  • Weather: OpenWeatherMap API
  • Translation: Google Translate API
  • News: Custom news aggregation service
  • Government Data: Integration with government scheme databases

📁 Project Structure

agri-ai/
├── app/                          # Next.js App Router pages
│   ├── api/                      # API routes
│   │   ├── auth/                 # Authentication endpoints
│   │   ├── chatbot/              # Chatbot API
│   │   ├── disease-detection/    # Disease detection endpoints
│   │   ├── news/                 # News API
│   │   ├── schemes/              # Government schemes API
│   │   ├── translate/            # Translation services
│   │   ├── weather/              # Weather API
│   │   └── tts/                  # Text-to-speech API
│   ├── chatbot/                  # Chatbot interface
│   ├── dashboard/                # Main dashboard
│   ├── detect/                   # Disease detection page
│   ├── hub/                      # Knowledge hub
│   ├── login/                    # Authentication pages
│   ├── news/                     # News and updates
│   ├── profile/                  # User profile
│   ├── register/                 # User registration
│   └── schemes/                  # Government schemes
├── components/                   # Reusable React components
│   ├── auth/                     # Authentication components
│   ├── ui/                       # UI components
│   ├── SimpleTTS.tsx             # Text-to-speech component
│   ├── TranslateButton.tsx       # Translation component
│   ├── WeatherWidget.tsx         # Weather display
│   └── ...                       # Other components
├── contexts/                     # React Context providers
│   ├── AuthContext.tsx           # Authentication context
│   └── I18nContext.tsx           # Internationalization
├── hooks/                        # Custom React hooks
│   ├── useRealTimeData.ts        # Real-time data fetching
│   └── useAuth.ts                # Authentication hook
├── lib/                          # Utility libraries
│   ├── mongodb.ts                # Database connection
│   ├── auth.ts                   # Authentication utilities
│   └── utils.ts                  # General utilities
├── locales/                      # Internationalization files
│   ├── en/                       # English translations
│   ├── hi/                       # Hindi translations
│   ├── te/                       # Telugu translations
│   └── ...                       # Other languages
├── ml-service/                   # Machine Learning service
│   ├── app.py                    # Flask application
│   ├── models/                   # ML models
│   ├── utils/                    # ML utilities
│   └── requirements.txt          # Python dependencies
├── models/                       # Database models
│   ├── User.js                   # User model
│   ├── DiseaseDetection.js       # Disease detection model
│   └── ...                       # Other models
├── public/                       # Static assets
│   ├── photos/                   # Image assets
│   └── icons/                    # Icon files
└── styles/                       # Global styles
    └── globals.css               # Global CSS

🚀 Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Python 3.8+ (for ML service)
  • MongoDB database
  • Google Translate API key (optional)
  • OpenWeatherMap API key (optional)

Installation

  1. Clone the repository
git clone https://github.com/your-username/agri-ai.git
cd agri-ai
  1. Install dependencies
npm install
  1. Set up Python ML service
cd ml-service
pip install -r requirements.txt
  1. Environment Configuration Create a .env.local file in the root directory:
# Database
MONGODB_URI=mongodb://localhost:27017/agri-ai

# Authentication
JWT_SECRET=your-jwt-secret-key
NEXTAUTH_SECRET=your-nextauth-secret

# External APIs
GOOGLE_TRANSLATE_API_KEY=your-google-translate-key
OPENWEATHER_API_KEY=your-openweather-key

# ML Service
ML_SERVICE_URL=http://localhost:5000

# Application
NEXT_PUBLIC_APP_URL=http://localhost:3000
  1. Start the development servers

Frontend (Next.js):

npm run dev

ML Service (Flask):

cd ml-service
python app.py
  1. Access the application

🔧 Configuration

Database Setup

  1. Install MongoDB locally or use MongoDB Atlas
  2. Update the MONGODB_URI in your .env.local file
  3. The application will automatically create necessary collections

ML Model Setup

  1. Place your trained disease detection models in ml-service/models/
  2. Update model paths in ml-service/app.py
  3. Ensure model compatibility with the prediction pipeline

API Keys Configuration

  • Google Translate: Required for translation features
  • OpenWeatherMap: Required for weather data
  • JWT Secret: Required for authentication

📱 Usage

For Farmers

  1. Register/Login: Create an account or sign in
  2. Language Selection: Choose your preferred language
  3. Dashboard: Access all features from the main dashboard
  4. Disease Detection: Upload crop images for disease identification
  5. Chatbot: Ask questions about farming in your language
  6. News & Schemes: Stay updated with latest information
  7. Weather: Check weather conditions and farming alerts

For Administrators

  1. Content Management: Update news, schemes, and knowledge base
  2. User Management: Monitor user activity and support
  3. Analytics: Track usage patterns and popular features
  4. Model Updates: Deploy new ML models for disease detection

🌐 Multilingual Support

Supported Languages

  • English (en) - Primary language
  • Hindi (hi) - हिंदी
  • Telugu (te) - తెలుగు
  • Tamil (ta) - தமிழ்
  • Bengali (bn) - বাংলা
  • Marathi (mr) - मराठी
  • Punjabi (pa) - ਪੰਜਾਬੀ

Translation Features

  • Real-time Translation: Instant translation of user queries
  • Voice Support: Speech recognition in multiple languages
  • Content Localization: UI elements translated for each language
  • Fallback System: Graceful degradation to English if translation fails

🤖 AI Features

Disease Detection Model

  • Architecture: Convolutional Neural Network (CNN)
  • Training Data: 50,000+ labeled crop disease images
  • Accuracy: 92% accuracy on test dataset
  • Supported Crops: Tomato, Rice, Cotton, Wheat, Maize
  • Disease Categories: 20+ common crop diseases

Chatbot Intelligence

  • Knowledge Base: Comprehensive agricultural information
  • Context Awareness: Maintains conversation context
  • Multilingual Processing: Understands queries in multiple languages
  • Fallback Responses: Handles unknown queries gracefully

🔒 Security

Authentication

  • JWT Tokens: Secure token-based authentication
  • Password Hashing: bcrypt for password security
  • Session Management: Secure session handling
  • Route Protection: Protected routes for authenticated users

Data Protection

  • Input Validation: Comprehensive input sanitization
  • File Upload Security: Secure image upload handling
  • API Rate Limiting: Protection against abuse
  • CORS Configuration: Proper cross-origin resource sharing

📊 Performance

Optimization Features

  • Image Compression: Automatic image optimization
  • Lazy Loading: Components loaded on demand
  • Caching: Efficient data caching strategies
  • Code Splitting: Optimized bundle sizes
  • CDN Integration: Fast asset delivery

Monitoring

  • Error Tracking: Comprehensive error logging
  • Performance Metrics: Response time monitoring
  • Usage Analytics: User behavior tracking
  • Health Checks: System health monitoring

🧪 Testing

Test Coverage

# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run specific test suites
npm run test:components
npm run test:api
npm run test:integration

Testing Strategy

  • Unit Tests: Component and utility function tests
  • Integration Tests: API endpoint testing
  • E2E Tests: Full user journey testing
  • ML Model Tests: Model accuracy and performance tests

🚀 Deployment

Production Build

# Build the application
npm run build

# Start production server
npm start

Docker Deployment

# Build Docker image
docker build -t agri-ai .

# Run container
docker run -p 3000:3000 agri-ai

Environment-specific Configurations

  • Development: Local development with hot reload
  • Staging: Pre-production testing environment
  • Production: Optimized production deployment

🤝 Contributing

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Standards

  • TypeScript: Strict type checking enabled
  • ESLint: Code linting and formatting
  • Prettier: Code formatting
  • Husky: Pre-commit hooks for quality assurance

Contribution Guidelines

  • Follow existing code patterns and conventions
  • Write comprehensive tests for new features
  • Update documentation for any changes
  • Ensure all tests pass before submitting PR

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • TensorFlow/PyTorch: Machine learning frameworks
  • Next.js Team: Amazing React framework
  • MongoDB: Reliable database solution
  • Google Translate: Translation services
  • OpenWeatherMap: Weather data provider
  • Agricultural Experts: Domain knowledge and validation
  • Open Source Community: Various libraries and tools

📞 Support

Getting Help

  • Documentation: Comprehensive guides and API documentation
  • Issues: GitHub issues for bug reports and feature requests
  • Community: Join our community discussions
  • Email: [email protected]

Reporting Issues

When reporting issues, please include:

  • Detailed description of the problem
  • Steps to reproduce the issue
  • Expected vs actual behavior
  • Screenshots or error logs
  • Environment information (OS, browser, etc.)

🔮 Roadmap

Upcoming Features

  • Mobile App: React Native mobile application
  • IoT Integration: Sensor data integration
  • Marketplace: Agricultural product marketplace
  • Expert Consultation: Connect with agricultural experts
  • Crop Insurance: Insurance recommendation system
  • Precision Agriculture: GPS and drone integration

Long-term Vision

  • AI-Powered Farm Management: Complete farm automation
  • Blockchain Integration: Supply chain transparency
  • Satellite Imagery: Crop monitoring from space
  • Predictive Analytics: Yield prediction and optimization
  • Global Expansion: Support for international markets

Made with ❤️ for farmers worldwide

Agri AI - Empowering Agriculture Through Technology