Skip to content

ChanMeng666/biosecurity

Repository files navigation

Biosecurity Guide for Agricultural Pests & Weeds

A comprehensive digital platform for identifying, understanding, and managing agricultural pests and weeds.
Built for agronomists, staff, and administrators with role-based access control and a growing guide library.

Issues


Share Project Repository

Tech Stack:

Important

This project is a modern full-stack biosecurity information system built with Next.js 16, React 19, Better Auth, Drizzle ORM, and Neon PostgreSQL. It provides role-based dashboards for administrators, staff, and agronomists to manage and browse pest and weed identification guides with detailed scientific data, images, and control methods.

Table of Contents

TOC


Introduction

About This Project

The Biosecurity Guide is a comprehensive digital platform designed to support agricultural professionals in identifying, understanding, and managing pests and weeds. The system provides a centralized guide library with detailed information on pest and weed characteristics, biology, impacts, and control methods — all backed by visual references.

The platform supports three distinct user roles — Administrator, Staff, and Agronomist — each with tailored dashboards and capabilities, ensuring the right level of access for every user.

Why This Project Exists

Agricultural biosecurity is critical for protecting crops, ecosystems, and food supply chains. Agronomists and field workers need quick, reliable access to pest and weed identification data to make timely decisions. This platform consolidates that information into a searchable, managed, and role-protected system — replacing scattered documents and outdated references with a modern, responsive web application.

Goals

  • Provide a centralized, searchable library of pest and weed identification guides
  • Enable role-based management of biosecurity information across organizations
  • Deliver a modern, responsive web experience for field and office use
  • Support data-driven decision making with structured scientific information

Note

  • Node.js >= 18.0 required
  • Neon PostgreSQL account required for database
  • Better Auth secret required for authentication

Key Features

1 Pest Identification

Detailed guides on agricultural pests including common and scientific names, key characteristics, biology, impacts, and control methods — all with visual image references to aid field identification.

Key capabilities:

  • Comprehensive pest profiles with scientific data
  • Multiple image support per guide entry
  • Structured control method recommendations
  • Impact assessment information

2 Weed Management

Comprehensive weed identification and control guides to protect agricultural productivity and biodiversity. Each entry includes lifecycle data, distinguishing characteristics, and recommended management strategies.

3 Role-Based Access Control

Three distinct user roles with tailored dashboards and permissions:

Role Capabilities
Administrator Full platform access — manage guides, staff, agronomists, and all system settings
Staff Create, edit, and delete guides; view agronomist profiles; manage own profile
Agronomist Browse and search the guide library; manage own profile

4 Guide Library & Smart Search

Browse and search through the guide library with powerful filtering capabilities:

  • Field-specific filtering (common name, scientific name, characteristics, biology, impacts, control)
  • Case-insensitive search matching
  • Pagination for large datasets
  • Filter by type (pest or weed)

* Additional Features

  • Secure authentication with server-side sessions (Better Auth)
  • Image carousel for visual guide references
  • Responsive design for desktop and mobile use
  • Light/dark theme support
  • Profile management for all user roles
  • Form validation with Zod schemas
  • Modern UI with shadcn/ui components

Tech Stack

Next.js
Next.js 16
React
React 19
TypeScript
TypeScript 5
Tailwind CSS
Tailwind CSS 4
PostgreSQL
Neon PostgreSQL
Drizzle
Drizzle ORM

Frontend:

  • Framework: Next.js 16 with App Router
  • Language: TypeScript for type safety
  • Styling: Tailwind CSS 4 + tw-animate-css
  • UI Components: shadcn/ui (Base UI React)
  • Icons: Lucide React
  • Themes: next-themes for light/dark mode
  • Notifications: Sonner toast system

Backend:

  • Runtime: Next.js API Routes (Node.js)
  • Authentication: Better Auth with email/password and server-side sessions
  • Database ORM: Drizzle ORM with type-safe queries
  • Validation: Zod schema validation

Database:

  • Provider: Neon serverless PostgreSQL
  • Migrations: Drizzle Kit
  • Schema: Custom tables for users, guides, images, profiles with role-based enums

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

npm install

Environment Setup

3. Configure Environment Variables

# Copy environment template
cp .env.example .env.local

# Edit environment variables
nano .env.local

Create .env.local with the following variables:

# Neon Database (get from neonctl connection-string)
DATABASE_URL=postgresql://user:[email protected]/neondb?sslmode=require

# Better Auth (generate a random 32+ character secret)
BETTER_AUTH_SECRET=your-random-secret-here
BETTER_AUTH_URL=http://localhost:3000

# App URL
NEXT_PUBLIC_APP_URL=http://localhost:3000

Quick Reference:

Variable Required Purpose
DATABASE_URL Yes Neon PostgreSQL connection string
BETTER_AUTH_SECRET Yes Auth encryption key (32+ chars)
BETTER_AUTH_URL Yes Auth base URL
NEXT_PUBLIC_APP_URL Yes Public-facing app URL

Tip

Use openssl rand -base64 32 to generate a secure random secret for BETTER_AUTH_SECRET.

Database Setup

4. Run Database Migrations

# Generate migration files from schema
npm run db:generate

# Push schema to database
npm run db:push

Tip

Use npm run db:studio to open the Drizzle Studio GUI for browsing your database.

Development Mode

5. Start Development Server

npm run dev

Open http://localhost:3000 to view the application.

Available Scripts:

npm run dev          # Start dev server with hot reload
npm run build        # Production build
npm run start        # Start production server
npm run lint         # Run ESLint
npm run db:generate  # Generate Drizzle migration files
npm run db:push      # Push schema changes to database
npm run db:migrate   # Run pending migrations
npm run db:studio    # Open Drizzle Studio database GUI

Project Structure

src/
├── app/                          # Next.js App Router
│   ├── (auth)/                   # Authentication routes
│   │   ├── login/                # Login page
│   │   └── register/             # Registration pages
│   │       ├── admin/            # Admin registration
│   │       ├── agronomist/       # Agronomist registration
│   │       └── staff/            # Staff registration
│   ├── (dashboard)/              # Protected dashboard routes
│   │   ├── admin/                # Admin dashboard
│   │   │   ├── manage-guides/    # Guide CRUD management
│   │   │   ├── manage-agronomists/ # Agronomist management
│   │   │   └── manage-staff/     # Staff management
│   │   ├── agronomist/           # Agronomist dashboard
│   │   │   └── guides/           # Guide browsing
│   │   └── staff/                # Staff dashboard
│   │       ├── manage-guides/    # Guide CRUD management
│   │       └── view-agronomists/ # View agronomist profiles
│   ├── api/                      # API routes
│   │   ├── auth/[...all]/        # Better Auth handler
│   │   ├── guides/               # Guide CRUD endpoints
│   │   ├── agronomists/          # Agronomist endpoints
│   │   ├── staff/                # Staff endpoints
│   │   └── profile/              # Profile endpoints
│   └── sources/                  # Sources & credits page
├── components/
│   ├── ui/                       # shadcn/ui base components
│   ├── guides/                   # Guide-specific components
│   ├── layout/                   # Navbar, dashboard shell
│   ├── shared/                   # Confirm dialog, data table
│   └── users/                    # Profile editor
└── lib/
    ├── auth/                     # Better Auth config & helpers
    ├── db/                       # Drizzle ORM, schema, migrations
    └── validators/               # Zod validation schemas

Contributing

Contributions are welcome! Here's how you can help:

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

Guidelines:

  • Follow TypeScript best practices
  • Use the existing code style and ESLint configuration
  • Test your changes locally before submitting
  • Write clear commit messages

Contributors

License

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

Author

Chan Meng

LinkedIn GitHub Email Website


Protecting Agriculture Through Knowledge
A comprehensive biosecurity guide for agricultural pest and weed management

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

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors