An AI-powered agricultural advisory system designed specifically for Kerala farmers. This system provides expert farming advice in Malayalam, helping farmers with crop diseases, weather decisions, input management, and more.
The Digital Krishi Officer serves as a "Digital Krishi Officer" that provides instant, accurate, and context-aware agricultural advice to farmers in their native language, primarily Malayalam. It bridges the critical gap between farmers and agricultural expertise through AI technology.
- Malayalam Language Support: Native language processing for Kerala farmers
- Multimodal Input: Text, voice, and image support for comprehensive queries
- AI-Powered Responses: Using Google's Gemini 2.5 Flash Lite model via OpenRouter
- Crop Disease Detection: Image analysis for disease identification and treatment
- Expert Escalation: Automatic escalation to human experts for complex issues
- 24/7 Availability: Round-the-clock agricultural support
- Next.js 14+ - React framework with App Router
- TypeScript - Type safety and better development experience
- Tailwind CSS - Utility-first CSS framework
- Appwrite - Backend-as-a-Service for authentication and database
- Appwrite Database - NoSQL document database
- Appwrite Auth - Email/password authentication
- OpenRouter - AI model routing and management
- Vercel AI SDK - Streaming AI responses
- Google Gemini 2.5 Flash Lite - Primary AI model for agricultural advice
- Zustand - Lightweight state management solution
- Node.js 18+
- pnpm (recommended) or npm
- Appwrite account and project
- OpenRouter API key
-
Clone the repository
git clone <repository-url> cd iic2025
-
Install dependencies
pnpm install
-
Set up environment variables
cp .env.example .env.local
Update
.env.localwith your actual values:# Appwrite Configuration NEXT_PUBLIC_APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1 NEXT_PUBLIC_APPWRITE_PROJECT_ID=your_project_id APPWRITE_API_KEY=your_api_key NEXT_PUBLIC_APPWRITE_DATABASE_ID=iic-db NEXT_PUBLIC_APPWRITE_USER_COLLECTION_ID=user NEXT_PUBLIC_APPWRITE_THREAD_COLLECTION_ID=thread NEXT_PUBLIC_APPWRITE_MESSAGE_COLLECTION_ID=message # OpenRouter Configuration OPENROUTER_API_KEY=your_openrouter_api_key NEXT_PUBLIC_OPENROUTER_BASE_URL=https://openrouter.ai/api/v1 # Weather API Configuration (Optional) NEXT_PUBLIC_OPENWEATHER_API_KEY=your_openweathermap_api_key # Application Configuration NEXT_PUBLIC_APP_URL=http://localhost:3000 NEXT_PUBLIC_APP_NAME=Digital Krishi Officer
-
Set up Appwrite Database
Create the following collections in your Appwrite database:
User Collection (
user)- username (string, required, size: 100)
- location (string, required, size: 200)
- farmsize (string, size: 60)
- crop (string array, size: 50)
- experience (string, size: 100)
- language (string, size: 100)
Thread Collection (
thread)- userId (string, required, size: 100)
- title (string, required, size: 256)
- description (string, size: 500)
- category (string, size: 100)
- priority (string, size: 50)
- status (string, size: 50)
- tags (string array, size: 50)
- messageCount (number)
- lastMessageAt (datetime)
Message Collection (
message)- threadId (string, required, size: 100)
- userId (string, required, size: 100)
- content (string, required, size: 20000)
- role (string, required, size: 50)
- contentType (string, required, size: 100)
- attachment (string, size: 500)
-
Run the development server
pnpm dev
-
Open your browser Navigate to http://localhost:3000
iic2025/
βββ src/
β βββ app/ # Next.js App Router
β β βββ (auth)/ # Authentication pages
β β β βββ login/
β β βββ api/ # API Routes
β β β βββ auth/ # Authentication endpoints
β β β βββ chat/ # Chat streaming endpoints
β β βββ globals.css
β β βββ layout.tsx
β β βββ page.tsx
β βββ components/ # React components (to be implemented)
β βββ services/ # Zustand stores
β β βββ authStore.ts
β β βββ chatStore.ts
β βββ utils/ # Utility functions & configurations
β β βββ aiModels/ # AI model configurations
β β βββ appwrite/ # Appwrite configurations
β β βββ openrouter/ # OpenRouter configurations
β β βββ types/ # TypeScript type definitions
β βββ hooks/ # Custom React hooks (to be implemented)
βββ public/ # Static assets
βββ .env.example # Environment variables template
βββ .env.local # Local environment variables
βββ README.md
The system is configured to use Google's Gemini 2.5 Flash Lite model through OpenRouter:
const MODELS = {
"google/gemini-2.5-flash-lite": {
id: "google/gemini-2.5-flash-lite",
name: "Gemini 2.5 Flash Lite",
provider: "Google",
description:
"Lightweight and fast Gemini model optimized for quick responses and cost-effectiveness",
contextLength: 1000000,
inputCost: 0.05,
outputCost: 0.15,
capabilities: ["text", "vision", "reasoning", "code", "multimodal"],
recommended: true,
},
};The application uses three main collections:
- Users: Store farmer profiles and preferences
- Threads: Organize conversations by topic
- Messages: Store individual messages in conversations
POST /api/auth/login- User loginPOST /api/auth/register- User registrationPOST /api/auth/logout- User logout
POST /api/chat/stream- Stream AI responses
The system is specifically designed for Malayalam-speaking farmers with:
- Native language processing
- Cultural context awareness
- Local farming practice knowledge
- Specialized agricultural prompts
- Context-aware responses
- Crop-specific advice
- Weather-based recommendations
- Text queries in Malayalam/English
- Voice message support
- Image upload for crop disease detection
- GPS location for region-specific advice
# Development
pnpm dev # Start development server
pnpm build # Build for production
pnpm start # Start production server
# Code Quality
pnpm lint # Run ESLint
pnpm type-check # Run TypeScript checks- Code Style: Follow TypeScript and ESLint configurations
- Components: Use functional components with hooks
- State Management: Use Zustand for global state
- Styling: Use Tailwind CSS utility classes
- API: Follow RESTful conventions for API routes
- Connect your GitHub repository to Vercel
- Configure environment variables in Vercel dashboard
- Deploy automatically on push to main branch
Ensure all environment variables are properly set in your deployment platform:
- Appwrite endpoint and credentials
- OpenRouter API key
- Application URLs and configuration
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Kerala farmers and agricultural experts for domain knowledge
- Appwrite team for the excellent BaaS platform
- OpenRouter for AI model access
- Vercel team for the AI SDK and deployment platform
For support and questions:
- Create an issue in the GitHub repository
- Contact the development team
- Check the documentation in the
docs/folder (coming soon)
Digital Krishi Officer - Empowering Kerala farmers with AI-driven agricultural expertise. πΎ