Skip to content

【Hit that ⭐️ if you like what you see!】A Flask-based web application serving as a comprehensive biosecurity guide for agricultural pests and weeds in New Zealand. Features role-based access control, detailed pest/weed information management, and responsive design for agronomists, staff, and administrators.

License

Notifications You must be signed in to change notification settings

ChanMeng666/biosecurity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Banner

🌱 Biosecurity Guide for Agricultural Pests and Weeds

Comprehensive Digital Platform for Agricultural Risk Management

An innovative web-based biosecurity platform that leverages modern Flask technology to provide comprehensive agricultural pest and weed management capabilities.
Supports role-based access control, detailed species information management, and visual identification tools with image galleries.
One-click FREE deployment of your agricultural biosecurity system.

Live Application · Screenshots · Documentation · Database Schema · Issues


🚀 Try Live Demo 🚀




Share Biosecurity Guide Repository

🌱 Pioneering the future of agricultural biosecurity. Built for the next generation of farmers, agronomists, and agricultural professionals.

📸 Project Screenshots

[!TIP] Explore the intuitive user interface designed for agricultural professionals across different user roles.

Home Dashboard

Home Dashboard - Welcome interface with easy navigation

Authentication System Admin Dashboard

User Authentication and Administrator Dashboard

📱 More Screenshots
Staff Management

Staff Management Interface

Guide Management

Agricultural Guide Content Management

Agronomist View

Agronomist's Guide Viewing Interface

🎬 Demo Video

[!NOTE] Experience the comprehensive biosecurity management system in action through our demo.

Demo Video

Click the image above to access the live application

Tech Stack Badges:

Important

This project demonstrates modern agricultural technology integration with web development best practices. It combines Flask backend with MySQL database to provide comprehensive biosecurity management. Features include role-based access control, visual species identification, and comprehensive agricultural data management.

📑 Table of Contents

TOC


🌟 Introduction

We are passionate developers creating next-generation agricultural biosecurity solutions. By adopting modern web development practices and comprehensive database design, we aim to provide agricultural professionals with powerful, scalable, and user-friendly biosecurity management tools.

Whether you're an agronomist seeking species identification resources, staff managing agricultural content, or administrators overseeing system operations, this platform will be your comprehensive biosecurity playground. Please note that this project is under active development, and we welcome feedback for any issues encountered.

Note

  • Python 3.8+ required
  • MySQL database required for data storage
  • Web browser with JavaScript enabled
  • Internet connection for image resources
No installation required! Visit our live demo to experience it firsthand.

Tip

⭐ Star us to receive all release notifications from GitHub without delay!

⭐ Star History

✨ Key Features

1 Role-Based Access Control

Experience comprehensive user management with distinct role-based interfaces. Our innovative approach provides specialized access levels for different agricultural professionals through advanced authentication and authorization systems.

Authentication System

Secure role-based authentication system

Key capabilities include:

  • 👥 Multi-Role Support: Administrators, Staff, and Agronomists
  • 🔒 Secure Authentication: Password hashing with Werkzeug
  • 📋 Profile Management: Individual user profile customization
  • 🛡️ Session Security: Secure session management

2 Comprehensive Species Database

Revolutionary agricultural species management that transforms how users access pest and weed information. With our comprehensive database and intuitive design, users can efficiently identify and manage agricultural threats while maintaining detailed records.

Species Management Species Viewing

Species Management (left) and Viewing Interface (right)

Database Features:

  • Pest Management: Comprehensive pest identification and control information
  • Weed Database: Detailed weed species with biological characteristics
  • Image Galleries: Multiple images per species for accurate identification
  • Scientific Data: Biology, impacts, and control methods for each species

* Additional Features

Beyond the core features, this biosecurity platform includes:

  • 🌐 Multi-User System: Support for multiple concurrent users with role separation
  • 🔍 Advanced Search: Search and filter capabilities across all species data
  • 📊 Data Management: CRUD operations for agricultural species information
  • 🖼️ Image Management: Multiple image support with primary image designation
  • 📱 Responsive Design: Mobile-friendly interface with Bootstrap CSS
  • 🔐 Secure Password: Complex password requirements and secure storage
  • 📋 Content Management: Easy-to-use forms for species data entry
  • 🏠 Dashboard Interface: Role-specific home pages and navigation

✨ More features are continuously being added as agricultural needs evolve.

🛠️ Tech Stack

Flask
Flask 3.0.2
Python
Python 3.8+
MySQL
MySQL 8.0
Bootstrap
Bootstrap 5
HTML5
HTML5
JavaScript
JavaScript

Backend Stack:

  • Framework: Flask 3.0.2 with Blueprint architecture
  • Language: Python 3.8+ for robust server-side logic
  • Database: MySQL with mysql-connector-python driver
  • Authentication: Werkzeug for password hashing and security
  • Forms: WTForms for form validation and processing

Frontend Stack:

  • Styling: Bootstrap 5 for responsive design
  • Templates: Jinja2 templating engine
  • JavaScript: Vanilla JS for interactive features
  • UI Components: Custom agricultural-focused design system

Development & Operations:

  • Deployment: PythonAnywhere cloud hosting
  • Database Tools: MySQL Workbench compatible schema
  • Version Control: Git with structured branching
  • Documentation: Comprehensive README and code comments

Tip

Each technology was carefully selected for agricultural application needs, ease of deployment, and long-term maintainability in educational and professional environments.

🏗️ Architecture

System Architecture

Tip

This architecture supports multi-user agricultural environments and role-based data access patterns, making it suitable for educational institutions and agricultural organizations.

graph TB
    subgraph "Frontend Layer"
        A[Flask Templates] --> B[Bootstrap UI]
        B --> C[JavaScript Interactions]
        C --> D[Form Handling]
    end
    
    subgraph "Application Layer"
        E[Flask Blueprints] --> F[Route Handlers]
        F --> G[Authentication Logic]
        G --> H[Business Logic]
    end
    
    subgraph "Data Layer"
        I[MySQL Database]
        J[User Management]
        K[Species Database]
        L[Image Storage]
    end
    
    D --> E
    H --> I
    I --> J
    I --> K
    I --> L
    
    subgraph "Security"
        M[Session Management]
        N[Password Hashing]
        O[Role-based Access]
    end
    
    G --> M
    G --> N
    G --> O
Loading

Database Schema

The database follows a normalized structure optimized for agricultural data management:

erDiagram
    users ||--o{ agronomists : "has profile"
    users ||--o{ staff_and_administrators : "has profile"
    agriculture_items ||--o{ images : "has images"
    
    users {
        int user_id PK
        varchar username
        varchar password_hash
        enum role_name
        enum status
    }
    
    agriculture_items {
        int agriculture_id PK
        enum item_type
        varchar common_name
        varchar scientific_name
        text key_characteristics
        text biology
        text impacts
        text control
    }
    
    images {
        int image_id PK
        int agriculture_id FK
        varchar image_path
        boolean is_primary
    }
    
    agronomists {
        int agronomist_id PK
        int user_id FK
        varchar first_name
        varchar last_name
        varchar email
        varchar phone_number
        varchar address
        date date_joined
    }
    
    staff_and_administrators {
        int staff_id PK
        int user_id FK
        varchar first_name
        varchar last_name
        varchar email
        varchar work_phone_number
        date hire_date
        varchar position
        varchar department
    }
Loading

User Role Structure

The system implements a three-tier role-based access control:

  • Administrators: Full system access, user management, complete CRUD operations
  • Staff: Content management, species data entry, user viewing capabilities
  • Agronomists: Read-only access to species database, identification tools

⚡️ Performance

Key Metrics

Application Performance:

  • Fast Load Times: Optimized database queries with proper indexing
  • 🚀 Responsive UI: Bootstrap-based responsive design for all devices
  • 💾 Efficient Queries: Prepared statements preventing SQL injection
  • 📊 Pagination Support: Efficient data loading with configurable page sizes

Database Optimization:

  • 🔄 Connection Pooling: Efficient database connection management
  • 📋 Indexed Searches: Optimized search across species characteristics
  • 🖼️ Image Management: External image hosting for optimal performance
  • 🔍 Query Optimization: Efficient JOIN operations for related data

Note

Performance metrics are continuously monitored and optimized for agricultural workflow requirements.

🚀 Getting Started

Prerequisites

Important

Ensure you have the following installed:

Quick Installation

1. Clone Repository

git clone https://github.com/ChanMeng666/biosecurity.git
cd biosecurity

2. Install Dependencies

# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install required packages
pip install -r requirements.txt

3. Database Setup

# Create MySQL database
mysql -u root -p
CREATE DATABASE biosecurity;

# Import database structure
mysql -u root -p biosecurity < app/database/biosecurity(structure_only).sql

# Optional: Import sample data
mysql -u root -p biosecurity < app/database/biosecurity(structure_and_data).sql

4. Configuration

# Edit config.py
class Config(object):
    SECRET_KEY = 'your-secret-key-here'
    DATABASE_URI = 'mysql://username:password@localhost/biosecurity'

5. Start Application

python app.py

🎉 Success! Open http://localhost:5000 to view the application.

Environment Setup

Configure your local environment:

# Database Configuration
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=biosecurity

# Application Configuration
SECRET_KEY=your-secret-key
DEBUG=True

Tip

Use a strong secret key for production deployments. Generate one using Python's secrets module.

Development Mode

# Start with debug mode
python app.py

# Check database connection
python -c "from app.database import check_db_connection; check_db_connection()"

🛳 Deployment

Important

Choose the deployment strategy that best fits your agricultural organization's needs.

A PythonAnywhere Deployment

Live Application: 1160210.pythonanywhere.com

Steps for PythonAnywhere:

  1. Upload your code to PythonAnywhere
  2. Configure MySQL database in the Databases tab
  3. Set up the WSGI configuration file
  4. Configure environment variables
  5. Reload the web application

B Local Deployment

# Production configuration
export FLASK_ENV=production
export SECRET_KEY=your-production-secret

# Start with production settings
python app.py

C Environment Variables

Variable Description Required Example
SECRET_KEY Flask secret key your-secret-key
DATABASE_URI MySQL connection string mysql://user:pass@localhost/biosecurity
DEBUG Debug mode 🔶 False

Warning

Never commit database credentials to version control. Use environment variables or secure configuration files in production.

📖 Usage Guide

Basic Usage

Getting Started:

  1. Access Application via the live demo or local installation
  2. Login/Register with appropriate role credentials
  3. Navigate Dashboard based on your user role
  4. Explore Features through role-specific interfaces

User Roles

Administrator Functions:

  • User management (create, edit, delete users)
  • Complete species database management
  • System configuration and oversight
  • Access to all application features

Staff Functions:

  • Species database content management
  • Image uploads and management
  • View agronomist profiles
  • Content creation and editing

Agronomist Functions:

  • Browse species database
  • View detailed species information
  • Access image galleries for identification
  • Read-only access to comprehensive guides

Testing Accounts

PythonAnywhere Environment

Role Username Password
Admin hello777 1234qweASD@
Admin admin0 123qweASD@
Staff staff1 123qweASD@
Agronomist agro1 123qweASD@

Local Environment

Role Username Password
Agronomist agro1 123qweASD@
Staff staff1 123qweASD@
Admin admin1 123qweASD@

Note

These are demonstration accounts. Change passwords for production use.

🔌 Integrations

Current and planned integrations for enhanced agricultural functionality:

Feature Status Description
External Image APIs ✅ Active Support for external agricultural image databases
Email Notifications 🔶 Planned User registration and system notifications
Export Functions 🔶 Planned PDF and Excel export of species data
Mobile App 🔶 Future Native mobile application for field use
API Endpoints 🔶 Future RESTful API for third-party integrations

📦 Database Schema

The biosecurity database contains comprehensive agricultural data:

  • 80+ Species Records: Detailed pest and weed information
  • 400+ Images: Visual identification resources
  • Multi-User Support: Role-based data access
  • Relationship Management: Normalized database structure

Key Tables:

  • agriculture_items: Core species data (pests and weeds)
  • images: Associated identification images
  • users: Authentication and authorization
  • agronomists: Agricultural professional profiles
  • staff_and_administrators: Staff member information

⌨️ Development

Local Development

Setup Development Environment:

# Clone and setup
git clone https://github.com/ChanMeng666/biosecurity.git
cd biosecurity

# Virtual environment
python -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Database setup
mysql -u root -p < app/database/biosecurity(structure_and_data).sql

# Start development server
python app.py

Adding Features

Development Workflow:

  1. Create feature branch
  2. Implement functionality in appropriate blueprint
  3. Add templates and styling
  4. Test with different user roles
  5. Update documentation
  6. Submit pull request

Project Structure:

app/
├── routes/           # Flask blueprints for different features
├── templates/        # Jinja2 templates organized by role
├── static/          # CSS, JavaScript, and assets
├── database/        # Database schemas and connection
└── utils.py         # Utility functions

Testing

Manual Testing:

  • Test all user roles and permissions
  • Verify database operations
  • Check responsive design
  • Validate form submissions

Database Testing:

# Test database connection
python -c "from app.database.db_connection import get_db_connection; conn = get_db_connection(); print('Connected!' if conn else 'Failed')"

🤝 Contributing

We welcome contributions to improve agricultural biosecurity management! Here's how you can help:

Development Process

1. Fork & Clone:

git clone https://github.com/your-username/biosecurity.git
cd biosecurity

2. Create Branch:

git checkout -b feature/your-feature-name

3. Make Changes:

  • Follow Python PEP 8 style guidelines
  • Add comprehensive comments
  • Test across different user roles
  • Update documentation as needed

4. Submit PR:

  • Provide clear description
  • Include screenshots for UI changes
  • Reference related issues
  • Ensure all features work correctly

Contribution Guidelines

Code Style:

  • Use Python 3.8+ features appropriately
  • Follow Flask best practices
  • Write clear, agricultural-domain-specific comments
  • Ensure cross-role compatibility

Agricultural Focus:

  • Consider real-world agricultural workflows
  • Maintain scientific accuracy in species data
  • Ensure accessibility for field use
  • Support various agricultural environments

📄 License

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

Open Source Benefits:

  • ✅ Educational use encouraged
  • ✅ Commercial use allowed
  • ✅ Modification and distribution permitted
  • ✅ Agricultural research applications supported

👥 Team

Chan Meng
Chan Meng

Creator & Lead Developer

🙋‍♀️ Author

Chan Meng


🌱 Building the Future of Agricultural Biosecurity 🚀
Empowering agricultural professionals with modern digital tools

Star us on GitHub • 📖 Read the Documentation • 🐛 Report Issues • 💡 Request Features • 🤝 Contribute



Made with ❤️ for the agricultural community

GitHub stars GitHub forks GitHub watchers

About

【Hit that ⭐️ if you like what you see!】A Flask-based web application serving as a comprehensive biosecurity guide for agricultural pests and weeds in New Zealand. Features role-based access control, detailed pest/weed information management, and responsive design for agronomists, staff, and administrators.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published