Skip to content

Latest commit

 

History

68 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Farm2Market - Farmer-to-Buyer Marketplace Platform

A full-featured, modern multi-role e-commerce platform built with Django. Farm2Market directly connects farmers with buyers, enabling streamlined product listings, cart management, order tracking, and logistics coordination — eliminating the need for middlemen.

Python Django PostgreSQL Tailwindcss HTML5 License

Features

Farmer

  • Registration - Register with farm name, location, and bio
  • Farmer Dashboard - Manage products (add, edit, view stock) from a dedicated dashboard
  • Order Management - Receive and handle orders: confirm, reject, assign logistics, dispatch, and mark as delivered
  • Inventory Insights - View in-stock / out-of-stock product statistics at a glance
  • Real-time Notifications - Notification badges for new pending orders

Buyer

  • Registration - Register with a delivery address
  • Product Discovery - Browse and search products by name or category
  • Smart Cart - Add products to cart with support for session-based cart for unauthenticated users
  • Cart Merge on Login - Anonymous cart merges seamlessly into the user account on login
  • Checkout - Checkout groups items by farmer and creates separate per-farmer orders
  • Order History - View past orders and real-time status updates
  • Receipt Confirmation - Confirm receipt to complete an order
  • Delivery Notifications - Notification badges for delivered orders

Shared

  • Role-based Access Control - Views protected per user role (farmer/buyer)
  • Notification System - Per-user, per-order messages surfaced as navbar badges
  • Responsive UI - Shared base template with a consistent footer across all pages
  • Admin Panel - All models registered and manageable via Django Admin

Technology Stack

Backend

  • Framework: Django 6.0.3
  • Database: PostgreSQL via Supabase (production) / SQLite (local development)
  • Authentication: Django built-in authentication
  • Image Handling: Pillow 12.2

Frontend

  • Template Engine: Django Templates (HTML/CSS/JS)
  • Icons & Styling: Custom CSS with native browser styles

Screenshots

Farmer Dashboard

Farmer Dashboard

Buyer Dashboard

Buyer Dashboard

Product Listing

Product Listing

Cart Page

Shopping Cart

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)
  • Virtual environment (recommended)
  • PostgreSQL / Supabase account (for production database)

Installation

1. Clone the Repository

git clone <repo-url>
cd Farm2Market

2. Create Virtual Environment

py -m venv my_env
# On Windows
my_env\Scripts\activate
# On macOS/Linux
source my_env/bin/activate

3. Install Dependencies

Navigate to the directory containing manage.py:

cd Farm2Market
pip install -r requirements.txt

4. Environment Configuration

Copy the example file and fill in your values:

copy .env.example .env

Edit .env with the following variables:

# Django Settings
SECRET_KEY=your-secret-key-here
DEBUG=True

# Database (leave unset to use local SQLite)
DATABASE_URL=postgresql://user:password@host:5432/dbname

# Supabase S3 Media Storage
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_STORAGE_BUCKET_NAME=media
AWS_S3_ENDPOINT_URL=https://your-project.supabase.co/storage/v1/s3
AWS_S3_REGION_NAME=ap-southeast-1

Tip: Leave DATABASE_URL unset to use a local SQLite database for development.

5. Configure Media Storage (Supabase S3)

Farm2Market uses Supabase Storage (S3) to handle user-uploaded product images.

  • Create a Public bucket named media in your Supabase project.
  • Inside the bucket, create a folder named product_images.
  • Add your S3 Connection details to the .env file as shown above.

6. Database Migration

# First-time or after model changes:
python manage.py makemigrations
python manage.py migrate

7. Create Superuser

python manage.py createsuperuser

8. (Optional) Seed Admin Data

Visit http://127.0.0.1:8000/admin/ to:

  • Add product Category entries (Vegetables, Fruits, Grains)
  • Add Logistic providers (Pathao, Steadfast, Uber)

9. Run Development Server

python manage.py runserver

Visit http://127.0.0.1:8000/ in your browser.

Project Structure

Farm2Market/              ← Repo root
└── Farm2Market/          ← Django project root (manage.py lives here)
    ├── Farm2Market/      ← Project config (settings, urls, wsgi, asgi)
    ├── apps/
    │   ├── accounts/     ← Auth, user profiles (Farmer & Buyer)
    │   ├── products/     ← Product catalog & categories
    │   ├── cart/         ← Shopping cart (DB + session-based)
    │   ├── orders/       ← Order lifecycle & logistics
    │   └── notifications/← Per-user, per-order notification system
    └── templates/
        ├── base.html     ← Shared layout
        ├── footer.html
        ├── accounts/
        ├── cart/
        ├── orders/
        └── products/

Database Models

  • Profile — Extends Django's User with a role (farmer or buyer). Farmers have farm_name, farm_location, and bio; buyers have a delivery_address.

  • Category — Groups products into categories (e.g., Vegetables, Fruits, Grains). One-to-many with Products.

  • Product — Listed by farmers with name, price_per_unit, stock_quantity, unit, and an optional image.

  • Cart / CartItem — One persistent cart per buyer. Anonymous users get a session-based cart that merges on login.

  • Order / OrderItem — Created per farmer on checkout with a price snapshot. Order status flow:

    PENDING
      ├── CONFIRMED → ASSIGNED → OUT_FOR_DELIVERY → DELIVERED → COMPLETED
      ├── REJECTED  (by farmer)
      └── CANCELLED (by buyer)
    
  • Logistic — Delivery providers (e.g., Pathao, Steadfast) assigned by farmers at the CONFIRMED stage. Stores name and an optional contact_number.

  • Notification — Per-user, per-order messages with an is_read flag, surfaced as navbar badges via context processors.

Admin Features

  • Django Admin Panel - Full CRUD operations on all models
  • Category Management - Create and organize product categories
  • Product Management - Add and manage farmer products with images
  • Order Management - View and update order statuses
  • User Management - Manage farmer and buyer accounts
  • Logistic Management - Add and configure delivery providers
  • Stock Control - Monitor and update product inventory

Security Features

  • CSRF protection on all forms
  • Password validation and hashing via Django's auth system
  • Login-required decorators on all protected views
  • Role-based access control (farmers cannot access buyer views and vice versa)
  • Environment variables for sensitive configuration data
  • Session security for anonymous cart management

Deployment

Environment Variables Reference

Variable Required Description
SECRET_KEY Yes Django secret key for cryptographic signing
DEBUG No True for development, False for production
DATABASE_URL No PostgreSQL connection string; defaults to SQLite
AWS_ACCESS_KEY_ID Yes Supabase S3 Access Key for image uploads
AWS_SECRET_ACCESS_KEY Yes Supabase S3 Secret Key
AWS_STORAGE_BUCKET_NAME Yes Target S3 bucket (e.g. media)
AWS_S3_ENDPOINT_URL Yes Supabase S3 Endpoint URL

The project uses dj-database-url with a DATABASE_URL environment variable, making it straightforward to deploy on platforms like Render, Railway, or Heroku with a Supabase PostgreSQL database.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Authors

Reports & Documentation

Project documents are located in the /Reports directory:

  • Project_Proposal.pdf — Initial project proposal
  • SRS.pdf — Software Requirements Specification
  • Project Progress Report.pdf — Progress report

Acknowledgments

  • Django Framework Documentation
  • Supabase for hosted PostgreSQL
  • Pillow for image handling

Note

Some earlier commits may appear under a different author name due to initial Git configuration issues. This has been resolved, and all future commits are correctly linked to my GitHub profile.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages