Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AgroVisionSecureAI+

AgroVisionSecureAI+ is a secure visual AI agent for farmers to monitor crops, compare field images, identify objects (plants, pests, weeds), segment affected areas, and generate clear reports. Access is protected by Auth0 for AI Agents, ensuring users only see their own data and analysis results.

Auth0 AI Agents Challenge 2025 Entry

This project demonstrates the three pillars of Auth0 for AI Agents:

  1. Authenticate: Secure user authentication with role-based access.
  2. Control: Fine-grained AI tool access through token validation.
  3. Limit: User data isolation and comprehensive audit trails.

Features

  • Secure authentication: Auth0 login with role-based access (farmer, inspector, admin).
  • Image analysis: Upload and analyze crop images with AI-powered insights.
  • Multi-analysis types: Classification, object detection, image segmentation, comparison.
  • Results dashboard: Confidence scores, detected areas, visual results, and graphs.
  • History tracking: Analysis backup with dates, scores, and comparison tools.
  • Admin dashboard: User management and system monitoring for administrators.

Tech Stack

  • Frontend: React 18, Vite, TypeScript, Tailwind CSS, Auth0 React SDK.
  • Backend: PHP 8.0+, REST API with Auth0 JWT verification.
  • Database: SQLite with user isolation and role-based access.
  • AI integration: Hugging Face Inference API (ResNet-50, DETR, Mask2Former, CLIP).
  • Hosting: Ready for Vercel (frontend) and Render/Railway (backend).

Architecture

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────────┐
│   React SPA     │────│   PHP REST API   │────│  Hugging Face API   │
│  (Auth0 Login)  │    │ (JWT Validation) │    │   (AI Models)       │
└─────────────────┘    └──────────────────┘    └─────────────────────┘
                                │
                       ┌────────▼────────┐
                       │   SQLite DB     │
                       │ (User Isolation)│
                       └─────────────────┘

Quick Start

Prerequisites

  • Node.js 18+ and npm.
  • PHP 8.0+ and Composer.
  • Auth0 account with AI Agents configuration.
  • Hugging Face API token.

Frontend Setup

cd frontend
npm install
cp .env.example .env
# Configure your Auth0 credentials in .env
npm run dev

Backend Setup

cd backend
composer install
cp .env.example .env
# Configure Auth0 and Hugging Face credentials in .env
composer run serve

Environment Configuration

Frontend (.env)

VITE_AUTH0_DOMAIN=your-auth0-domain.auth0.com
VITE_AUTH0_CLIENT_ID=your-client-id
VITE_API_BASE_URL=http://localhost:8000/api

Backend (.env)

AUTH0_DOMAIN=your-auth0-domain.auth0.com
AUTH0_CLIENT_ID=your-client-id
AUTH0_CLIENT_SECRET=your-client-secret
AUTH0_AUDIENCE=https://agrovision-api.auth0.com
HUGGING_FACE_API_TOKEN=your-hf-token
ALLOWED_ORIGINS=http://localhost:5173

AI Models Used

  • Classification: microsoft/resnet-50 - Identifies crop types and health status.
  • Object detection: facebook/detr-resnet-50 - Detects pests, plants, tools.
  • Segmentation: facebook/mask2former - Segments vegetation vs. diseased areas.
  • Comparison: openai/clip-vit-base-patch32 - Compares field changes over time.

API Endpoints

  • GET /health - Health check.
  • GET /user/profile - Current user profile.
  • POST /analyze - Upload and analyze images.
  • GET /analysis/history - User's analysis history.
  • GET /analysis/{id} - Specific analysis details.
  • DELETE /analysis/{id} - Delete analysis.
  • GET /admin/users - All users (admin only).
  • GET /admin/analyses - All analyses (admin only).

Security Features

  • Authentication: Auth0 JWT token verification on all endpoints.
  • Authorization: Role-based access control (farmer/inspector/admin).
  • Data isolation: Users can only access their own analyses.
  • Token vault: Secure token management with Auth0.
  • Audit logs: Track user connections and AI analyses.
  • CORS protection: Configurable allowed origins.

Development

Available Tasks

  • Start frontend dev server: npm run dev (in frontend/).
  • Start backend server: composer run serve (in backend/).
  • Build frontend: npm run build (in frontend/).
  • Run frontend preview: npm run preview (in frontend/).

Project Structure

AgroVisionSecureAI+/
├── frontend/                 # React SPA
│   ├── src/
│   │   ├── components/       # Reusable UI components
│   │   ├── pages/           # Route pages
│   │   ├── services/        # API service layer
│   │   ├── types/           # TypeScript definitions
│   │   └── hooks/           # Custom React hooks
│   └── public/              # Static assets
├── backend/                 # PHP REST API
│   ├── src/                 # PHP classes
│   ├── public/              # Web server entry point
│   ├── config/              # Configuration files
│   └── uploads/             # User uploaded images
└── database/                # SQLite database files

Competition Impact

This project demonstrates all three pillars of Auth0 for AI Agents:

  1. Authenticate: Secure user login with role-based access.
  2. Control: Fine-grained permissions for AI tools and resources.
  3. Limit: User data isolation and audit capabilities.

Use case: Smart, sustainable, and secure agriculture through AI-powered crop monitoring with enterprise-grade security.

Deployment

Frontend (Vercel)

npm run build
# Deploy dist/ folder to Vercel

Backend (Render/Railway)

# Configure environment variables
# Set document root to public/
# Install PHP 8.0+ and Composer

License

This project is built for the Auth0 AI Agents Challenge 2025.

About

AgroVisionSecureAI+ is a secure, full‑stack AI application for agricultural monitoring and analysis. It provides image classification, object detection, segmentation, and image comparison using ResNet-50, DETR, Mask2Former, and CLIP via the Hugging Face Inference API. Built with a React + TypeScript + Vite frontend, a PHP REST API backend with Auth

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages