A comprehensive web application connecting local farmers with buyers, built with PHP + MongoDB backend and HTML/CSS/JavaScript frontend featuring an agricultural color palette and complete marketplace functionality.
Author Name: DEEPAK P S
Mail id : [email protected]
Author Name: TILAK B V
Mail id : -
Author Name: DARSHAN S M
Mail id : -
Author Name: KARTHIK
Mail id : -
Farmer Lookup eliminates the middleman by providing farmers with digital tools to manage their business while offering buyers transparent, hyper-local access to fresh produce. The platform focuses on efficiency, trust, and community impact.
- Features Overview
- Technical Architecture
- Installation & Setup
- How to Use
- API Documentation
- File Structure
- Color Palette & Design
- Database Schema
- Configuration
- Troubleshooting
- ✅ User-friendly, customizable profile pages
- ✅ Farm story, images, and certifications (Organic, GAP)
- ✅ Dynamic catalog with high-quality photos
- ✅ Detailed product descriptions (specific varieties)
- ✅ Real-time availability toggles ("Available Now", "Coming Soon", "Sold Out")
- ✅ Search by current location or delivery address
- ✅ Distance filters (5-50 miles)
- ✅ Product type filtering (leafy greens, meats, etc.)
- ✅ Availability filtering (today/this week)
- ✅ Farming practice filters (No-Till, Hydroponic, Organic)
- ✅ In-app messaging for product inquiries
- ✅ Simple retail checkout system
- ✅ Custom bulk order support
- ✅ Recurring order subscriptions
- ✅ Professional transaction tracking
- ✅ Buyers review farmers (quality, professionalism, delivery)
- ✅ Farmers review buyers (payment, communication, pickup)
- ✅ Verified transaction requirement for authenticity
- ✅ Trust score calculation
- ✅ Geo-fencing for delivery zone management
- ✅ Zone-specific delivery fees and minimums
- ✅ Interactive address plotting
- ✅ Distance-based product filtering
- ✅ Mobile-friendly dashboard for stock updates
- ✅ Automatic inventory deduction on orders
- ✅ Low-stock alerts for farmers
- ✅ Overselling prevention
- HTML5 - Semantic structure with accessibility features
- CSS3 - Agricultural color palette with responsive design
- Vanilla JavaScript - Modern ES6+ with class-based architecture
- Agricultural Icons - Emoji-based icon system (🚜🌾🥬🍎)
- PHP 8.0+ - RESTful API architecture
- MongoDB - NoSQL document database for scalability
- JWT Authentication - Secure token-based sessions
- File Upload System - Image handling for products/profiles
- Responsive Design - Mobile-first approach
- Location Services - GPS integration and distance calculations
- Real-time Updates - Dynamic content loading
- Security - Input validation, SQL injection prevention, XSS protection
- PHP 8.0+ with extensions:
mongodb,curl,gd,fileinfo - MongoDB 4.4+ (Community Edition)
- Web Server (Apache/Nginx) or PHP built-in server
- Composer (for MongoDB PHP library)
# Navigate to project directory
cd C:\FarmerLookup
# Install MongoDB PHP library via Composer
composer require mongodb/mongodb
# Verify PHP extensions
php -m | grep -E "(mongodb|curl|gd|fileinfo)"Option A: Local MongoDB Installation
- Download MongoDB Community Server
- Install with default settings
- Start MongoDB service:
# Windows net start MongoDB # Or start manually mongod --dbpath C:\data\db
Option B: MongoDB Atlas (Cloud)
- Create free cluster at mongodb.com/atlas
- Get connection string
- Update environment variables
Create a .env file or set environment variables:
# Database Configuration
MONGO_HOST=localhost
MONGO_PORT=27017
MONGO_DATABASE=farmer_lookup
MONGO_USERNAME=
MONGO_PASSWORD=
# Application Security
JWT_SECRET=your-super-secure-secret-key-here
# File Upload Settings
UPLOAD_MAX_SIZE=10485760 # 10MB in bytesMethod 1: PHP Built-in Server
cd C:\FarmerLookup
php -S localhost:8000Method 2: Apache/Nginx
- Place project in web root directory
- Configure virtual host pointing to
C:\FarmerLookup - Ensure
.htaccesssupport for clean URLs
- Open browser: http://localhost:8000
- Register as farmer or buyer
- Start exploring the marketplace!
To automate a fast smoke test of the API after importing the SQL and starting XAMPP, there's a PowerShell script at scripts/test_api.ps1 that will run through seed, login, product creation, order creation, messages and reviews.
Run it from project root in PowerShell:
cd C:\xampp1\htdocs\FarmerLookup
.\scripts\test_api.ps1If your site is served at a different base URL, pass it with -BaseUrl, e.g.: .-scripts\test_api.ps1 -BaseUrl 'http://localhost:8000'.
- Start XAMPP (Apache + MySQL) and ensure both services are running.
- Import the SQL schema:
- Using phpMyAdmin (http://localhost/phpmyadmin): import
database/schema.sql. - Or from PowerShell (example using default root user with no password):
mysql -u root < .\database\schema.sql- Seed demo data (creates a farmer and buyer and a sample product):
php .\scripts\seed.php- Run the smoke test to validate API endpoints end-to-end:
.\scripts\test_api.ps1- If you used a different base URL, pass it to the smoke test script using
-BaseUrl.
- Register → Choose "Buyer" account type
- Browse → Use location-based search to find local farmers
- Filter → Apply distance, category, and farming method filters
- Connect → Message farmers with specific questions
- Order → Add products to cart and checkout
- Review → Rate your experience after delivery
- Register → Choose "Farmer" account type
- Profile Setup → Add farm details, story, and certifications
- Add Products → Create product listings with photos and pricing
- Manage Inventory → Update stock levels and availability
- Process Orders → Receive and fulfill customer orders
- Communicate → Respond to buyer inquiries
graph TD
A[Homepage] --> B{User Type?}
B -->|Buyer| C[Marketplace Search]
B -->|Farmer| D[Farm Dashboard]
C --> E[Filter Products]
E --> F[View Product Details]
F --> G[Message Farmer]
G --> H[Add to Cart]
H --> I[Checkout]
D --> J[Manage Products]
J --> K[Update Inventory]
K --> L[Process Orders]
POST /api/auth/register.php
{
"user_type": "farmer|buyer",
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"password": "securepassword",
"address": "123 Farm Road",
"city": "Springfield",
"state": "IL",
"zip_code": "62701"
}POST /api/auth/login.php
{
"email": "[email protected]",
"password": "securepassword",
"user_type": "farmer"
}GET /api/products/search.php
- Query Parameters:
search,latitude,longitude,distance,category,farming_method - Returns: Array of products with farmer details
POST /api/products/create.php (Requires Auth)
{
"name": "Organic Tomatoes",
"description": "Fresh heirloom tomatoes",
"category": "vegetables",
"price_per_unit": 4.50,
"unit_type": "lb",
"quantity_available": 100,
"farming_method": "organic"
}POST /api/orders/create.php (Requires Auth)
GET /api/orders/history.php (Requires Auth)
PUT /api/orders/update-status.php (Requires Auth)
C:\FarmerLookup/
├── 📄 index.html # Landing page
├── 📄 register.html # User registration
├── 📄 login.html # User authentication
├── 📄 marketplace.html # Product search & discovery
├── 📄 README.md # This documentation
│
├── 📁 assets/
│ ├── 📁 css/
│ │ └── 📄 style.css # Agricultural theme CSS
│ ├── 📁 js/
│ │ └── 📄 main.js # Frontend JavaScript
│ └── 📁 images/ # Platform images
│
├── 📁 api/ # PHP Backend
│ ├── 📄 config.php # Database & app configuration
│ ├── 📁 auth/
│ │ ├── 📄 register.php # User registration endpoint
│ │ └── 📄 login.php # User login endpoint
│ ├── 📁 products/
│ │ ├── 📄 search.php # Product search API
│ │ └── 📄 create.php # Product creation API
│ └── 📁 orders/
│ ├── 📄 create.php # Order creation
│ └── 📄 history.php # Order history
│
├── 📁 uploads/ # User uploaded files
└── 📄 composer.json # PHP dependencies
The agricultural color scheme creates a warm, earth-friendly atmosphere:
--primary-green: #2E7D32 /* Deep Forest Green */
--secondary-green: #4CAF50 /* Fresh Green */
--accent-green: #66BB6A /* Light Green */
--earth-brown: #8D6E63 /* Rich Earth Brown */
--wheat-gold: #FFA000 /* Golden Wheat */
--harvest-orange: #FF6F00 /* Harvest Orange */--sky-blue: #1976D2 /* Clear Sky Blue */
--soil-dark: #3E2723 /* Dark Soil */
--cream-white: #FFF8E1 /* Cream Background */
--sage-light: #E8F5E8 /* Light Sage */- 🚜 Tractor - Farm/Farmer representation
- 🌾 Wheat - Harvest/Grains
- 🥬 Vegetables - Fresh produce
- 🍎 Fruits - Fresh fruits
- 📍 Location - Geographic features
- 💬 Messages - Communication
- ⭐ Reviews - Rating system
- 🛒 Cart - Shopping features
users - User accounts (farmers & buyers)
{
_id: ObjectId,
user_type: "farmer|buyer",
first_name: String,
last_name: String,
email: String,
password_hash: String,
profile: {
// Farmer-specific or buyer-specific data
},
location: {
address: String,
city: String,
state: String,
zip_code: String,
coordinates: [longitude, latitude]
},
created_at: ISODate,
updated_at: ISODate
}products - Product listings
{
_id: ObjectId,
farmer_id: ObjectId,
name: String,
description: String,
category: String,
price_per_unit: Number,
unit_type: String,
quantity_available: Number,
farming_method: String,
images: [String],
availability_status: String,
created_at: ISODate
}orders - Purchase transactions
{
_id: ObjectId,
buyer_id: ObjectId,
farmer_id: ObjectId,
items: [{
product_id: ObjectId,
quantity: Number,
unit_price: Number
}],
total_amount: Number,
status: String,
delivery_method: String,
created_at: ISODate
}| Variable | Default | Description |
|---|---|---|
MONGO_HOST |
localhost |
MongoDB server address |
MONGO_PORT |
27017 |
MongoDB port |
MONGO_DATABASE |
farmer_lookup |
Database name |
JWT_SECRET |
farmer-lookup-secret-key |
JWT signing secret |
UPLOAD_MAX_SIZE |
10485760 |
Max file upload size (bytes) |
Edit api/config.php for:
- File upload settings
- Authentication token lifetime
- Distance calculation settings
- Default search radius
1. MongoDB Connection Failed
# Check if MongoDB is running
mongosh --eval "db.runCommand({connectionStatus: 1})"
# Restart MongoDB service
net stop MongoDB && net start MongoDB2. File Upload Issues
- Check folder permissions on
uploads/directory - Verify PHP upload limits in
php.ini:upload_max_filesize = 10M post_max_size = 10M
3. JavaScript Errors
- Open browser developer tools (F12)
- Check console for error messages
- Ensure all asset files are loading correctly
4. CSS Not Loading
- Verify file paths in HTML files
- Check web server configuration
- Clear browser cache
Enable debug mode by adding to api/config.php:
ini_set('display_errors', 1);
error_reporting(E_ALL);# Check database status
mongosh --eval "db.adminCommand('listCollections')"
# View collections
mongosh farmer_lookup --eval "show collections"
# Check user count
mongosh farmer_lookup --eval "db.users.countDocuments()"- MongoDB Indexing - Optimized queries for location and search
- Image Optimization - Compressed uploads with size limits
- Lazy Loading - Products load as user scrolls
- Caching - Browser caching for static assets
- Mobile-First - Responsive design for all devices
- Database Sharding - MongoDB supports horizontal scaling
- CDN Integration - Serve static assets from CDN
- Load Balancing - Multiple PHP server instances
- Image Storage - External services like AWS S3
This is a complete, production-ready marketplace platform. The codebase is organized for easy extension and customization.
- Payment gateway integration (Stripe, PayPal)
- SMS notifications for order updates
- Advanced analytics dashboard
- Mobile app development
- Multi-language support
- Subscription management system
This project is created for educational and commercial use. All dependencies maintain their respective licenses.
Farmer Lookup supports local food systems by:
- Increasing farmer revenue through direct sales
- Reducing food miles with local sourcing
- Building community connections between producers and consumers
- Supporting sustainable agriculture through transparent practices
- Eliminating middleman markups for better prices
Ready to connect your local food community?
- Clone/Download the project to
C:\FarmerLookup - Follow setup instructions above
- Register as a farmer or buyer
- Start building your local food network!
Visit: http://localhost/FarmerLookup/index.html to begin your journey! 🌱
Made with 💚 for local communities
