Connecting Farmers and Buyers with AI-Powered Agricultural Solutions
FarmLink AI is a comprehensive agricultural marketplace platform that bridges the gap between farmers and buyers, powered by artificial intelligence and modern web technologies.
๐ Live Demo: https://farmlinkai.vercel.app/
- Direct Farm-to-Buyer Trading: Connect farmers directly with buyers, eliminating middlemen
- Real-time Inventory Management: Track crop availability and stock levels
- Smart Search & Filtering: Find crops by category, location, price range, and more
- Secure Payment Integration: Razorpay payment gateway for safe transactions
- Order Tracking: Real-time shipment tracking with multiple courier integrations
- Crop Recommendations: AI-driven crop suggestions based on soil, climate, and market demand
- Price Forecasting: National-level commodity price predictions using Agmarknet data
- Pest & Disease Detection: Image-based analysis for early pest/disease identification
- Weather Integration: Real-time weather data for farming decisions
- Expert Forum: Q&A platform for agricultural experts and farmers
- Learning Hub: Educational articles on modern farming techniques
- Rating & Review System: Build trust through verified buyer-seller ratings
- Achievement System: Gamification to encourage platform engagement
- KYC Verification: Secure seller verification with encrypted document storage
- Role-Based Access Control: Admin, Farmer, and Buyer roles with specific permissions
- Fraud Prevention: Rate limiting, IP tracking, and suspicious activity detection
- Data Encryption: End-to-end encryption for sensitive information
- Framework: Flask (Python 3.11)
- Database: PostgreSQL with SQLAlchemy ORM
- Authentication: Flask-Login with secure session management
- Email: Flask-Mail with SMTP support
- Task Scheduling: APScheduler for background jobs
- UI Framework: Bootstrap 5
- JavaScript: Vanilla JS with modern ES6+ features
- Icons: Font Awesome
- Image Processing: Cropper.js for profile pictures
- AI Model: Google Gemini API for intelligent recommendations
- Price Data: Agmarknet API (data.gov.in)
- Weather API: OpenWeatherMap integration
- Data Analysis: Pandas, NumPy, Statsmodels for forecasting
- Payment Gateway: Razorpay
- SMS Notifications: Twilio
- Shipment Tracking: Shiprocket, India Post APIs
- Web Server: Vercel Serverless Functions
- Platform: Vercel (recommended)
- Database: PostgreSQL (managed, e.g., Supabase)
- File Storage: Local filesystem (upgradeable to S3)
- Python 3.11 or higher
- PostgreSQL 12 or higher
- pip (Python package manager)
- Git
git clone https://github.com/Dipendra2003/Farmlink-AI.git
cd Farmlink-AIpython -m venv .venv
# Windows
.venv\Scripts\activate
# Linux/Mac
source .venv/bin/activatepip install -r requirements.txtCopy .env.example to .env and fill in your values:
cp .env.example .envRequired Environment Variables:
# Application
BASE_URL=http://localhost:5000
SESSION_SECRET=your-secret-key-here
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/farmlink_db
# AI APIs
GEMINI_API_KEY=your-gemini-api-key
WEATHER_API_KEY=your-weather-api-key
AGMARKNET_API_KEY=your-agmarknet-api-key
# Email (Gmail)
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
MAIL_DEFAULT_SENDER=your-email@gmail.com
# Payment
RAZORPAY_KEY_ID=your-razorpay-key-id
RAZORPAY_KEY_SECRET=your-razorpay-secret
# Encryption
KYC_ENCRYPTION_KEY=generate-using-fernet
ENCRYPTION_KEY=generate-using-fernetGenerate Encryption Keys:
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"# The app will automatically create tables on first run
python main.pyAccess the application and register with role "admin" for the first user.
python main.pyAccess at: http://localhost:5000
gunicorn main:app --workers 4 --bind 0.0.0.0:5000git add .
git commit -m "Ready for deployment"
git push origin main- Sign up at vercel.com
- Connect your GitHub repository
- Set up a managed PostgreSQL database (e.g., Supabase, Neon)
- Copy the Database connection URL
- Import your repository to Vercel
- The framework preset should automatically detect Python/Flask
- Vercel uses
vercel.jsonfor configuration which is already provided
Add all variables from .env.example in the Vercel Dashboard Settings:
BASE_URL: Your Vercel URL (e.g., https://farmlinkai.vercel.app)DATABASE_URL: Your PostgreSQL connection stringSESSION_SECRET: Generate a random string- All API keys and credentials
Click "Deploy" and wait for the build to complete.
Farmlink-AI/
โโโ static/ # Static files (CSS, JS, images)
โ โโโ css/
โ โโโ js/
โ โโโ img/
โ โโโ uploads/ # User-uploaded files
โโโ templates/ # HTML templates
โ โโโ admin/ # Admin dashboard
โ โโโ ai/ # AI features
โ โโโ auth/ # Authentication
โ โโโ dashboard/ # User dashboards
โ โโโ marketplace/ # Product listings
โ โโโ ...
โโโ app.py # Flask application factory
โโโ main.py # Application entry point
โโโ models.py # Database models
โโโ routes.py # Main routes
โโโ forms.py # WTForms definitions
โโโ config.py # Configuration
โโโ requirements.txt # Python dependencies
โโโ vercel.json # Vercel deployment config
โโโ .env.example # Environment variables template
- Password Hashing: Werkzeug secure password hashing
- CSRF Protection: Flask-WTF CSRF tokens
- Session Security: HTTPOnly, Secure, SameSite cookies
- Rate Limiting: Flask-Limiter for API endpoints
- Input Sanitization: Bleach for HTML sanitization
- SQL Injection Prevention: SQLAlchemy ORM
- XSS Protection: Template auto-escaping
- File Upload Validation: Type and size restrictions
- KYC Encryption: Fernet symmetric encryption
- Full system access
- User management
- Crop approval/rejection
- Order management
- Analytics dashboard
- System settings
- List crops for sale
- Manage inventory
- Process orders
- View earnings
- Access AI tools
- KYC verification
- Browse marketplace
- Place orders
- Track shipments
- Rate products
- View purchase history
- Access learning resources
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Developer: Dipendra GitHub: @Dipendra2003 Repository: Farmlink-AI
- Google Gemini API for AI capabilities
- Agmarknet (data.gov.in) for agricultural data
- Razorpay for payment processing
- Vercel for hosting platform
- Bootstrap team for UI framework
- Flask community for excellent documentation
GET /api/crops- List all available cropsGET /api/crop/<id>- Get crop detailsGET /api/crop/<id>/stock- Check stock availability
POST /api/cart/add/<crop_id>- Add to cartPOST /api/order/place- Place orderGET /api/orders/my- Get user ordersPOST /api/rating/submit- Submit rating
GET /api/admin/analytics- System analyticsPOST /api/admin/crop/approve/<id>- Approve cropGET /api/admin/users- List users
- Large file uploads may timeout on free hosting tiers
- SMS notifications require Twilio credits
- Weather API has rate limits on free tier
- Mobile app (React Native)
- Multi-language support (Hindi, regional languages)
- Blockchain for supply chain tracking
- Advanced ML models for yield prediction
- Integration with government schemes
- Farmer insurance integration
- Cold storage facility finder
- Soil testing service integration
- Initial release
- Core marketplace functionality
- AI-powered features
- Payment integration
- Order tracking
- Community features
Made with โค๏ธ for Indian Farmers