# 🎉 FarmMatch - Start Here!

## ⚡ Quick Start (30 seconds)

### Start the System
```bash
cd "/Users/jonathan/SynologyDrive/Since Today/PROJECTEN/farmmatch/scraper"
./start_system.sh
```

### Access the UI
- **Map Viewer**: http://localhost:8000/map_viewer_advanced.html
- **Criteria Manager**: http://localhost:8000/criteria_manager.html

### Run First Update
1. Open [Criteria Manager](http://localhost:8000/criteria_manager.html)
2. Go to **Overview** tab
3. Click **"🔄 Full Update"**
4. Wait 20-30 minutes

### Stop the System
```bash
./stop_system.sh
```

---

## 🎯 What Can You Do?

### 1. **View Properties on Map**
- Open [Map Viewer](http://localhost:8000/map_viewer_advanced.html)
- Use filters to find properties:
  - **Overall Score**: 1-5 (higher = better match)
  - **Price Range**: Min/Max filter
  - **Individual Criteria**: Market garden, guest accommodation, etc.
  - **Risk Profile**: Low, Medium, High
- Click properties for details

### 2. **Update Property Data**
- **Full Update**: Scrape → Geocode → Analyze → Check availability (20-30 min)
- **Scrape Only**: Just update property list (5-10 min)
- **Check Availability**: Remove sold properties (5-10 min)

All from Criteria Manager → Overview tab → Click buttons!

### 3. **Adjust Criteria Weights**
- Open [Criteria Manager](http://localhost:8000/criteria_manager.html)
- Go to **Custom Criteria** or **GPT Criteria** tab
- Adjust sliders (0-5, higher = more important)
- Click "💾 Save Weights"
- Re-run evaluation to see new scores

### 4. **Edit Criteria**
- Click "✏️ Edit" button on any criterion
- Modify evaluation logic (Custom Criteria)
- Update descriptions (GPT Criteria)
- Save and re-evaluate

---

## 🤖 Automation Setup

### Weekly Scraping (Set and Forget)
```bash
# Runs every Sunday at 2 AM
nohup python3 auto_scrape_favorites.py schedule sunday 02:00 > scraper.log 2>&1 &

# Check if running
ps aux | grep auto_scrape_favorites
```

### Daily Availability Checks
```bash
# Runs every day at 3 AM
nohup python3 auto_availability_check.py > availability.log 2>&1 &

# Check if running
ps aux | grep auto_availability_check
```

---

## 📊 Understanding Scores

### Overall Score (1-5)
- **4.5-5.0**: 🌟 Excellent - Top properties!
- **3.5-4.4**: ✅ Good - Worth investigating
- **2.5-3.4**: 🤔 Fair - Has potential
- **1.5-2.4**: ⚠️ Poor - Significant issues
- **1.0-1.4**: ❌ Very poor - Avoid

### Individual Criteria
- **5**: Perfect for this criterion
- **4**: Very good
- **3**: Adequate/neutral
- **2**: Poor
- **1**: Very poor

### Risk Profile
- **Low**: Safe investment, few concerns
- **Medium**: Some risks to consider
- **High**: Significant uncertainties (legal, location, climate)

---

## 🔧 Troubleshooting

### "Unable to connect" or "NetworkError"
**Solution**: Start the system
```bash
./start_system.sh
```

### "auth.json not found" when scraping
**Solution**: Run manual scrape once
```bash
python3 favorites_scraper.py
# Log into Properstar when browser opens
# Press Enter when logged in
```

### No properties showing on map
**Solution**: Run a full update
1. Criteria Manager → Overview → "🔄 Full Update"
2. Wait 20-30 minutes
3. Refresh map viewer

### Buttons not working
**Check**: Is API server running?
```bash
curl http://localhost:5001/api/get-api-key
# Should return JSON, not error
```

If not running: `./start_system.sh`

---

## 📁 Key Files

### Data Files
- **enriched_data.json** - All property data with scores
- **extracted_property_urls.csv** - Raw scraped data
- **auth.json** - Properstar login session

### Scripts
- **start_system.sh** - Start everything ⭐
- **stop_system.sh** - Stop everything
- **auto_scrape_favorites.py** - Automated scraping
- **check_availability.py** - Check if properties still available
- **custom_criteria.py** - Custom criteria evaluation

### UI
- **map_viewer_advanced.html** - Interactive map
- **criteria_manager.html** - Criteria management UI

### Logs
- **/tmp/farmmatch_api.log** - API server logs
- **/tmp/farmmatch_web.log** - Web server logs
- **scraper.log** - Scraping logs (if automated)
- **availability.log** - Availability check logs

---

## 📚 Documentation

Detailed guides in the scraper directory:

1. **[SETUP_COMPLETE.md](SETUP_COMPLETE.md)** - Complete setup guide
2. **[AUTO_SCRAPING_GUIDE.md](AUTO_SCRAPING_GUIDE.md)** - Scraping automation
3. **[AVAILABILITY_CHECKER_GUIDE.md](AVAILABILITY_CHECKER_GUIDE.md)** - Availability system
4. **[OPTIMIZATION_ANALYSIS.md](OPTIMIZATION_ANALYSIS.md)** - Criteria details

---

## ✨ Features Summary

✅ **Automated scraping** - Weekly or on-demand
✅ **Rich location data** - Country, state, district, city, postcode
✅ **8 custom criteria** - FREE APIs (weather, location, etc.)
✅ **6 GPT criteria** - AI-powered analysis
✅ **Availability checking** - Auto-remove sold properties
✅ **Interactive map** - Filter and explore visually
✅ **Criteria editing** - Customize evaluation logic
✅ **Weight adjustment** - Prioritize what matters to you
✅ **Min/Max price filters** - Stay in budget
✅ **Risk assessment** - Know the uncertainties

---

## 🎯 Recommended Workflow

### First Time
1. Start system: `./start_system.sh`
2. Run full update (Criteria Manager → Overview)
3. Wait 20-30 minutes
4. Explore results in Map Viewer
5. Adjust criteria weights if needed
6. Set up automation for future

### Weekly
- System automatically scrapes new favorites (if automated)
- Check Map Viewer for new properties
- Adjust filters to refine search

### As Needed
- Add new favorites on Properstar
- Click "🔄 Full Update" to process them
- Remove unavailable properties: `python3 check_availability.py --remove`

---

## 💡 Pro Tips

1. **Combine Filters**: Use multiple criteria + price range to find hidden gems
2. **Watch Risk Profile**: High risk might be okay if score is excellent
3. **Weight Adjustment**: Make criteria you care about weigh more (set to 5)
4. **Regular Updates**: Run availability checks 2-3x per week
5. **Save Good Ones**: Use Properstar's favorites to keep track

---

## 🚀 You're Ready!

Your FarmMatch system is fully operational and ready to help you find the perfect regenerative farm property.

**Start exploring**: http://localhost:8000/map_viewer_advanced.html

Happy property hunting! 🏡🌱
