← back to Wine Finder
SETUP.md
258 lines
# Quick Setup Guide
Follow these steps to get Red Thunder Wine Tracker running on your server.
## Step-by-Step Setup
### Step 1: Google Sheets Setup (5-10 minutes)
1. **Create Google Sheet**
- Go to [Google Sheets](https://sheets.google.com)
- Create a new sheet named "Red Thunder Wine Tracker"
- Copy the Sheet ID from the URL:
```
https://docs.google.com/spreadsheets/d/SHEET_ID_HERE/edit
```
2. **Enable Google Sheets API**
- Go to [Google Cloud Console](https://console.cloud.google.com/)
- Create a new project (or use existing)
- Go to "APIs & Services" → "Library"
- Search for "Google Sheets API" and click "Enable"
3. **Create Service Account**
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "Service Account"
- Name it "wine-tracker-service"
- Click "Create and Continue" → "Done"
4. **Download Credentials**
- Click on the service account you just created
- Go to "Keys" tab
- Click "Add Key" → "Create New Key"
- Choose "JSON" and download
- Save as `google-credentials.json` in `/root/WebsitesMisc/WineFinder/`
5. **Share the Sheet**
- Open the downloaded `google-credentials.json`
- Find the `client_email` field (looks like: `wine-tracker-service@project-id.iam.gserviceaccount.com`)
- In your Google Sheet, click "Share"
- Paste the service account email
- Give it "Editor" access
- Click "Send" (uncheck "Notify people")
### Step 2: Slack Setup (5 minutes)
1. **Create Slack App**
- Go to [https://api.slack.com/apps](https://api.slack.com/apps)
- Click "Create New App" → "From scratch"
- App Name: "Red Thunder Wine Tracker"
- Workspace: designerwallc-hyg8426.slack.com
- Click "Create App"
2. **Enable Incoming Webhooks**
- In the left sidebar, click "Incoming Webhooks"
- Toggle "Activate Incoming Webhooks" to **ON**
- Scroll down and click "Add New Webhook to Workspace"
- Select a channel (create #wine-alerts if needed)
- Click "Allow"
3. **Copy Webhook URL**
- Copy the webhook URL that starts with `https://hooks.slack.com/services/...`
- Save it for the next step
### Step 3: Configure Environment (2 minutes)
Edit `/root/WebsitesMisc/WineFinder/.env` file:
```bash
nano /root/WebsitesMisc/WineFinder/.env
```
Update these values:
```env
GOOGLE_SHEET_ID=paste-your-sheet-id-here
SLACK_WEBHOOK_URL=paste-your-webhook-url-here
```
Save and exit (Ctrl+X, then Y, then Enter)
### Step 4: Open Firewall (1 minute)
```bash
sudo ufw allow 9222/tcp
sudo ufw status
```
You should see port 9222 listed as ALLOW.
### Step 5: Start the Application (1 minute)
```bash
cd /root/WebsitesMisc/WineFinder
npm start
```
You should see:
```
🍷 Red Thunder Wine Tracker running on port 9222
📊 Access at: http://localhost:9222
🔐 Login with username: admin
```
### Step 6: Test the Application
1. **Access the site**
- Open your browser
- Go to `http://your-server-ip:9222`
- You should see the login page
2. **Login**
- Username: `admin`
- Password: `2025`
3. **Test Search**
- Click the "FOXEN" button
- Wait for results to load
- Check your Google Sheet - new rows should appear
- Check your Slack channel - you may see alerts if prices changed
## Verification Checklist
- [ ] Google Sheet created and shared with service account
- [ ] Google credentials JSON file in project directory
- [ ] Slack webhook URL configured
- [ ] Port 9222 open in firewall
- [ ] Application running without errors
- [ ] Can access login page
- [ ] Can login successfully
- [ ] Search returns results
- [ ] Data appears in Google Sheet
- [ ] Slack notifications working (if price spike detected)
## Running in Background
To keep the application running after you close SSH:
### Option 1: Using PM2 (Recommended)
```bash
# Install PM2
npm install -g pm2
# Start the application
pm2 start server.js --name wine-tracker
# Save PM2 process list
pm2 save
# Set PM2 to start on boot
pm2 startup
# View logs
pm2 logs wine-tracker
# View status
pm2 status
# Restart
pm2 restart wine-tracker
# Stop
pm2 stop wine-tracker
```
### Option 2: Using Screen
```bash
# Install screen
sudo apt-get install screen
# Start a new screen session
screen -S wine-tracker
# Run the application
npm start
# Detach from screen: Press Ctrl+A then D
# Reattach later
screen -r wine-tracker
# Kill the session
screen -X -S wine-tracker quit
```
### Option 3: Using nohup
```bash
# Start in background
nohup npm start > wine-tracker.log 2>&1 &
# View logs
tail -f wine-tracker.log
# Find process
ps aux | grep node
# Kill process
kill <process-id>
```
## Troubleshooting
### Can't access the site
```bash
# Check if the app is running
ps aux | grep node
# Check if port is listening
sudo netstat -tulpn | grep 9222
# Check firewall
sudo ufw status
# View application logs
tail -f wine-tracker.log # if using nohup
pm2 logs wine-tracker # if using PM2
```
### Google Sheets not updating
1. Verify service account email has access to the sheet
2. Check that GOOGLE_SHEET_ID in .env is correct
3. Ensure google-credentials.json is in the right location
4. Check server logs for errors
### Slack not sending notifications
1. Test webhook URL with curl:
```bash
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"Test from Red Thunder"}' \
YOUR_SLACK_WEBHOOK_URL
```
2. Verify webhook URL in .env is correct
3. Check that Slack app is still active
4. Note: Alerts only trigger when price increases >20%
## Next Steps
- Bookmark the site URL
- Set up PM2 for automatic restart on server reboot
- Test price spike alerts (may need to manually adjust historical data)
- Customize the price spike threshold in .env if needed
- Add more wineries to quick search buttons (edit public/index.html)
## Support
If you encounter issues:
1. Check the troubleshooting section above
2. Review server logs
3. Verify all credentials are correct
4. Contact Steve Abrams at steve@designerwallcoverings.com