# Feature Spec: Plant Touch Points & IPM Tracking

**Priority**: 🟡 High (Phase 2)  
**Team**: 777 Wolfpack  
**Date**: 2025-12-09  
**Status**: New Requirement

---

## 📋 Overview

A **touch points system** that allows staff to record data at each interaction with plants, with specific focus on **IPM (Integrated Pest Management)** tracking for the veg room.

**Key Insight from 777 Wolfpack**:
> "Basically a touch points app - at each touch point to plant to simply record and compile data"

---

## 🎯 User Story

**As a** 777 Wolfpack grower  
**I want** to record data every time I interact with a plant  
**So that** we have a complete history of all plant interactions and can track IPM schedules

---

## ✅ Core Requirements

### 1. Plant Touch Points

**What**: Record every interaction with plants

**Touch Point Types**:

- Watering
- Feeding
- Pruning
- Training
- Inspection
- IPM Treatment
- Transplanting
- Harvesting

**Data to Capture**:

- Touch point type
- Plant/Batch ID
- Date/Time (auto)
- Staff member (auto from JWT)
- Notes
- Photos (optional)
- Measurements (height, width, etc.)
- Issues observed

---

### 2. IPM Plan - Root Drench Schedule

**What**: 10-day cycle root drench IPM plan for veg room

**Specific Product**: Pyganic 5.0 (when budget allows)

**Schedule**:

- **Day 0**: Root drench with Pyganic 5.0
- **Day 10**: Root drench with Pyganic 5.0
- **Day 20**: Root drench with Pyganic 5.0
- **Day 30**: Root drench with Pyganic 5.0
- (Repeat every 10 days)

**Requirements**:

- [ ] Track last IPM treatment date per batch
- [ ] Calculate next treatment date (10 days)
- [ ] Alert when treatment is due
- [ ] Record treatment completion
- [ ] Track product used (Pyganic 5.0)
- [ ] Track dosage/concentration
- [ ] Photo of treatment (before/after)

---

## 🏗️ Implementation Design

### Database Schema

#### PlantTouchPoint Model

```prisma
model PlantTouchPoint {
  id          String   @id @default(uuid())
  batchId     String
  batch       Batch    @relation(fields: [batchId], references: [id])
  plantId     String?  // Optional individual plant ID
  
  touchType   TouchPointType
  performedBy String
  user        User     @relation(fields: [performedBy], references: [id])
  
  timestamp   DateTime @default(now())
  notes       String?
  photoUrls   String[] // Array of photo URLs
  
  // Measurements
  heightCm    Float?
  widthCm     Float?
  
  // IPM specific
  ipmProduct  String?  // e.g., "Pyganic 5.0"
  ipmDosage   String?  // e.g., "1 oz per gallon"
  
  // Issues
  issuesObserved Boolean @default(false)
  issueType      String?
  
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt

  @@map("plant_touch_points")
}

enum TouchPointType {
  WATERING
  FEEDING
  PRUNING
  TRAINING
  INSPECTION
  IPM_TREATMENT
  TRANSPLANTING
  HARVESTING
  OTHER
}

model IPMSchedule {
  id              String   @id @default(uuid())
  batchId         String
  batch           Batch    @relation(fields: [batchId], references: [id])
  
  product         String   // "Pyganic 5.0"
  intervalDays    Int      // 10
  lastTreatment   DateTime?
  nextTreatment   DateTime?
  
  isActive        Boolean  @default(true)
  
  createdAt       DateTime @default(now())
  updatedAt       DateTime @updatedAt

  @@map("ipm_schedules")
}
```

---

## 📱 Mobile UI Design

### Touch Point Entry Screen

**Layout** (Mobile-First):

1. **Quick Actions** (Large buttons)
   - 💧 Water
   - 🍃 Feed
   - ✂️ Prune
   - 🔍 Inspect
   - 🛡️ IPM Treatment

2. **Batch Selection**
   - Dropdown or quick select
   - Show current room/location

3. **Data Entry**
   - Notes (optional)
   - Photos (camera button)
   - Measurements (optional)

4. **Submit**
   - Save touch point
   - Return to dashboard

### IPM Schedule Screen

**Layout**:

1. **Active Batches** (Veg Room)
   - Batch name
   - Last IPM treatment date
   - Next treatment date
   - Days until next treatment

2. **Treatment Due** (Alert)
   - Red badge if overdue
   - Yellow badge if due today
   - Green if not due

3. **Record Treatment**
   - Tap batch → Record IPM treatment
   - Auto-fill product (Pyganic 5.0)
   - Enter dosage
   - Take photos
   - Submit

---

## 🔔 Notifications

### IPM Treatment Alerts

- **3 days before**: "IPM treatment due in 3 days for Batch X"
- **Day of**: "IPM treatment DUE TODAY for Batch X"
- **Overdue**: "IPM treatment OVERDUE for Batch X (2 days late)"

### Touch Point Reminders

- Daily reminder to record touch points
- Weekly summary of touch points per batch

---

## 📊 Reporting

### Touch Point History

- View all touch points for a batch
- Filter by type (watering, feeding, IPM, etc.)
- Timeline view
- Photo gallery

### IPM Compliance Report

- All batches with IPM schedules
- Treatment history
- Compliance percentage
- Upcoming treatments

---

## ✅ Acceptance Criteria

- [ ] Staff can quickly record touch points on mobile
- [ ] All touch point types supported
- [ ] Photos can be attached to touch points
- [ ] IPM schedule auto-calculates next treatment date
- [ ] Alerts sent for upcoming IPM treatments
- [ ] Touch point history viewable per batch
- [ ] IPM compliance report available

---

## 🚀 Implementation Priority

**Phase**: Should be in **Phase 2** (after Daily Walkthrough)

**Estimated Effort**:

- Database schema: 2 hours
- Backend API: 4 hours
- Mobile UI: 6 hours
- IPM scheduling logic: 3 hours
- Notifications: 2 hours
- **Total**: ~17 hours (2-3 days)

---

## 🔗 Related Features

- **Daily Walkthrough**: Touch points can be created during walkthrough
- **Batches and Rooms**: Touch points linked to batches
- **Tasks and Scheduling**: IPM treatments are scheduled tasks
- **Compliance**: Touch point history is audit trail

---

## 📝 Notes from 777 Wolfpack Team

> "Basically a touch points app at each touch point to plant to simply record and compile data"

This is the core workflow - every time a grower touches a plant, they should be able to quickly record what they did.

> "Root drench ipm plan on 10 day sections in veg room with pyganic 5.0 once we can afford it"

**Key Details**:

- **Product**: Pyganic 5.0 (organic pyrethrin-based insecticide)
- **Schedule**: Every 10 days
- **Application**: Root drench
- **Room**: Veg room only
- **Budget**: "Once we can afford it" - need to track product inventory/cost

---

## 💡 Quick Wins

### MVP (Minimum Viable Product)

1. Simple touch point recording (type, notes, photo)
2. IPM schedule tracker (10-day intervals)
3. Basic alerts for IPM treatments

### Future Enhancements

- [ ] Barcode scanning for plant IDs
- [ ] Voice-to-text for notes
- [ ] AI-powered issue detection from photos
- [ ] Inventory tracking for IPM products
- [ ] Cost tracking per treatment
- [ ] Integration with environmental sensors

---

## 🎯 Success Metrics

### Adoption

- 80%+ of plant interactions recorded
- Average touch point entry time < 30 seconds
- 100% IPM treatment compliance

### Quality

- Complete touch point history for all batches
- Zero missed IPM treatments
- Early pest detection through regular touch points

---

**Status**: ✅ Spec Complete - Ready for Implementation  
**Next Step**: Review with 777 Wolfpack team, then implement in Phase 2
