# Interactive Terminal Search Scripts

Two PowerShell scripts for searching travel deals via interactive prompts.

## 🚀 Quick Start

### 1. Start the Server
```powershell
npm run dev
```

### 2. Run a Search Script

**Option A: Full Interactive Search** (with detailed feature preferences)
```powershell
.\search-interactive.ps1
```

**Option B: Quick Search** (simplified prompts)
```powershell
.\search-quick.ps1
```

---

## 📋 What You'll Be Asked

### Basic Travel Info
1. **Where are you leaving from?**
   - Enter IATA airport code (e.g., `YOW`, `YYZ`, `YUL`, `YVR`)

2. **Where do you want to go?**
   - Enter destinations separated by commas (e.g., `CUN,PUJ,MBJ`)

3. **When do you want to travel?**
   - Earliest departure date: `2025-12-15`
   - Latest return date: `2026-01-15`

4. **How long do you want to stay?**
   - Minimum nights: `5`
   - Maximum nights: `9`

5. **What's your budget?**
   - Enter amount in CAD or leave blank for no limit

6. **Flight preferences**
   - Non-stop flights only? (y/n)

### Destination Features (Rate 0-10)

The script will ask you to rate the importance of:

- 🏖️ **Beach** - Direct beach access
- 🏊 **Pool** - Swimming pool facilities
- ⛳ **Golf** - Golf courses nearby
- 💆 **Spa** - Spa and wellness facilities
- 🍽️ **Food** - Dining options and local cuisine
- 🎉 **Nightlife** - Bars, clubs, entertainment
- 🛍️ **Shopping** - Shopping centers and markets
- 🏛️ **Culture** - Museums, historical sites
- 🚵 **Outdoor** - Hiking, water sports, activities
- 👨‍👩‍👧‍👦 **Family** - Family-friendly amenities

**Rating Guide:**
- `0` = Not important at all
- `5` = Nice to have
- `10` = Must have

### Search Sources
Choose which sources to include:
- Deal sites (YOWDeals, YYZDeals, etc.)
- Skyscanner
- Google Flights
- Air Canada

---

## 🎯 Example Session

```
========================================
   Holiday Travel Deal Finder
========================================

Where are you leaving from?
(Enter IATA airport code, e.g., YOW, YYZ, YUL, YVR)
Origin: YOW

Where do you want to go?
(Enter one or more IATA codes, separated by commas)
Examples: CUN,PUJ,MBJ (Caribbean) or LHR,CDG,FCO (Europe)
Destinations: CUN,PUJ,MBJ

When do you want to travel?
Earliest departure date (YYYY-MM-DD):
Start date: 2025-12-15
Latest return date (YYYY-MM-DD):
End date: 2026-01-15

How long do you want to stay?
Minimum nights: 7
Maximum nights: 9

What's your budget?
(Leave blank for no budget limit)
Budget (CAD): 1000

Flight preferences:
Non-stop flights only? (y/n): n

========================================
   Destination Features
========================================

Rate the importance of these features (0-10):
0 = Not important, 10 = Must have

Beach access:
Rating (0-10): 10

Swimming pool:
Rating (0-10): 8

Golf course nearby:
Rating (0-10): 2

Spa & wellness:
Rating (0-10): 7

Food & dining options:
Rating (0-10): 9

Nightlife & entertainment:
Rating (0-10): 6

Shopping:
Rating (0-10): 3

Cultural attractions:
Rating (0-10): 4

Outdoor activities (hiking, water sports):
Rating (0-10): 8

Family-friendly:
Rating (0-10): 7

========================================
   Search Sources
========================================

Which sources do you want to search?
Deal sites (YOWDeals, etc)? (y/n): y
Skyscanner? (y/n): y
Google Flights? (y/n): y
Air Canada? (y/n): y

========================================
   Search Summary
========================================

From: YOW
To: CUN, PUJ, MBJ
Dates: 2025-12-15 to 2026-01-15
Stay: 7-9 nights
Budget: $1000 CAD
Non-stop only: False
Sources: Deals, Skyscanner, GoogleFlights, AirCanada

Top priorities:
  beach: ██████████ 10/10
  food: █████████ 9/10
  pool: ████████ 8/10

========================================

Search now? (y/n): y

Searching for deals...
(This may take 10-30 seconds)

✓ Found 47 results!

========================================
   Top Deals
========================================

[1] Ottawa → Cancun (7 nights)
    Price: $685 CAD
    Duration: 7 nights
    Dates: 2025-12-20 → 2025-12-27
    Source: Skyscanner Link
    Link: https://www.skyscanner.ca/...
    Score: 10542

[2] YOW → PUJ (8 nights)
    Price: $712 CAD
    Duration: 8 nights
    Dates: 2025-12-22 → 2025-12-30
    Source: yowdeals.com
    Link: https://www.yowdeals.com/...
    Score: 10235

...

Export all results to CSV? (y/n): y
✓ Exported to travel_deals_2025-10-29_143052.csv

Open top deal in browser? (y/n): y
✓ Opening in browser...

Happy travels! ✈️🏖️
```

---

## 🎨 How Feature Weighting Works

The app matches your preferences with destination profiles:

### Example: Cancun (CUN)
- Beach: 10/10 ⭐⭐⭐⭐⭐
- Pool: 9/10 ⭐⭐⭐⭐⭐
- Golf: 6/10 ⭐⭐⭐
- Spa: 8/10 ⭐⭐⭐⭐
- Food: 8/10 ⭐⭐⭐⭐
- Nightlife: 9/10 ⭐⭐⭐⭐⭐
- Shopping: 7/10 ⭐⭐⭐⭐
- Culture: 5/10 ⭐⭐⭐
- Outdoor: 8/10 ⭐⭐⭐⭐
- Family: 9/10 ⭐⭐⭐⭐⭐

If you rate **Beach: 10** and **Food: 9**, destinations like Cancun will score higher because they excel in those areas.

### Supported Destinations

**Caribbean**: CUN, PUJ, MBJ, NAS
**Europe**: LHR, CDG, FCO, BCN, AMS  
**USA**: LAX, LAS, MIA, MCO, HNL

*Other destinations use average ratings*

---

## 💡 Tips

1. **Be specific with priorities** - Rate 3-5 features as 8+ for best matching
2. **Set realistic budgets** - Add 10-15% buffer for better results
3. **Multiple destinations** - Enter 3-5 options to see more deals
4. **Flexible dates** - Wider date ranges (30-60 days) find more options
5. **Save results** - Export to CSV for comparison and analysis

---

## 🔧 Troubleshooting

**"Unable to connect to the remote server"**
- Make sure the dev server is running: `npm run dev`
- Check that it's on port 4000: look for "Local: http://localhost:4000"

**"No deals found"**
- Try removing or increasing the budget
- Expand your date range
- Add more destination options
- Set non-stop to `n` instead of `y`

**Script won't run**
- Enable script execution: `Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned`
- Or run with: `powershell -ExecutionPolicy Bypass -File .\search-interactive.ps1`

---

## 📊 Understanding Results

Results are sorted by a **composite score** that considers:
- **Price** (lower is better)
- **Flight type** (non-stop gets bonus)
- **Trip length** (closer to 7 nights is ideal)
- **Source reliability** (curated deal sites get bonus)
- **Feature match** (how well destination matches your priorities)

Higher scores = better matches for your criteria!

---

Happy searching! 🌴✈️
