Skip to content

mdsaad31/BloomIQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌿 BloomIQ - Smart Crop Analysis Platform

BloomIQ is a production-level, AI-powered crop health monitoring application built with YOLOv8 for real-time flower and fruit stage detection. It combines modern web and mobile technologies to deliver accurate, fast, and visually rich crop analysis.


πŸ“‹ Table of Contents


✨ Features

🌿 Home Dashboard

  • Beautiful plant-themed interface with natural animations
  • Quick stats: weather, total analyses, recent reports
  • Quick actions: Analyze Now, View Reports, Check Weather

πŸ“Έ Crop Analysis

  • Upload or capture crop images
  • Dual YOLOv8 Model Integration:
    • flower_model.pt - Flower stage detection
    • fruit_model.pt - Fruit stage detection
  • Real-time inference and stage determination
  • Confidence levels and health summaries
  • Actionable care recommendations

πŸ“Š Reports

  • Complete analysis history
  • Expandable detailed reports
  • Detection counts and confidence metrics
  • Care recommendations archive

☁️ Weather Insights

  • Live weather data (OpenWeatherMap API)
  • Temperature, humidity, rainfall probability
  • Smart farming recommendations based on conditions
  • Watering and fertilization timing suggestions

πŸ‘€ Authentication

  • Email + Password authentication
  • JWT-based secure sessions
  • Profile management (name, region, language)

πŸ› οΈ Tech Stack

Frontend

  • Web: React.js 18
  • Mobile: React Native (Android)
  • Styling: TailwindCSS
  • Animations: Framer Motion (web), React Native Reanimated (mobile)
  • HTTP Client: Axios

Backend

  • Server: Node.js + Express.js
  • Database: SQLite (lightweight, file-based)
  • Authentication: JWT (JSON Web Tokens)
  • File Upload: Multer

AI/ML

  • Framework: Python + Flask
  • Model: YOLOv8 (Ultralytics)
  • Image Processing: OpenCV, Pillow

APIs

  • Weather: OpenWeatherMap API

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   React Web     β”‚
β”‚   React Native  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ HTTP/REST
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Node.js Server β”‚
β”‚   (Express.js)  β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
     β”‚       β”‚
     β”‚       └──────────────┐
     β–Ό                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ SQLite  β”‚        β”‚ Python Service β”‚
β”‚   DB    β”‚        β”‚   (YOLOv8)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Inference Flow

  1. User uploads image β†’ Express server
  2. Server sends image β†’ Python Flask service
  3. Python loads both models:
    • flower_model.pt
    • fruit_model.pt
  4. Both models run inference
  5. System compares confidence scores
  6. Returns dominant stage (Flower/Fruit) + recommendations
  7. Server stores result in database
  8. Client displays analysis

πŸ“¦ Prerequisites

General

  • Node.js 16.x or higher
  • Python 3.9 or higher
  • npm or yarn
  • pip (Python package manager)

For Mobile (Optional)

  • React Native CLI
  • Android Studio (for Android development)
  • Java JDK 11 or higher

πŸš€ Installation

1. Clone the Repository

git clone <repository-url>
cd BloomIQ-v4

2. Backend Setup

Install Node.js Dependencies

cd backend
npm install

Install Python Dependencies

cd python-service
pip install -r requirements.txt
cd ..

Configure Environment Variables

cp .env.example .env

Edit .env:

PORT=5000
JWT_SECRET=your-super-secret-jwt-key-change-this
PYTHON_SERVICE_URL=http://localhost:8000
WEATHER_API_KEY=your-openweathermap-api-key

Add YOLOv8 Models

Place your trained models in backend/models/:

  • flower_model.pt
  • fruit_model.pt

Note: If models are missing, the system uses YOLOv8n as fallback.

3. Web Frontend Setup

cd ../web
npm install

Create .env:

cp .env.example .env

Edit .env:

REACT_APP_API_URL=http://localhost:5000/api

4. Mobile Setup (Optional)

cd ../mobile
npm install

For Android:

npx react-native run-android

🎯 Usage

Start All Services

Terminal 1: Node.js Backend

cd backend
npm run dev

Server runs on http://localhost:5000

Terminal 2: Python Inference Service

cd backend/python-service
python app.py

Service runs on http://localhost:8000

Terminal 3: React Web App

cd web
npm start

App opens at http://localhost:3000

Using the Application

  1. Register/Login: Create account or sign in
  2. Dashboard: View stats and weather
  3. Analyze: Upload/capture crop image
  4. Results: View stage, confidence, recommendations
  5. Reports: Check analysis history
  6. Weather: Get farming recommendations

πŸ“‘ API Documentation

Authentication

Register

POST /api/auth/register
Content-Type: application/json

{
  "email": "[email protected]",
  "password": "password123",
  "name": "John Doe",
  "region": "California",
  "language": "en"
}

Login

POST /api/auth/login
Content-Type: application/json

{
  "email": "[email protected]",
  "password": "password123"
}

Analysis

Analyze Crop

POST /api/analysis/analyze
Authorization: Bearer <token>
Content-Type: multipart/form-data

image: <file>

Response:

{
  "reportId": "uuid",
  "stage": "Flower",
  "confidence": 0.89,
  "detections": [...],
  "health_summary": "Detected 3 flowers...",
  "recommendations": ["Ensure pollination", ...],
  "imageUrl": "http://..."
}

Weather

Get Current Weather

GET /api/weather/current?city=California
Authorization: Bearer <token>

Reports

Get All Reports

GET /api/reports
Authorization: Bearer <token>

Get Report by ID

GET /api/reports/:id
Authorization: Bearer <token>

🌐 Deployment

Backend (Node.js + Python)

Option 1: Traditional Server

# Install PM2
npm install -g pm2

# Start Node.js
cd backend
pm2 start server.js --name bloomiq-backend

# Start Python (separate process)
cd python-service
pm2 start app.py --name bloomiq-python --interpreter python3

Option 2: Docker

# Example Dockerfile for backend
FROM node:18
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
EXPOSE 5000
CMD ["node", "server.js"]

Frontend

Web (React)

cd web
npm run build
# Deploy 'build' folder to:
# - Vercel
# - Netlify
# - AWS S3 + CloudFront
# - GitHub Pages

Mobile (React Native)

cd mobile
# Android
npx react-native build-android --release

# Generate APK in android/app/build/outputs/apk/release/

πŸ”§ Troubleshooting

Python Service Not Connecting

# Check if service is running
curl http://localhost:8000/health

# Restart service
cd backend/python-service
python app.py

Models Not Loading

  • Ensure flower_model.pt and fruit_model.pt are in backend/models/
  • Check file permissions
  • Verify PyTorch and Ultralytics are installed

Database Issues

# Reset database
cd backend
rm database.sqlite
npm run dev  # Recreates tables

πŸ“ License

MIT License - See LICENSE file


🀝 Contributing

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

πŸ“ž Support

For issues and questions:


🌟 Acknowledgments

  • Ultralytics YOLOv8 - Object detection framework
  • OpenWeatherMap - Weather data API
  • React Team - Frontend framework
  • Express.js - Backend framework

Made with 🌱 by the BloomIQ Team