Skip to content
/ fedai Public

AI-powered plant health diagnostic app with image analysis, weather, soil data integration. Multi-language support, real-time monitoring. Built with React, TypeScript, Vite.

License

Notifications You must be signed in to change notification settings

bnelabs/fedai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fedai: Plant Health AI 🌿

Version Tests License React TypeScript Vite

Fedai is an intelligent assistant designed to help you understand and improve your plant's health. By leveraging advanced image analysis and contextual data (like your location, local weather, and soil characteristics), Fedai provides insightful analysis and actionable solutions.

✨ Key Features

  • πŸ€– AI-Powered Diagnosis - Multi-provider support (Gemini, OpenRouter, Local AI)
  • πŸ“Έ Image Analysis - Advanced plant disease detection from photos
  • 🌍 Environmental Context - Location, weather, soil, and elevation data
  • 🌐 Multi-Language - Support for multiple languages
  • πŸ“Š Real-Time Monitoring - Service health status dashboard
  • 🎨 Modern UI - Responsive design with smooth animations
  • πŸ§ͺ Well-Tested - Comprehensive test suite with 22 passing tests
  • 🐳 Docker Ready - Easy deployment with Docker Compose
  • ⚑ Performance Optimized - Web Worker image compression, race condition-free async operations
  • πŸ›‘οΈ Error Recovery - Retry buttons on error states, error boundaries prevent crashes
  • ⌨️ Keyboard Shortcuts - Ctrl+Enter to analyze, Escape to close modals

πŸ“ Repository Structure

This project uses an intentional monorepo structure:

fedai/
β”œβ”€β”€ πŸ“‚ Frontend (Root Directory)
β”‚   β”œβ”€β”€ components/        # React components
β”‚   β”œβ”€β”€ contexts/          # React contexts (AI Settings, etc.)
β”‚   β”œβ”€β”€ hooks/             # Custom React hooks
β”‚   β”œβ”€β”€ pages/             # Page components
β”‚   β”œβ”€β”€ providers/         # AI provider implementations
β”‚   β”œβ”€β”€ services/          # API service clients
β”‚   β”œβ”€β”€ types/             # TypeScript type definitions
β”‚   β”œβ”€β”€ utils/             # Utility functions
β”‚   β”‚   β”œβ”€β”€ workers/       # Web Workers (image compression)
β”‚   β”‚   └── imageCompression.ts  # Image compression utilities
β”‚   β”œβ”€β”€ App.tsx            # Main app component
β”‚   β”œβ”€β”€ index.tsx          # React entry point
β”‚   β”œβ”€β”€ index.html         # HTML entry with import maps
β”‚   β”œβ”€β”€ types.ts           # Centralized types
β”‚   β”œβ”€β”€ constants.ts       # App constants
β”‚   β”œβ”€β”€ localization.ts    # Multi-language support
β”‚   β”œβ”€β”€ theme.css          # Global styles
β”‚   └── package.json       # Frontend dependencies
β”‚
β”œβ”€β”€ πŸ“‚ fedai-backend-proxy/  # Backend API Server
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/           # Controllers, routes, middleware
β”‚   β”‚   β”œβ”€β”€ services/      # AI provider services
β”‚   β”‚   └── utils/         # Backend utilities
β”‚   β”œβ”€β”€ server.js          # Server entry point
β”‚   └── package.json       # Backend dependencies
β”‚
β”œβ”€β”€ πŸ“‚ docs/               # Comprehensive documentation
β”‚   β”œβ”€β”€ QUICKSTART.md      # 3-step setup guide
β”‚   β”œβ”€β”€ DEPLOYMENT.md      # Production deployment
β”‚   β”œβ”€β”€ AI_PROVIDER_SETUP.md
β”‚   └── ...
β”‚
└── πŸ“ Configuration Files
    β”œβ”€β”€ docker-compose.yml     # Production Docker setup
    β”œβ”€β”€ docker-compose.dev.yml # Development Docker setup
    β”œβ”€β”€ render.yaml            # Render deployment config
    β”œβ”€β”€ vite.config.ts         # Vite bundler config
    └── tsconfig.json          # TypeScript config

Why frontend in root? This structure supports our unique dev approach using esm.sh/tsx for browser-based TypeScript compilation during development, while using Vite for optimized production builds.

For Everyone: What is Fedai?

Imagine you have a plant that looks sick, but you're not sure what's wrong or how to help it. Fedai is like having a knowledgeable gardening assistant in your pocket!

  • Snap a Photo: Take a picture of your plant.
  • Get Insights: Fedai analyzes the photo and, if you allow it, uses your location to consider local environmental factors.
  • Understand the Problem: It identifies potential diseases or issues.
  • Find Solutions: Fedai suggests ways to treat your plant, including different approaches and estimated costs.

It's designed to be easy to use, even if you don't know much about plant diseases or technology.

πŸ—οΈ Architecture

Fedai is a full-stack web application with clear separation of concerns:

Frontend (Root Directory)

  • Tech Stack: React 19, TypeScript, Vite, Tailwind CSS
  • Features: Image upload, AI settings, multi-language support, real-time analysis
  • Location: All source files in root directory (see structure above)
  • Unique Approach: Uses esm.sh/tsx for dev + Vite for production builds
  • πŸ“– Frontend Documentation

Backend Proxy (fedai-backend-proxy/)

  • Tech Stack: Node.js, Express, multi-provider AI integration
  • Purpose: Secure API key management, external service orchestration
  • Services:
    • AI Providers (Gemini, OpenRouter, Local AI)
    • Weather data (Open-Meteo)
    • Soil data (SoilGrids)
    • Plant database (OpenPlantBook)
  • πŸ“– Backend Documentation

Why This Structure?

βœ… Security: API keys never exposed to browser βœ… Modularity: Clear backend/frontend separation βœ… Flexibility: Support for multiple AI providers βœ… Developer Experience: Simplified dev workflow with hot reload

πŸš€ Quick Start

For Users

Access the deployed application at [your-deployment-url] (coming soon)

For Developers

Get started in 3 steps - see QUICKSTART.md

# 1. Clone and setup backend
cd fedai-backend-proxy
npm install
# Add API keys to .env file

# 2. Setup frontend (in separate terminal)
cd ..
npm install

# 3. Run both services
npm run dev          # Frontend (http://localhost:5173)
cd fedai-backend-proxy && npm start  # Backend (http://localhost:3001)

Using Docker

docker-compose -f docker-compose.dev.yml up
# Frontend: http://localhost:5173
# Backend: http://localhost:3001

πŸ“– Full Documentation:

Key Features

  • AI-Powered Image Analysis: Identifies plant health issues from images.
  • Contextual Data Integration: Uses location, weather, and soil data for more accurate diagnoses.
  • Actionable Solutions: Provides cultural, biological, and chemical treatment options.
  • User-Friendly Interface: Designed for ease of use.
  • Multi-language Support.

We hope Fedai helps you keep your plants healthy and thriving!

⚑ Performance & Reliability

Fedai has been optimized for performance and reliability with several key improvements:

πŸš€ Performance Optimizations

  • Non-Blocking Image Compression: Uses Web Workers with OffscreenCanvas to compress images without freezing the UI (eliminates 2-3 second freeze on large uploads)
  • API Preconnect: DNS prefetch and preconnect for all external APIs (~200ms faster API calls)
  • Race Condition Free: Uses native AbortController for proper async operation cancellation
  • Loading Skeletons: Smooth loading states for better perceived performance

πŸ›‘οΈ Reliability Features

  • Error Boundaries: Component crashes don't bring down the entire app
  • Retry Buttons: Easy recovery from transient network errors
  • Automatic Cleanup: Proper resource cleanup on component unmount
  • User-Friendly Errors: Clear, actionable error messages in multiple languages

⌨️ User Experience

  • Keyboard Shortcuts:
    • Ctrl+Enter - Trigger plant analysis
    • Escape - Close modals
  • Responsive Design: Works seamlessly on desktop, tablet, and mobile
  • Multi-Language Support: Full localization in multiple languages

πŸ”’ Security

  • Explicit CORS: No wildcard origins, explicit whitelist only
  • Rate Limiting: Endpoint-specific rate limits (20 AI analyses/hour, 60 data requests/15min)
  • Secure API Key Management: All API keys stored server-side only

See IMPROVEMENTS_COMPLETED.md for detailed technical information.

About

AI-powered plant health diagnostic app with image analysis, weather, soil data integration. Multi-language support, real-time monitoring. Built with React, TypeScript, Vite.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •