# Windows Server Deployment Checklist

## ☑️ Pre-Deployment (On Your PC)

- [ ] All code tested locally
- [ ] `credentials.json` ready
- [ ] Google Spreadsheet ID noted down
- [ ] Server details collected:
  - [ ] Server IP address: `___________________`
  - [ ] Administrator credentials
  - [ ] Windows Server version: `___________________`
- [ ] Create deployment ZIP:
  ```powershell
  Compress-Archive -Path "C:\Users\Tiago Rebelo\Desktop\Globale RC\2-Vibe Coding\Sales Dashboard App_VScode\*" `
      -DestinationPath "C:\Users\Tiago Rebelo\Desktop\SalesDashboard-Deploy.zip"
  ```

---

## ☑️ Server Preparation

- [ ] Connect to Windows Server (RDP)
- [ ] Copy `SalesDashboard-Deploy.zip` to server
- [ ] Extract to: `C:\Sales-Dashboard`
- [ ] Python 3.8+ installed (check: `python --version`)
- [ ] Administrator access confirmed

---

## ☑️ Installation Steps

### Virtual Environment & Dependencies
- [ ] Open PowerShell as Administrator
- [ ] Navigate to: `cd C:\Sales-Dashboard`
- [ ] Create venv: `python -m venv venv`
- [ ] Activate: `.\venv\Scripts\Activate.ps1`
- [ ] Update pip: `python -m pip install --upgrade pip`
- [ ] Install requirements: `pip install -r requirements.txt`
- [ ] Install waitress: `pip install waitress`

### Windows Service Installation
- [ ] Still in PowerShell as Administrator
- [ ] Run: `.\install_windows_service.ps1`
- [ ] Wait for completion (2-5 minutes)
- [ ] Verify service running: `Get-Service -Name SalesDashboard`
- [ ] Test local access: `http://localhost:5000`

---

## ☑️ IIS Configuration (Recommended)

### Install IIS Components
- [ ] Server Manager → Add Roles → Web Server (IIS)
- [ ] Download and install URL Rewrite Module
- [ ] Download and install Application Request Routing (ARR)
- [ ] Enable ARR proxy in IIS Manager

### Create Website
- [ ] IIS Manager → Add Website
  - [ ] Name: `SalesDashboard`
  - [ ] Path: `C:\Sales-Dashboard\static`
  - [ ] Binding: HTTP, Port 80, Host: `sales.globalerc.pt`
- [ ] Create `web.config` with reverse proxy rules
- [ ] Test: `http://sales.globalerc.pt` (after hosts file edit)

---

## ☑️ SSL Certificate

### Option A: Let's Encrypt (win-acme)
- [ ] Download win-acme from https://www.win-acme.com/
- [ ] Extract to `C:\Program Files\win-acme`
- [ ] Run `wacs.exe` as Administrator
- [ ] Create certificate for `sales.globalerc.pt`
- [ ] Verify HTTPS binding in IIS
- [ ] Test: `https://sales.globalerc.pt`

### Option B: Company Certificate
- [ ] Import certificate to Windows Certificate Store
- [ ] Assign to IIS site binding

---

## ☑️ DNS Configuration

- [ ] Log into domain registrar / company DNS
- [ ] Add A record:
  - [ ] Type: `A`
  - [ ] Name: `sales`
  - [ ] Value: `SERVER_PUBLIC_IP`
  - [ ] TTL: `3600`
- [ ] If behind NAT:
  - [ ] Configure port forwarding: 443 → Server:443
- [ ] Wait for DNS propagation (5-60 minutes)
- [ ] Test: `nslookup sales.globalerc.pt`

---

## ☑️ Google OAuth Update

- [ ] Go to: https://console.cloud.google.com/
- [ ] Navigate to: APIs & Services → Credentials
- [ ] Select OAuth 2.0 Client ID
- [ ] Add to Authorized redirect URIs:
  ```
  https://sales.globalerc.pt/oauth2callback
  ```
- [ ] Save changes

---

## ☑️ Security Hardening

- [ ] HTTPS redirect enabled (web.config rule)
- [ ] HTTP traffic redirects to HTTPS
- [ ] Firewall rules configured (port 80, 443)
- [ ] `credentials.json` permissions restricted
- [ ] Environment variables set in service
- [ ] IP whitelisting (if applicable)

---

## ☑️ Testing

### Local Testing (on server)
- [ ] Service status: `Get-Service -Name SalesDashboard` → Running
- [ ] Local HTTP: `http://localhost:5000` → Loads
- [ ] Local HTTPS: `https://sales.globalerc.pt` (via hosts file) → Loads
- [ ] Check logs: `Get-Content C:\Sales-Dashboard\logs\service-output.log`

### External Testing
- [ ] From your PC: `https://sales.globalerc.pt` → Loads
- [ ] Login with Google → Works
- [ ] Load dashboard data → Displays
- [ ] Test filters → Working
- [ ] Test exports → Downloads
- [ ] Test Client Intelligence → Shows metrics
- [ ] Test from mobile → Responsive

### User Acceptance Testing
- [ ] Test with 1 sales user
- [ ] Test with 2-3 sales users simultaneously
- [ ] Verify all features work
- [ ] Check performance (page load times)
- [ ] Monitor server resources (CPU, RAM)

---

## ☑️ Monitoring Setup

- [ ] Check logs location: `C:\Sales-Dashboard\logs\`
- [ ] Set up log rotation (service configured)
- [ ] Bookmark IIS logs: `C:\inetpub\logs\LogFiles\`
- [ ] Create monitoring script or alerts
- [ ] Schedule regular log reviews

---

## ☑️ Documentation & Training

- [ ] Document server location and access
- [ ] Document admin credentials (secure location)
- [ ] Create user guide with URL: `https://sales.globalerc.pt`
- [ ] Train sales team on access
- [ ] Train 1-2 people on basic troubleshooting
- [ ] Document restart procedure

---

## ☑️ Backup & Recovery

- [ ] Backup `C:\Sales-Dashboard` (especially `credentials.json`)
- [ ] Document service configuration: `nssm dump SalesDashboard`
- [ ] Note Python version and dependencies
- [ ] Save IIS configuration
- [ ] Save SSL certificate backup
- [ ] Schedule regular backups (weekly for credentials)

---

## ☑️ Go-Live

- [ ] All tests passing
- [ ] DNS propagated globally
- [ ] SSL certificate valid
- [ ] All 6 users have Google access
- [ ] Support contact identified
- [ ] Monitoring in place
- [ ] **Announce to sales team!** 🎉
- [ ] Share URL: `https://sales.globalerc.pt`

---

## ☑️ Post-Deployment (First Week)

- [ ] Day 1: Monitor logs hourly
- [ ] Day 1: Check service status every 2 hours
- [ ] Day 2-3: Monitor logs 2x per day
- [ ] Day 4-7: Daily log review
- [ ] Collect feedback from sales team
- [ ] Address any issues immediately
- [ ] Optimize if needed

---

## 🆘 Quick Commands Reference

```powershell
# Check service status
Get-Service -Name SalesDashboard

# Restart service
Restart-Service -Name SalesDashboard

# View logs (live)
Get-Content C:\Sales-Dashboard\logs\service-output.log -Tail 50 -Wait

# View errors
Get-Content C:\Sales-Dashboard\logs\service-error.log -Tail 50

# Check port
netstat -ano | findstr :5000

# Test local
Invoke-WebRequest -Uri http://localhost:5000 -UseBasicParsing

# Check DNS
nslookup sales.globalerc.pt
```

---

## 📞 Emergency Contacts

- Server Admin: `___________________________`
- Network Team: `___________________________`
- Your Contact: `___________________________`

---

## ✅ Success Criteria

- ✅ Service running 24/7 without manual intervention
- ✅ All 6 users can access from anywhere
- ✅ Professional URL: `sales.globalerc.pt`
- ✅ HTTPS working (SSL valid)
- ✅ Login via Google working
- ✅ Data loading from Google Sheets
- ✅ All features functional
- ✅ No dependency on your PC
- ✅ Auto-restart on server reboot
- ✅ Logs being generated and rotated

---

**Estimated Total Time:** 60-90 minutes  
**Difficulty:** Medium (requires admin access)  
**Result:** Production-ready 24/7 sales dashboard! 🚀
