# Sky Art Shop - Quick Deployment Checklist

## 🎯 Pre-Deployment Setup (One-Time)

### 1. Install Prerequisites

- [ ] **Download .NET 8.0 Hosting Bundle**
  - Visit: <https://dotnet.microsoft.com/download/dotnet/8.0>
  - Look for "Hosting Bundle" under Windows
  - Install and restart computer
  
- [ ] **Enable IIS** (Run PowerShell as Administrator)

  ```powershell
  .\deploy.ps1 -InstallIIS
  ```

  - Restart computer after installation

- [ ] **Install MongoDB** (if not already)
  - Download from: <https://www.mongodb.com/try/download/community>
  - Install as Windows Service
  - Verify it's running: `net start MongoDB`

### 2. Network Configuration

- [ ] **Set Static Local IP**
  1. Control Panel → Network → Change adapter settings
  2. Right-click network → Properties → IPv4 → Properties
  3. Use static IP: e.g., `192.168.1.100`
  
- [ ] **Configure Router Port Forwarding**
  1. Access router (usually <http://192.168.1.1>)
  2. Find Port Forwarding section
  3. Forward: External Port 80 → Internal IP 192.168.1.100:80
  
- [ ] **Install No-IP DUC Client**
  1. Download: <https://www.noip.com/download>
  2. Install and login with No-IP credentials
  3. Verify it's updating your hostname

### 3. Security Setup

- [ ] **Change Admin Password**
  - Edit: `appsettings.Production.json`
  - Update the password field
  - Use a strong password!

## 🚀 Deployment Steps (Every Time You Update)

### Option A: Automated Deployment (Recommended)

Run PowerShell as **Administrator**:

```powershell
cd "E:\Documents\Website Projects\Sky_Art_Shop"

# First time deployment (creates IIS site)
.\deploy.ps1 -CreateSite

# Future updates (faster, just updates files)
.\deploy.ps1 -UpdateOnly
```

### Option B: Manual Deployment

Run PowerShell as **Administrator**:

```powershell
# 1. Stop IIS site (if updating)
Stop-WebSite -Name "SkyArtShop"

# 2. Publish application
cd "E:\Documents\Website Projects\Sky_Art_Shop"
dotnet publish -c Release -o "C:\inetpub\wwwroot\skyartshop"

# 3. Set permissions
icacls "C:\inetpub\wwwroot\skyartshop" /grant "IIS_IUSRS:(OI)(CI)F" /T
icacls "C:\inetpub\wwwroot\skyartshop\wwwroot\uploads" /grant "IIS_IUSRS:(OI)(CI)F" /T

# 4. Start IIS site
Start-WebSite -Name "SkyArtShop"
```

## ✅ Testing

### Test 1: Local (on server)

- [ ] Open browser on server machine
- [ ] Visit: <http://localhost>
- [ ] ✅ Site loads correctly

### Test 2: Local Network

- [ ] On another device (phone/laptop on same WiFi)
- [ ] Visit: <http://192.168.1.100> (your server's local IP)
- [ ] ✅ Site loads correctly

### Test 3: Internet

- [ ] On mobile data or different network
- [ ] Visit: <http://your-hostname.ddns.net> (your No-IP hostname)
- [ ] ✅ Site loads from internet

## 🔍 Troubleshooting

### Site Not Loading Locally

```powershell
# Check IIS site status
Get-WebSite -Name "SkyArtShop"

# Check if port 80 is listening
netstat -ano | findstr :80

# Restart IIS
iisreset /restart
```

### Site Not Loading from Internet

- [ ] Verify No-IP DUC is running (check system tray)
- [ ] Check router port forwarding is configured
- [ ] Test your public IP: <https://www.whatismyip.com>
- [ ] Visit: http://YOUR_PUBLIC_IP (should show your site)

### MongoDB Connection Error

```powershell
# Check MongoDB status
net start MongoDB

# If not running, start it
net start MongoDB
```

### Permission Errors (403/500)

```powershell
# Re-apply permissions
icacls "C:\inetpub\wwwroot\skyartshop" /grant "IIS_IUSRS:(OI)(CI)F" /T
icacls "C:\inetpub\wwwroot\skyartshop" /grant "IUSR:(OI)(CI)F" /T

# Restart IIS
iisreset /restart
```

## 📊 Quick Commands

```powershell
# Check site status
Get-WebSite -Name "SkyArtShop" | Select Name, State

# Start site
Start-WebSite -Name "SkyArtShop"

# Stop site
Stop-WebSite -Name "SkyArtShop"

# Restart IIS
iisreset /restart

# Check MongoDB
net start MongoDB

# View firewall rules
Get-NetFirewallRule -DisplayName "*SkyArtShop*"

# Check what's using port 80
netstat -ano | findstr :80
```

## 🎯 Your Site URLs

After deployment, your site will be accessible at:

- **Local Machine**: <http://localhost>
- **Local Network**: <http://192.168.1.100> (or your static IP)
- **Internet**: <http://your-hostname.ddns.net> (your No-IP hostname)

## 📝 Notes

- **Development**: Continue using `dotnet run` on port 5001 for local development
- **Production**: Clients access via your No-IP hostname
- **Updates**: Run `.\deploy.ps1 -UpdateOnly` to push changes
- **Backups**: Consider backing up `identity.db` and MongoDB before major updates

## 🎉 Success Criteria

✅ Site loads on localhost  
✅ Site loads on local network  
✅ Site loads from internet via No-IP hostname  
✅ Admin login works  
✅ Images upload correctly  
✅ MongoDB data persists  
✅ No error messages in browser console  

---

**Ready to deploy? Start with the Pre-Deployment Setup, then run the automated deployment script!**
