# ⚡ Quick Deployment Steps
## jmtree.wundanyimbale.co.ke

---

## **Step 1: Prepare Your Hosting** (5 min)
```
1. Log in to cPanel
2. Go to: Addon Domains OR Subdomains
3. Create: jmtree.wundanyimbale.co.ke → /public_html/jmtree
4. Wait 5-10 minutes for DNS
```

---

## **Step 2: Upload Files** (5 min)

### Option A: FTP (Easiest)
```
1. Download FileZilla or WinSCP
2. Connect with your cPanel FTP credentials
3. Upload folder contents to: /public_html/jmtree
4. Skip: .git/ venv/ __pycache__ *.pyc .env
5. Upload .env separately (see Step 5)
```

### Option B: cPanel File Manager
```
1. cPanel → File Manager
2. Navigate to /public_html/jmtree
3. Upload zip of project (extract after)
```

---

## **Step 3: Setup Python** (10 min)

In cPanel Terminal:

```bash
cd /public_html/jmtree

# Create virtual environment
python3 -m venv venv

# Activate
source venv/bin/activate

# Install packages
pip install -r requirements.txt

# Run migrations
python manage.py migrate

# Collect static files
python manage.py collectstatic --noinput

# Create admin user
python manage.py createsuperuser
# Follow prompts: username, email, password
```

---

## **Step 4: Configure Web Server** (10 min)

### Create `/public_html/jmtree/.htaccess`:

```apache
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ app.wsgi/$1 [QSA,L]
</IfModule>
```

### Create `/public_html/jmtree/app.wsgi`:

```python
import sys
import os
sys.path.insert(0, '/home/USERNAME/public_html/jmtree')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'treetracker.settings')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
```

Replace `USERNAME` with your cPanel username!

---

## **Step 5: Create .env File** (2 min)

Upload to: `/public_html/jmtree/.env`

```env
SECRET_KEY=generate-a-random-key-here-use-32-chars
DEBUG=False
RESEND_API_KEY=re_gNgQLTZA_NxLkr6XYgngMQp4KgQw3Y4G5
```

---

## **Step 6: Enable HTTPS** (5 min)

```
1. cPanel → AutoSSL
2. Click: "Check & Install"
3. Wait 5 minutes
4. Test: https://jmtree.wundanyimbale.co.ke
```

---

## **Step 7: Test Website** (2 min)

✅ Visit:
- `https://jmtree.wundanyimbale.co.ke` → Should show Welcome page with logo
- `https://jmtree.wundanyimbale.co.ke/admin` → Sign in with superuser

✅ Test Email OTP:
- Click "Get Started"
- Enter test email
- Should receive OTP email within 30 seconds

---

## **Step 8: Enable Python App in cPanel** (5 min)

```
1. cPanel → Python Apps (or Setup Python App)
2. Click: Create Python App
3. Settings:
   - Python Version: 3.9+ (highest available)
   - App Root: /public_html/jmtree
   - Startup Script: app.wsgi
   - Interpreter: Select venv python
4. Click: Deploy
```

---

## **Done!** 🎉

Your JM3 is now live at: **https://jmtree.wundanyimbale.co.ke**

**Next Steps:**
- Test account creation (try the full onboarding flow)
- Add test data
- Monitor error logs: `/home/USERNAME/public_html/jmtree/error.log`

---

## 🚨 Common Issues

### 404 on /static/ files?
```bash
python manage.py collectstatic --noinput --clear
```

### 500 Error?
```bash
# Check error log
tail -50 /home/USERNAME/public_html/jmtree/error.log
```

### Email not sending?
- Verify RESEND_API_KEY in .env
- Test in admin panel → try sending test email

### Can't find USERNAME?
```bash
# In cPanel terminal:
whoami
# This shows your username
```

---

**Support:** Check full guide in `DEPLOYMENT.md`
