Skip to content

Victor-W-N/SmartFarmingSystem

Repository files navigation

SmartFarmingSystem

This system provides a secure digital platform for tracking, verifying, and managing subsidized and commercial fertilizers from manufacturers and suppliers to farmers. Inspired by recent counterfeits in Kenya. Its goal is to eliminate counterfeit fertilizer, improve accountability, and protect farmer productivity. Overview

The Smart Farming System enables end-to-end traceability of fertilizer batches. It allows farmers to confirm authenticity, suppliers to manage inventory, and administrators to maintain oversight of the distribution pipeline.

Key Features

Fertilizer Input Verification (QR and USSD)

Farmers can check fertilizer authenticity by scanning a QR code on the bag.

A USSD-based verification process is also available through Africa’s Talking for regions with poor internet access.

Supplier Management Portal

Secure dashboard for suppliers to register fertilizer batches, manage inventory, and generate unique QR codes for each batch.

Role-Based Access Control (RBAC)

Different system roles including System Administrator, Registered Supplier, and Agro-Dealer to ensure secure data handling.

Farmer Education Chatbot

A simple chatbot providing farming tips and guidance in both English and Kiswahili.

Project Structure

The project uses Python Flask with a structured layout for scalability:

app.py: Main Flask application responsible for routing, business logic, and web page rendering.

db.py: Handles MySQL database connectivity using secure parameterized queries.

templates/: Contains HTML (Jinja2) templates for all system pages.

static/: Holds UI resources (CSS, JavaScript) and dynamically generated QR code images.

venv/: Contains the project’s virtual environment and dependencies.

Technology Stack

Backend: Python (Flask) Database: MySQL USSD Integration: Africa’s Talking Libraries Used: Flask, mysql-connector-python, qrcode

Installation and Setup

This guide is intended for quick installation during system submission or demonstration.

Prerequisites

Python 3.x installed

MySQL Server (or XAMPP/WAMP)

Transfer Project Files

Copy the entire SMARTFARMING_SYSTEM folder to your computer.

Open Command Prompt or Terminal and navigate to the project root directory.

Activate the Virtual Environment

Activate the included virtual environment to load all dependencies.

Database Setup

Start MySQL Server.

Create a database named smartfarming_db.

Import the provided SQL schema to create required tables (users, fertilizer_batch, etc.).

Open db.py and verify that the database connection details match your local setup.

Run the Application

With the virtual environment active and database configured, run the Flask server.

The system will display a local address such as http://127.0.0.1:5000/ which you can open in a web browser.

Testing

The following tests should be conducted during demonstration:

QR Code Generation Test

Register a new fertilizer batch and confirm that a new QR code image is created in the static/qrcodes folder.

Verification Module Test

Visit the Farmer Verification page and enter a valid Batch ID.

Confirm that the system correctly fetches data from the database and returns an “Authentic” result.

Security Test (SQL Injection)

Attempt to log in with malicious input.

Login should fail, proving that secure parameterized queries are in use.

About

This system provides a secure digital platform for tracking, verifying, and managing subsidized and commercial fertilizers from manufacturers and suppliers to farmers. Inspired by recent counterfeits in Kenya. Its goal is to eliminate counterfeit fertilizer, improve accountability, and protect farmer productivity.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors