# 🌍 Environmental Tracking Guide

**Track soil, climate, nutrients, and growing conditions to optimize plant health and learn from successful growers.**

## Overview

LocalGreenChain's environmental tracking system allows you to record detailed information about where and how your plants are grown. This data helps you:

- **Understand** what conditions make plants thrive
- **Compare** your setup with successful growers
- **Optimize** growing conditions based on data
- **Learn** from the collective experience
- **Replicate** successful growing environments
- **Troubleshoot** plant health issues

## What Can You Track?

### 🌱 Soil Composition
- **Soil type**: Clay, sand, silt, loam, peat, chalk, or custom
- **pH level**: 0-14 scale (most plants prefer 6.0-7.5)
- **Texture**: Heavy, medium, or light
- **Drainage**: Poor, moderate, good, or excellent
- **Organic matter**: Percentage (0-100%)
- **Composition**: Clay/sand/silt percentages
- **Amendments**: Compost, manure, perlite, vermiculite, etc.

**Why it matters**: Soil is the foundation of plant health. pH affects nutrient availability, drainage prevents root rot, and organic matter improves structure.

### 🧪 Nutrients & Fertilization
- **NPK values**: Nitrogen, Phosphorus, Potassium percentages
- **Secondary nutrients**: Calcium, magnesium, sulfur
- **Micronutrients**: Iron, manganese, zinc, copper, boron, molybdenum
- **EC/TDS**: Electrical conductivity and total dissolved solids
- **Fertilizer schedule**: Type, amount, frequency, NPK ratios
- **Application history**: Track what you've added and when

**Why it matters**: Proper nutrition is crucial for growth. Too little causes deficiencies, too much can burn plants. Track what works!

### ☀️ Lighting Conditions
- **Light type**: Natural, artificial, or mixed
- **Natural light**:
  - Exposure: Full sun, partial sun, partial shade, full shade
  - Hours per day: 0-24
  - Direction: North, south, east, west
  - Quality: Direct, filtered, dappled, indirect
- **Artificial light**:
  - Type: LED, fluorescent, HPS, MH, etc.
  - Spectrum: Full spectrum, color temperature (K)
  - Wattage and distance from plant
  - Hours per day
- **Advanced metrics**: PPFD (μmol/m²/s), DLI (mol/m²/day)

**Why it matters**: Light is energy. Insufficient light causes leggy growth, too much can burn leaves. Track optimal levels for your species.

### 🌡️ Climate Conditions
- **Temperature**: Day/night temps, min/max ranges (Celsius)
- **Humidity**: Average, min, max percentages
- **Air circulation**: None, minimal, moderate, strong
- **Ventilation**: Poor, adequate, good, excellent
- **CO2 levels**: PPM (ambient ~400, enhanced ~1200-1500)
- **Season**: Spring, summer, fall, winter
- **Hardiness zone**: USDA zones (e.g., "9b", "10a")

**Why it matters**: Plants have optimal temperature and humidity ranges. Extremes cause stress or death. Good airflow prevents disease.

### 📍 Growing Location
- **Location type**: Indoor, outdoor, greenhouse, polytunnel, shade house, window, balcony
- **Indoor details**: Room type (bedroom, basement, grow tent)
- **Outdoor details**:
  - Exposure to elements: Protected, semi-protected, exposed
  - Elevation: Meters above sea level
  - Slope: Flat, gentle, moderate, steep
  - Aspect: Slope direction (affects sun exposure)

**Why it matters**: Location affects everything - temperature, humidity, light, pests. Indoor vs outdoor requires different care.

### 🪴 Container Information
- **Type**: Pot, raised bed, ground, hydroponic, aeroponic, fabric pot, etc.
- **Material**: Plastic, terracotta, ceramic, fabric, wood, metal
- **Size**: Gallons, diameter, or dimensions
- **Volume**: Liters
- **Depth**: Centimeters
- **Drainage**: Yes/no, number of holes

**Why it matters**: Container size affects root development and watering frequency. Drainage is critical - no drainage = dead plant.

### 💧 Watering Schedule
- **Method**: Hand water, drip, soaker hose, sprinkler, self-watering, hydroponic
- **Frequency**: Daily, every 2-3 days, weekly, etc.
- **Amount**: Liters, "until runoff", inches
- **Water source**: Tap, well, rain, filtered, distilled, RO
- **Water quality**:
  - pH: Affects nutrient availability
  - TDS: Total dissolved solids (PPM)
  - Chlorine: Yes, no, or filtered

**Why it matters**: Over/underwatering kills more plants than anything. Water quality affects long-term soil health.

### 🌿 Surrounding Environment
- **Companion plants**: Other species growing nearby
- **Nearby features**: Trees, structures, walls, fences
- **Ground cover**: Mulch, grass, bare soil, gravel
- **Wildlife**:
  - Pollinators: Bees, butterflies, hummingbirds
  - Beneficial insects: Ladybugs, lacewings
  - Pests: Name, severity, treatment, date observed
  - Diseases: Name, symptoms, severity, treatment
- **Microclimate factors**:
  - Wind exposure: Sheltered, moderate, exposed, windy
  - Frost pockets: Yes/no
  - Heat traps: Yes/no
- **Ecosystem type**: Urban, suburban, rural, forest, desert, coastal, mountain, tropical

**Why it matters**: Companion planting improves growth. Pest/disease tracking helps prevention. Microclimates explain unexpected results.

### 📈 Growth Metrics
- **Measurements**: Height, width, leaf count, flower count, fruit count
- **Health score**: 0-100 rating
- **Vigor**: Poor, fair, good, excellent
- **Tracking**: Photos and notes over time

**Why it matters**: Measure growth to evaluate if conditions are optimal. Data drives improvement.

## API Endpoints

### Get Recommendations
```http
GET /api/environment/recommendations?plantId=xyz
```

Returns personalized recommendations based on your plant's environment:
- **Critical issues**: Must fix immediately (no drainage, extreme temps)
- **High priority**: Important for health (pH problems, insufficient light)
- **Medium priority**: Optimization opportunities (humidity, amendments)
- **Low priority**: Minor improvements (water quality tweaks)
- **Environmental health score**: 0-100 overall rating

**Example response**:
```json
{
  "environmentalHealth": 75,
  "recommendations": [
    {
      "category": "soil",
      "priority": "high",
      "issue": "Low soil pH (5.2)",
      "recommendation": "Add lime to raise pH. Most plants prefer 6.0-7.0",
      "impact": "Acidic soil can lock out nutrients and harm roots"
    },
    {
      "category": "climate",
      "priority": "medium",
      "issue": "Low humidity (25%)",
      "recommendation": "Mist plants, use humidity tray, or group plants together",
      "impact": "Low humidity can cause leaf tip browning and stress"
    }
  ]
}
```

### Find Similar Environments
```http
GET /api/environment/similar?plantId=xyz&minScore=70
```

Finds other plants growing in similar conditions:
- Compare your environment with successful growers
- Learn from plants that thrive in similar setups
- Get ideas for what works in your conditions

**Similarity factors**:
- Location type (indoor/outdoor/greenhouse)
- Soil type and pH
- Temperature and humidity ranges
- Lighting conditions
- Water source and quality
- Container type

**Scores**:
- **90-100**: Nearly identical conditions
- **75-89**: Very similar - expect similar results
- **60-74**: Moderately similar
- **40-59**: Some similarities
- **0-39**: Very different

### Compare Two Plants
```http
GET /api/environment/compare?plant1=xyz&plant2=abc
```

Direct comparison of two specific plants:
- See exactly what's similar and different
- Learn why one plant might be thriving while another struggles
- Identify which factors to adjust

### Growth Correlation Analysis
```http
GET /api/environment/analysis?species=tomato
```

Network-wide analysis to identify optimal conditions:
- What pH do successful plants average?
- What temperature range works best?
- Which lighting type has best results?
- Success rates by location type, soil type, etc.

**Filter by species** to get species-specific insights!

## How Recommendations Work

The system analyzes your environment and generates priority-based recommendations:

### Soil Recommendations
- **pH < 5.5**: Add lime (priority: high)
- **pH > 7.5**: Add sulfur (priority: high)
- **Organic matter < 3%**: Add compost (priority: medium)
- **Poor drainage**: Add perlite/sand or raise beds (priority: high)

### Climate Recommendations
- **Temp > 35°C**: Provide shade, increase watering (priority: high)
- **Temp < 10°C**: Frost protection needed (priority: high)
- **Humidity < 30%**: Mist, use humidity trays (priority: medium)
- **Humidity > 80%**: Improve airflow (priority: medium)

### Light Recommendations
- **< 4 hours/day**: Move to brighter spot or add grow lights (priority: high)
- **Natural light direction**: Optimize plant placement

### Nutrient Recommendations
- **Low NPK**: Apply balanced fertilizer (priority: medium)
- **High EC/TDS**: Reduce feeding or flush (priority: medium)

### Water Recommendations
- **pH > 7.5**: Consider pH adjustment or rainwater (priority: low)
- **Chlorinated**: Let sit 24h or filter (priority: low)

### Container Recommendations
- **No drainage**: Add holes IMMEDIATELY (priority: CRITICAL)
- **Too small**: Repot to larger container (priority: medium)

## Environmental Health Scoring

The system calculates a 0-100 health score based on:

**Perfect score (100)**: Everything optimal
- Soil pH 6.0-7.0
- Good drainage
- Organic matter > 3%
- Temps 15-30°C
- Humidity 40-70%
- Adequate light (6+ hours or proper artificial)
- Proper container with drainage
- Good water quality

**Deductions**:
- **-15 points**: No container drainage (CRITICAL)
- **-15 points**: Insufficient light (< 4 hours)
- **-10 points**: Extreme pH (< 5.5 or > 7.5)
- **-10 points**: Extreme temperature (< 10°C or > 35°C)
- **-10 points**: Poor soil drainage
- **-5 points**: Low organic matter
- **-5 points**: Poor humidity (< 30% or > 80%)
- **-5 points**: No airflow
- **-5 points**: Chlorinated water
- **-5 points**: High water pH

**Score interpretation**:
- **90-100**: Excellent conditions
- **75-89**: Good conditions, minor improvements possible
- **60-74**: Adequate, several opportunities for optimization
- **40-59**: Suboptimal, multiple issues to address
- **0-39**: Poor conditions, plant likely struggling

## Best Practices

### When to Track Environmental Data

**Always track**:
- When registering a new plant
- After making changes (repotting, moving, fertilizing)
- When troubleshooting problems
- Before/after cloning (compare parent and clone environments)

**Update regularly**:
- Monthly for stable setups
- Weekly during active growth
- Daily when troubleshooting or experimenting

### What to Measure

**Essentials** (track these at minimum):
- Soil type and pH
- Location type (indoor/outdoor)
- Light exposure (hours/day)
- Temperature range
- Watering frequency

**Recommended** (for better insights):
- Soil drainage and amendments
- Humidity
- Container details
- Nutrient applications
- Growth measurements

**Advanced** (for serious growers):
- Full NPK and micronutrients
- EC/TDS measurements
- PPFD/DLI for lighting
- CO2 levels
- Pest/disease tracking
- Companion plants

### Tips for Accurate Tracking

1. **Measure, don't guess**: Use pH meters, thermometers, soil probes
2. **Track over time**: Conditions change - update seasonally
3. **Note anomalies**: Heatwaves, cold snaps, unusual events
4. **Photo documentation**: Pictures reveal patterns you might miss
5. **Consistent timing**: Measure at the same time of day
6. **Calibrate instruments**: Test meters regularly
7. **Record failures too**: Learning what doesn't work is valuable

## Use Cases

### For Home Growers
"My tomato plant is struggling. Let me check recommendations..."
- System identifies low soil pH and insufficient light
- Suggests adding lime and moving to sunnier spot
- Compares with successful tomato growers nearby
- Shows that similar plants thrive with 8+ hours sun and pH 6.5

### For Propagation
"I want to clone my best basil plant..."
- Records current environment that's producing healthy growth
- When giving clone to friend, shares environmental data
- Friend replicates conditions for best success
- Tracks if clone thrives in new environment

### For Troubleshooting
"Why are my pepper leaves yellowing?"
- Checks pH: 7.8 (too high)
- System recommends sulfur to lower pH
- Compares with healthy pepper plants: pH 6.0-6.5
- Adds sulfur, yellowing stops within 2 weeks

### For Learning
"What conditions work best for lavender?"
- Searches network for successful lavender plants
- Finds they all have: pH 6.5-7.5, full sun, excellent drainage
- Notices growers with poor drainage have struggling plants
- Adjusts setup before planting

### For Research
"Does companion planting really work?"
- Analyzes all plants with tomato-basil companions
- Compares health scores with lone tomatoes
- Statistical analysis shows 15% better vigor
- Data supports traditional growing wisdom

## Privacy Considerations

Environmental data can be:
- **Shared openly**: Help others learn from your setup
- **Kept private**: Track for yourself without broadcasting
- **Anonymous**: Share conditions without revealing location/identity

Use privacy settings to control:
- Whether environment data is visible to others
- Whether it appears in similarity searches
- Whether it's included in analysis
- Location obfuscation (see TOR_SETUP.md)

## Advanced Features

### Automated Recommendations
As you add more plants:
- System learns what works in YOUR specific conditions
- Personalized recommendations based on your history
- "You've had success with these pH levels..."

### Seasonal Tracking
- Record how conditions change through the year
- Plan planting schedules based on historical data
- Anticipate challenges (summer heat, winter cold)

### Clone Comparison
- Automatically compare clone environments with parent
- See if environmental differences affect growth
- Optimize clone success rates

### Community Insights
- "Plants in your area typically use X soil type"
- "Growers in similar climates report best results with Y"
- "This species thrives in conditions like yours"

## Future Enhancements

Coming soon:
- **Photo-based tracking**: Upload photos, AI analyzes plant health
- **Sensor integration**: Automatic data from soil sensors, weather stations
- **Mobile app**: Track on-the-go with smartphone
- **Notifications**: "Time to water", "pH out of range"
- **Marketplace integration**: Buy recommended products
- **Expert consultations**: Connect with master growers

## Troubleshooting

**"My recommendations don't make sense"**
- Check that measurements are accurate
- Ensure units are correct (Celsius not Fahrenheit)
- Verify pH probe is calibrated
- Update environmental data if conditions changed

**"No similar plants found"**
- Lower the minimum similarity score
- Your setup might be unique!
- Add more environmental details for better matching
- Check that other plants have environmental data

**"Analysis shows low success rate"**
- System is helping you identify what to improve
- Follow recommendations to optimize
- Learn from successful growers
- Don't be discouraged - this is how you learn!

## Getting Help

- **Issues**: GitHub Issues for bugs
- **Questions**: Community forum for growing advice
- **Contributions**: PRs welcome for new features
- **Data privacy**: See PRIVACY.md

---

**Remember**: The goal is learning and improvement, not perfection. Every data point helps you become a better grower!

Happy tracking! 🌱📊
