A web application that connects small/medium farmers and buyers (markets, aggregators, retailers) and provides personalized recommendations using machine learning.
- User registration and authentication
- Product listing (crop type, quantity, price, quality, harvest date)
- Edit and delete product functionality
- Dashboard to manage products
- Personalized recommendations for buyers to target
- User registration and authentication
- Product browsing and search functionality
- Advanced filtering options (crop type, price range, quality)
- Product detail pages with nutritional information
- Purchase functionality
- Personalized product recommendations
- Collaborative filtering based on user interactions
- Content-based recommendations
- Popular products fallback
- Integration with Open Food Facts API for nutritional data
- Backend: Python Flask
- Frontend: HTML, CSS (Bootstrap), JavaScript
- Database: SQLite
- ML Library: scikit-learn (Nearest Neighbors)
- API: Open Food Facts API
- Python 3.7+
- pip (Python package installer)
- Clone the repository:
git clone https://github.com/OfficialDiLi/FarmConnect.git
cd FarmConnect- Create a virtual environment:
python -m venv .venv
# On Linux/Mac:
source .venv/bin/activate
# On Windows:
.venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Generate the recommendation model:
python ml_model.py- Start the application:
python main.pyThe application will be accessible at http://localhost:5000
- Make sure you have Python 3.7+ installed
- Use PowerShell or Command Prompt for the installation steps
- Virtual environment activation command:
.venv\Scripts\activate - If you encounter issues with
openfoodfactspackage on Windows, you might need to install Microsoft C++ Build Tools
- Use the standard installation commands as listed above
- Virtual environment activation command:
source .venv/bin/activate
farm/
├── main.py # Flask application
├── ml_model.py # ML model training
├── model.pkl # Trained model file
├── requirements.txt # Python dependencies
├── Project.md # Original project specification
├── .env # Environment variables
├── datasets/
│ ├── data.py # Data generation script
│ ├── interactions.csv # Sample interaction data
│ ├── products.csv # Sample product data
│ ├── transactions.csv # Sample transaction data
│ └── users.csv # Sample user data
├── templates/ # HTML templates
│ ├── base.html
│ ├── index.html
│ ├── products.html
│ ├── product_detail.html
│ ├── recommendations.html
│ ├── login.html
│ ├── register.html
│ ├── farmer_dashboard.html
│ ├── buyer_dashboard.html
│ └── sell.html
└── instance/
- Register as a farmer
- Login to your account
- Click "Add New Product" to list your crops
- Manage your products using "Edit" or "Delete" options
- Check your dashboard for recommendations and product performance
- Register as a buyer
- Browse products using search and filters
- View detailed product information including nutritional data
- Purchase products directly
- Get personalized recommendations based on your behavior
The recommendation system uses multiple approaches:
- Collaborative Filtering: Based on user interaction history
- Content-Based: Based on crop types and attributes
- Popularity-Based: Fallback for users with no interaction history
The system tracks:
- Product views
- Purchases
- User preferences
User: Farmer/Buyer accounts with rolesProduct: Crop listings with details (type, quantity, price, quality)Interaction: User-product interactions (views, clicks, purchases)Transaction: Purchase records
GET /- Home pagePOST /register- User registrationPOST /login- User authenticationGET /dashboard- User dashboardGET /products- Product listings with filtersGET /product/<id>- Product detailsPOST /buy/<id>- Purchase productsGET /sell- List new products (farmers only)GET /edit_product/<id>- Edit product (farmers only)POST /delete_product/<id>- Delete product (farmers only)GET /recommendations- Personalized recommendations
To test the recommendation system:
- Create multiple user accounts
- As a buyer, interact with various products (view, purchase)
- Check recommendations to see personalized suggestions
- As a farmer, add products and monitor their performance
- Migration to PostgreSQL and FastAPI
- Redis caching for recommendations
- Elasticsearch for advanced search
- Mobile-responsive improvements
- More sophisticated ML algorithms
- Real-time recommendation updates
- Seller/buyer ratings and reviews
- Location-based recommendations
- Seasonal crop recommendations
This project is open source and available under the MIT License.
- 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
- The recommendation model requires sufficient interaction data to provide accurate suggestions
- SQLite may have performance limitations with large datasets
For support, please open an issue in the GitHub repository.