# JM3 Setup Instructions
## For: jmtree.wundanyimbale.co.ke

---

## **STEP 1: Upload Files**

1. Extract `jm3_deploy.zip` to your desktop
2. Use **FileZilla** or **cPanel File Manager**
3. Upload all files to `/public_html/jmtree`
4. Verify upload is complete

---

## **STEP 2: Create .env File**

In `/public_html/jmtree/`, create file `.env` with:

```
SECRET_KEY=your-random-secret-key-change-this-12345
DEBUG=False
RESEND_API_KEY=re_gNgQLTZA_NxLkr6XYgngMQp4KgQw3Y4G5
```

**Get your USERNAME for next step:**
- In cPanel Terminal, run: `whoami`
- Copy the output (your username)

---

## **STEP 3: Edit passenger_wsgi.py**

In `/public_html/jmtree/passenger_wsgi.py`:

Replace `USERNAME` with your actual cPanel username:

```python
sys.path.insert(0, '/home/YOUR_USERNAME/public_html/jmtree')
```

---

## **STEP 4: Create Python App in cPanel**

1. Go to **cPanel → Python Apps** (or Setup Python App)
2. Click **CREATE APPLICATION**
3. Fill in:
   - **Python version:** 3.9.23 (or latest available)
   - **Application root:** `/public_html/jmtree`
   - **Application URL:** `jmtree.wundanyimbale.co.ke`
   - **Application startup file:** `passenger_wsgi.py`
   - **Application Entry point:** `application`
4. Click **CREATE**

---

## **STEP 5: Run Terminal Commands**

1. In cPanel, click **Terminal** (appears after Python app created)
2. Run these commands one by one:

```bash
cd /home/USERNAME/public_html/jmtree

source venv/bin/activate

pip install -r requirements.txt

python manage.py migrate

python manage.py collectstatic --noinput

python manage.py createsuperuser
```

**For createsuperuser:**
- Enter username: `admin`
- Enter email: `admin@jmtree.local`
- Enter password: (your password)
- Confirm password: (same)

---

## **STEP 6: Enable HTTPS**

1. Go to **cPanel → AutoSSL**
2. Click **Check & Install**
3. Wait 5 minutes

---

## **STEP 7: Test Website**

Visit: `https://jmtree.wundanyimbale.co.ke`

You should see:
- JM3 logo ✓
- "Grow. Monitor. Protect." ✓
- Welcome page ✓

---

## **STEP 8: Test Admin**

Visit: `https://jmtree.wundanyimbale.co.ke/admin`

Sign in with:
- Username: `admin`
- Password: (what you created in Step 5)

---

## ✅ **Done!**

Your JM3 is live!

---

## 🚨 **If Something Goes Wrong**

### Error: 500 Internal Server Error
```bash
tail -50 /home/USERNAME/public_html/jmtree/error.log
# Check error message and fix
```

### Error: Static files not loading (404)
```bash
cd /home/USERNAME/public_html/jmtree
source venv/bin/activate
python manage.py collectstatic --noinput --clear
```

### Error: Cannot access /admin
- Make sure you ran `python manage.py createsuperuser`
- Verify username/password are correct

### Email OTP not sending
- Check RESEND_API_KEY in .env is correct
- Visit /admin and test email

---

**Next Step:** Open `https://jmtree.wundanyimbale.co.ke` and test the full onboarding!
