A modern, AI-powered agricultural advisory chatbot built with React and TypeScript. This application provides personalized farming advice, weather information, and agricultural guidance with offline support and multi-language capabilities.
The Agri Chatbot Agent is designed to help farmers access agricultural information and advice through an intuitive chat interface. The application works seamlessly in both online and offline modes, making it accessible to farmers in areas with limited internet connectivity.
- π€ Intelligent Chat Interface: Natural language processing for agricultural queries
- π Multi-Language Support: Hindi, English, and regional languages
- π± Progressive Web App: Installable on mobile devices
- π Offline Functionality: Works without internet using cached data
- π€οΈ Weather Integration: Real-time weather data and forecasts
- π€ User Profiles: Personalized recommendations based on location and crops
- π¨ Modern UI: Clean, responsive design with Tailwind CSS
- Node.js 18+
- npm or yarn
-
Clone the repository
git clone <your-repo-url> cd agri-chatbot-agent
-
Install dependencies
npm install
-
Start development server
npm run dev
-
Open in browser
http://localhost:5173
npm run build
npm run previewsrc/
βββ components/ # React components
β βββ ProtectedRoute.tsx
β βββ NetworkStatusIndicator.tsx
β βββ LoadingSpinner.tsx
βββ hooks/ # Custom React hooks
β βββ api/ # API-related hooks
β βββ utils/ # Utility hooks
βββ pages/ # Page components
βββ Provider/ # Context providers
βββ services/ # API services
βββ types/ # TypeScript type definitions
βββ utils/ # Utility functions
βββ i18n/ # Internationalization
βββ assets/ # Static assets
- React 18 - UI framework
- TypeScript - Type safety
- Vite - Build tool and dev server
- Tailwind CSS - Styling
- React Router - Navigation
- React Query - Data fetching and caching
- Radix UI - Accessible component primitives
- Lucide React - Icons
- Class Variance Authority - Component variants
- i18next - Multi-language support
- react-i18next - React integration
- Vite PWA Plugin - PWA capabilities
- Service Worker - Offline functionality
The application includes robust offline support:
- Network Detection: Automatically detects network conditions
- Data Caching: Stores user profiles and essential data locally
- Graceful Degradation: Works with limited or no internet
- Smart API Calls: Only makes API calls when network is suitable
- Online (4G/5G): Full functionality with real-time data
- Limited (2G/3G): Uses cached data, reduced API calls
- Offline: Works entirely with cached data
- Installable: Can be installed on mobile devices
- Offline Support: Works without internet connection
- App-like Experience: Native app feel on mobile
- Push Notifications: Ready for future implementation
- Mobile-First: Optimized for mobile devices
- Accessibility: WCAG compliant components
- Responsive: Works on all screen sizes
- Dark/Light Mode: Theme support
- Chat Interface: Main interaction area
- User Profile Setup: Multi-step onboarding
- Network Status Indicator: Shows connection status
- Loading States: Smooth loading experiences
- Protected Routes: Secure access to authenticated features
- Token Management: JWT-based authentication
- Local Storage: Secure data caching
- Network Security: HTTPS enforcement
Supports multiple languages with easy extensibility:
- Hindi (ΰ€Ήΰ€Ώΰ€ΰ€¦ΰ₯)
- English
- Regional Languages (easily configurable)
- Add language configuration in
src/i18n/ - Update translation files
- Add language selector in UI
- RESTful APIs: Standard HTTP endpoints
- Error Handling: Graceful error management
- Caching Strategy: Smart data caching
- Retry Logic: Automatic retry for failed requests
- User Profiles: Cached user information
- Chat History: Local message storage
- Settings: User preferences
- Offline Data: Essential data for offline use
npm run buildThis command runs TypeScript compilation (tsc) followed by Vite build process.
- Vercel (Recommended)
- Netlify
- Firebase Hosting
- GitHub Pages
Create a .env file in the root directory with the following variables:
# API Configuration
VITE_API_BASE_URL=http://localhost:3001/api
VITE_QUEUE_API_BASE_URL=http://localhost:3003/api
# Feature Flags
VITE_DISABLE_TWILIO=trueNote: Make sure your backend services are running on the specified ports (3001 and 3003) for the application to work properly.
npm run dev # Start development server (vite)
npm run build # Build for production (tsc && vite build)
npm run preview # Preview production build
npm run lint # Run ESLint with TypeScript- TypeScript: Strict type checking
- ESLint: Code linting and formatting
- Prettier: Code formatting
- Git Hooks: Pre-commit checks
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Follow TypeScript best practices
- Use functional components with hooks
- Maintain accessibility standards
- Write meaningful commit messages
This project is licensed under the MIT License.
- React and TypeScript communities
- Tailwind CSS for styling
- Vite for build tooling
- All contributors and maintainers
Built with β€οΈ for the agricultural community
Empowering farmers with modern technology and accessible information