# PythonAnywhere Deployment Checklist

## Before You Start
- [ ] Read `PYTHONANYWHERE_DEPLOYMENT.md`
- [ ] Have your `credentials.json` file ready
- [ ] Have your Google Spreadsheet ID ready

---

## Step 1: Create Account
- [ ] Go to https://www.pythonanywhere.com/
- [ ] Click "Pricing & signup"
- [ ] Choose: FREE (for testing) or €5/month (for production with custom domain)
- [ ] Create account with company email
- [ ] Write down your username: `___________________________`

---

## Step 2: Prepare Files Locally
- [ ] Verify all files are in your project folder:
  - [ ] `app.py`
  - [ ] `client_intelligence_helper.py`
  - [ ] `priority_actions_helper.py`
  - [ ] `requirements.txt`
  - [ ] `credentials.json`
  - [ ] `templates/` folder
  - [ ] `static/` folder (if exists)
- [ ] Create ZIP file of all project files: `sales-dashboard.zip`

---

## Step 3: Upload to PythonAnywhere
- [ ] Log into PythonAnywhere dashboard
- [ ] Click **"Files"** tab
- [ ] Upload `sales-dashboard.zip`
- [ ] Open **"Bash" console**
- [ ] Run: `unzip sales-dashboard.zip`
- [ ] Run: `ls` to verify files extracted

---

## Step 4: Create Virtual Environment
In Bash console:
- [ ] Run: `mkvirtualenv --python=/usr/bin/python3.10 sales-env`
- [ ] Run: `workon sales-env`
- [ ] Run: `cd ~/sales-dashboard` (or your folder name)
- [ ] Run: `pip install -r requirements.txt`
- [ ] Wait for installation (2-5 minutes)

---

## Step 5: Create Web App
- [ ] Go to **"Web"** tab
- [ ] Click **"Add a new web app"**
- [ ] Select: **"Manual configuration"**
- [ ] Select: **Python 3.10**
- [ ] Complete wizard
- [ ] Write down your URL: `https://_______________.pythonanywhere.com`

---

## Step 6: Configure WSGI File
- [ ] In **Web** tab, find **"Code"** section
- [ ] Click WSGI configuration file link
- [ ] Open `pythonanywhere_wsgi.py` (from your local files)
- [ ] Update `USERNAME` to your PythonAnywhere username
- [ ] Generate random SECRET_KEY: https://randomkeygen.com/
- [ ] Copy content to WSGI file in PythonAnywhere
- [ ] Click **"Save"**

---

## Step 7: Set Virtual Environment Path
- [ ] In **Web** tab, find **"Virtualenv"** section
- [ ] Enter: `/home/YOUR_USERNAME/.virtualenvs/sales-env`
- [ ] Replace `YOUR_USERNAME` with your actual username
- [ ] Click checkmark to save

---

## Step 8: Set Working Directory
- [ ] In **Web** tab, **"Code"** section
- [ ] Set **"Working directory"**: `/home/YOUR_USERNAME/sales-dashboard`
- [ ] Replace `YOUR_USERNAME` with your actual username

---

## Step 9: Reload Web App
- [ ] Scroll to top of **Web** tab
- [ ] Click big green **"Reload YOUR_USERNAME.pythonanywhere.com"** button
- [ ] Wait 15-30 seconds

---

## Step 10: Test Your App
- [ ] Click your URL: `https://YOUR_USERNAME.pythonanywhere.com`
- [ ] Should see login page
- [ ] Try logging in
- [ ] Test loading data
- [ ] Test Client Intelligence feature

---

## Step 11: Update Google OAuth (IMPORTANT!)
- [ ] Go to: https://console.cloud.google.com/
- [ ] Find your OAuth credentials
- [ ] Add to **"Authorized redirect URIs"**:
  - `https://YOUR_USERNAME.pythonanywhere.com/oauth2callback`
- [ ] Save changes
- [ ] Test login again

---

## Step 12: Share with Sales Team
- [ ] Test all features thoroughly
- [ ] Share URL with sales team
- [ ] Provide login instructions
- [ ] Monitor for any errors

---

## Optional: Set Up Custom Domain (Requires €5/month plan)
- [ ] Upgrade to Hacker plan (€5/month)
- [ ] In **Web** tab, add new web app for custom domain
- [ ] Enter: `sales.globalerc.pt`
- [ ] Configure according to prompts
- [ ] Update DNS in your domain registrar:
  - Add CNAME: `sales` → `YOUR_USERNAME.pythonanywhere.com`
- [ ] Wait 1-24 hours for DNS propagation
- [ ] Test custom domain

---

## Troubleshooting

### If you see "Something went wrong :("
- [ ] Check error log in **Web** tab → **"Log files"** → **"Error log"**
- [ ] Common issues:
  - Wrong path in WSGI file
  - Virtual environment not set correctly
  - Missing dependencies

### If login fails
- [ ] Check Google OAuth redirect URIs include PythonAnywhere URL
- [ ] Check `BASE_URL` in WSGI file matches your actual URL
- [ ] Check error log for details

### If data doesn't load
- [ ] Check `credentials.json` uploaded correctly
- [ ] Check file permissions: Run in Bash: `chmod 600 credentials.json`
- [ ] Check spreadsheet ID is correct

---

## Maintenance

### To Update Your App:
1. Upload new files via **Files** tab
2. Go to **Web** tab
3. Click **"Reload"** button

### To View Errors:
- **Web** tab → **"Log files"** → **"Error log"**

### To Check Usage:
- **Account** tab → View CPU usage, disk space

---

## Success Criteria
- ✅ URL loads without errors
- ✅ Login works with Google account
- ✅ Dashboard displays data correctly
- ✅ All features work (filters, exports, Client Intelligence)
- ✅ Sales team can access from their devices
- ✅ No dependency on your local PC

---

## Support Resources
- PythonAnywhere Help: https://help.pythonanywhere.com/
- Flask on PythonAnywhere: https://help.pythonanywhere.com/pages/Flask/
- PythonAnywhere Forums: https://www.pythonanywhere.com/forums/

---

## Contact Info for Help
If you get stuck:
- PythonAnywhere Support: help@pythonanywhere.com
- Check error logs first!
- Search PythonAnywhere forums
