- Overview
- Features
- Tech Stack
- Project Structure
- Quick Start
- Frontend Setup
- Backend Setup
- API Documentation
- Database Schema
- Deployment
- Contributing
- License
FarmWise is a comprehensive mobile-first agricultural advisory web application designed to help farmers access crop-specific guidance, seasonal farming advice, and agricultural best practices. The application supports multiple languages (English, Hindi, Kannada) and provides expert farming knowledge in a farmer-friendly interface.
Empowering farmers with accessible, multilingual agricultural guidance to improve crop yields and farming practices through modern web technology.
- Small and medium-scale farmers
- Agricultural extension workers
- Farming communities in India
- Agricultural students and researchers
- Multi-language Support: English, Hindi (हिंदी), Kannada (ಕನ್ನಡ)
- Crop-specific Guidance: Detailed advice for 9+ major crops
- Problem Diagnosis: Solutions for pests, diseases, water stress, and more
- Seasonal Calendar: Month-wise farming activities and alerts
- Smart Search: Full-text search across crops, problems, and advice
- Mobile-first Design: Optimized for smartphones and tablets
- PWA Capabilities: Installable on mobile devices, offline support
- Touch-friendly Interface: Large buttons, swipe gestures, voice search ready
- High Contrast Design: Readable in bright sunlight conditions
- Farmer-friendly Language: Simple explanations with actionable steps
- Visual Guidance: Icons, emojis, and color-coded severity indicators
- RESTful API: Scalable backend with MongoDB database
- Real-time Search: Instant results with relevance scoring
- Responsive Design: Works on all device sizes
- Security: Rate limiting, CORS, input validation, JWT authentication
- Performance: Optimized queries, caching, compression
- Framework: React 18+ with TypeScript
- Styling: Tailwind CSS for responsive design
- Icons: Lucide React for consistent iconography
- Routing: React Router DOM for navigation
- State Management: React Hooks (useState, useContext)
- Build Tool: Vite for fast development and building
- Runtime: Node.js 18+
- Framework: Express.js for RESTful API
- Database: MongoDB with Mongoose ODM
- Security: Helmet, CORS, Rate Limiting, JWT
- Validation: Joi for input validation
- Logging: Morgan for request logging
- Hosting: Bolt Hosting (Frontend), MongoDB Atlas (Database)
- PWA: Service Worker for offline capabilities
- Environment: Docker-ready configuration
- Monitoring: Health checks and error logging
FarmWise/
├── 📁 src/ # Frontend React application
│ ├── 📁 components/
│ │ ├── 📁 common/ # Reusable UI components
│ │ │ ├── Header.jsx
│ │ │ ├── Navigation.jsx
│ │ │ └── SearchBar.jsx
│ │ ├── 📁 cards/ # Data display cards
│ │ │ ├── CropCard.jsx
│ │ │ ├── AdviceCard.jsx
│ │ │ ├── ProblemCard.jsx
│ │ │ └── SeasonalCard.jsx
│ │ └── 📁 screens/ # Main application screens
│ │ ├── WelcomeScreen.jsx
│ │ ├── HomeScreen.jsx
│ │ ├── CropsScreen.jsx
│ │ ├── ProblemsScreen.jsx
│ │ ├── AdviceScreen.jsx
│ │ ├── CalendarScreen.jsx
│ │ └── SearchScreen.jsx
│ ├── 📁 hooks/ # Custom React hooks
│ │ ├── useLanguage.js # Multi-language support
│ │ └── useSearch.js # Search functionality
│ ├── 📁 utils/ # Utility functions and data
│ │ ├── translations.js # Language translations
│ │ └── knowledgeBase.js # Agricultural data
│ ├── App.tsx # Main application component
│ ├── main.tsx # Application entry point
│ └── index.css # Global styles
├── 📁 server/ # Backend API application
│ ├── 📁 config/
│ │ └── database.js # MongoDB connection
│ ├── 📁 models/ # Database schemas
│ │ ├── Crop.js
│ │ ├── Topic.js
│ │ ├── Advice.js
│ │ ├── Calendar.js
│ │ └── User.js
│ ├── 📁 routes/ # API endpoints
│ │ ├── crops.js
│ │ ├── advice.js
│ │ ├── topics.js
│ │ ├── search.js
│ │ ├── calendar.js
│ │ └── users.js
│ ├── 📁 middleware/ # Express middleware
│ │ ├── auth.js
│ │ ├── validation.js
│ │ └── errorHandler.js
│ ├── 📁 scripts/
│ │ └── seedDatabase.js # Sample data seeding
│ ├── server.js # Express server setup
│ └── package.json
├── 📁 public/ # Static assets
│ ├── manifest.json # PWA configuration
│ ├── sw.js # Service worker
│ └── index.html # HTML template
├── package.json # Frontend dependencies
├── tailwind.config.js # Tailwind CSS configuration
├── vite.config.ts # Vite build configuration
└── README.md # This file
- Node.js 18+ installed
- MongoDB running locally or MongoDB Atlas account
- Git for version control
git clone https://github.com/your-username/farmwise-app.git
cd farmwise-app# Install frontend dependencies
npm install
# Install backend dependencies
cd server
npm install
cd ..# Backend environment
cp server/.env.example server/.env
# Edit server/.env with your MongoDB URI and JWT secret# Terminal 1: Start backend API (port 5000)
cd server
npm run dev
# Terminal 2: Start frontend (port 5173)
npm run dev- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- API Health: http://localhost:5000/health
-
HomeScreen was restored after being corrupted (invalid JSON accidentally present). If you previously saw a build error like
"Expected ";" but found ':'" referencing
src/components/screens/HomeScreen.jsx, that file was replaced with a proper React component. -
Navigation/back behavior: the app now maintains a small internal navigation stack in
src/App.tsx. The header back button restores the previous screen (e.g., Home → Crops → Advice → Back → Crops). If you prefer native browser back/forward behavior, consider converting screens to routes withreact-router-dom. -
Popular crops click:
onCropSelectis now passed fromApp.tsxintoHomeScreenso clicking a crop opens the advice view. -
ESLint / TypeScript note: you may see a lint warning from
@typescript-eslintabout unsupported TypeScript versions. Options:- Pin TypeScript to a supported version (e.g.,
5.5.3) inpackage.jsonand reinstall:npm install typescript@5.5.3 --save-dev. - Or upgrade
@typescript-eslint/*packages to versions that support your TypeScript.
- Pin TypeScript to a supported version (e.g.,
Quick sanity test (dev):
npm install
npm run dev
# In the app: Welcome → Get started → Home → Crops → click a crop → should open Advice; header Back should return to Crops# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview- Responsive Design: Mobile-first approach with Tailwind CSS
- Component Architecture: Modular, reusable React components
- State Management: Context API for language and search state
- PWA Support: Installable with offline capabilities
- Performance: Optimized with Vite bundler
# Frontend (.env)
VITE_API_BASE_URL=http://localhost:5000/api
VITE_APP_NAME=FarmWisecd server
# Install dependencies
npm install
# Start development server with auto-reload
npm run dev
# Start production server
npm start
# Seed database with sample data
npm run seed# Backend (server/.env)
PORT=5000
NODE_ENV=development
MONGODB_URI=mongodb://localhost:27017/farmwise
JWT_SECRET=your-super-secret-jwt-key-change-in-production
JWT_EXPIRE=7d
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100# Local MongoDB
mongod
# Or use MongoDB Atlas (cloud)
# Update MONGODB_URI in .env file
# Seed database (optional)
npm run seedDevelopment: http://localhost:5000/api
Production: https://your-api-domain.com/api
GET /api/crops # List all crops with pagination
GET /api/crops/categories # Get crop categories with counts
GET /api/crops/:cropId # Get detailed crop information
GET /api/crops/:cropId/advice # Get all advice for specific cropGET /api/advice/:cropId/:topicId # Get detailed crop-topic advice
GET /api/advice/:adviceId # Get advice by ID
GET /api/advice/seasonal/:month # Get seasonal advice for month
POST /api/advice/:adviceId/rate # Rate an advice entryGET /api/topics # List all problem categories
GET /api/topics/:topicId # Get detailed topic information
GET /api/topics/:topicId/crops # Get crops affected by topicGET /api/search?q={query}&language={lang}&category={cat}
GET /api/search/suggestions?q={query}GET /api/calendar # Get 12-month agricultural calendar
GET /api/calendar/:month # Get detailed month guidance
GET /api/calendar/current/guidance # Get current month's guidancelanguage: Response language (english, hindi, kannada)page: Page number for pagination (default: 1)limit: Items per page (default: 10, max: 50)sort: Sort field (name, created_at, view_count, rating)order: Sort order (asc, desc)
{
"success": true,
"data": {...},
"pagination": {
"current_page": 1,
"total_pages": 5,
"total_items": 50,
"items_per_page": 10
}
}{
id: "tomato",
name: {
english: "Tomato",
hindi: "टमाटर",
kannada: "ಟೊಮೆಟೊ"
},
emoji: "🍅",
category: "vegetables",
description: { english: "...", hindi: "...", kannada: "..." },
growing_seasons: ["kharif", "rabi"],
topics: 12,
view_count: 1250,
featured: true
}{
id: "tomato_water_stress",
crop: "Tomato",
crop_id: "tomato",
problem: "Water Stress",
topic_id: "water_stress",
severity: "high",
category: "water_management",
effect: { english: "...", hindi: "...", kannada: "..." },
advice: { english: "...", hindi: "...", kannada: "..." },
action_steps: { english: [...], hindi: [...], kannada: [...] },
prevention_tips: { english: [...], hindi: [...], kannada: [...] },
scientific_explanation: "...",
seasonal_relevance: ["march", "april", "may"],
related_topics: ["tomato_heat_stress"]
}- Text indexes for full-text search
- Compound indexes for crop_id + topic_id queries
- Single field indexes for common filters
# Build production version
npm run build
# Deploy to Bolt Hosting (automatic)
# Visit: https://farmwise-agricultura-20r1.bolt.host# Install Heroku CLI
heroku create farmwise-api
heroku config:set NODE_ENV=production
heroku config:set MONGODB_URI=your-mongodb-atlas-uri
heroku config:set JWT_SECRET=your-production-secret
git push heroku main# Dockerfile (server/)
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 5000
CMD ["npm", "start"]# PM2 for production process management
npm install -g pm2
pm2 start server.js --name farmwise-api
pm2 startup
pm2 saveNODE_ENV=production
PORT=5000
MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/farmwise
JWT_SECRET=super-secure-production-secret-key
ALLOWED_ORIGINS=https://farmwise-agricultura-20r1.bolt.hostWe welcome contributions from the agricultural and developer communities!
- 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
- 🌾 Agricultural Content: Add crops, problems, seasonal guidance
- 🌍 Translations: Improve Hindi/Kannada translations or add new languages
- 🎨 UI/UX: Enhance farmer-friendly interface design
- 🔧 Backend: API optimizations, new features, security improvements
- 📱 Mobile: PWA enhancements, offline capabilities
- 📚 Documentation: Improve guides, add tutorials
- Follow existing code structure and naming conventions
- Add proper validation for new endpoints
- Include multi-language support for user-facing content
- Write clear commit messages
- Test thoroughly before submitting
// Add to server/scripts/seedDatabase.js
const newCrop = {
id: 'mango',
name: {
english: 'Mango',
hindi: 'आम',
kannada: 'ಮಾವಿನ ಹಣ್ಣು'
},
emoji: '🥭',
category: 'fruits',
// ... additional fields
};This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2025 FarmWise Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
- Farmers: For inspiring this project and providing real-world insights
- Agricultural Experts: For validating farming practices and advice
- Open Source Community: For the amazing tools and libraries used
- Translators: For Hindi and Kannada language support
- Contributors: Everyone who helps improve FarmWise
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: farmwise.support@example.com
- Documentation: Wiki
Made with ❤️ for farmers worldwide
🌱 Growing better futures through technology 🌱
