# StewardGrid — GoDaddy Deployment Guide

## 📋 Pre-Deployment Checklist

- [ ] GoDaddy hosting plan with PHP 8.0+ and MySQL
- [ ] SSH/FTP access to your hosting
- [ ] cPanel or similar control panel access
- [ ] Domain: stewardgrid.alphagrdsys.com

---

## 🚀 Step 1: Create MySQL Database on GoDaddy

1. Log in to GoDaddy → **My Products** → **Web Hosting** → **Manage**
2. Open **cPanel** → **MySQL Databases**
3. Create a new database: `stewardgrid`
4. Create a database user with a **strong password**
5. Add the user to the database with **ALL PRIVILEGES**

**Save these details:**
```
Database Host: localhost (usually)
Database Name: yourusername_stewardgrid
Database User: yourusername_stewardgriduser
Database Password: your_chosen_password
```

---

## 🚀 Step 2: Upload Files

### Option A: Using cPanel File Manager
1. Open **cPanel** → **File Manager**
2. Navigate to `public_html`
3. Upload the `stewardgrid-deployment.zip` file
4. Right-click the ZIP → **Extract** → Extract to `public_html/`

### Option B: Using FTP (FileZilla)
1. Connect to your GoDaddy server via FTP
2. Navigate to `public_html`
3. Upload the `stewardgrid-deployment.zip`
4. Extract the ZIP on the server

### Option C: Using SSH (if available)
```bash
cd ~/public_html
# Upload the ZIP via SCP
scp /path/to/stewardgrid-deployment.zip username@server:~/public_html/
# Extract
unzip stewardgrid-deployment.zip
```

---

## 🚀 Step 3: Configure Environment

1. Open the uploaded folder structure
2. Edit the `.env` file with your production settings:

```ini
# Application
APP_NAME=StewardGrid
APP_ENV=production
APP_DEBUG=false
APP_URL=https://stewardgrid.alphagrdsys.com
APP_KEY=your-generated-key-here

# Database
DB_HOST=localhost
DB_NAME=yourusername_stewardgrid
DB_USER=yourusername_stewardgriduser
DB_PASSWORD=your_database_password

# Encryption Key (generate: php -r "echo bin2hex(random_bytes(32));")
ENCRYPTION_KEY=your-generated-encryption-key

# Mail Settings
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@stewardgrid.alphagrdsys.com
MAIL_FROM_NAME=StewardGrid
```

**Generate APP_KEY:**
```bash
php -r "echo bin2hex(random_bytes(32));"
```

**Generate ENCRYPTION_KEY:**
```bash
php -r "echo bin2hex(random_bytes(32));"
```

---

## 🚀 Step 4: Import Database

### Option A: Using phpMyAdmin (cPanel)
1. Open **cPanel** → **phpMyAdmin**
2. Select your `stewardgrid` database
3. Click **Import** tab
4. Choose `database/stewardgrid_full.sql`
5. Click **Go** to import

### Option B: Using SSH
```bash
mysql -u username_stewardgrid -p stewardgrid < ~/public_html/stewardgrid/database/stewardgrid_full.sql
```

---

## 🚀 Step 5: Set Directory Permissions

Via cPanel File Manager or SSH:
```bash
chmod -R 755 public_html/stewardgrid/public/uploads
chmod -R 755 public_html/stewardgrid/public/storage
chmod -R 755 public_html/stewardgrid/storage
chmod 644 public_html/stewardgrid/.env
```

---

## 🚀 Step 6: Configure Document Root

**Option A: Point to public folder**
- In GoDaddy cPanel → **Addon Domains** or **Subdomains**
- Set the document root to `public_html/stewardgrid/public`

**Option B: Use .htaccess**
Create `.htaccess` in `public_html/stewardgrid/`:
```apache
RewriteEngine On
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
```

---

## 🚀 Step 7: Test the Application

1. Visit: `https://stewardgrid.alphagrdsys.com`
2. You should see the landing page
3. Test superadmin login: `http://stewardgrid.alphagrdsys.com/auth/login`
4. Test tenant login: `http://stewardgrid.alphagrdsys.com/bezalel-temple/login`
5. Test mobile app: `http://stewardgrid.alphagrdsys.com/app/`

---

## 🚀 Step 8: Update Mobile App

Once the server is live:
1. The APK will automatically connect to `https://stewardgrid.alphagrdsys.com`
2. Users can select "Production Server" on the setup screen
3. Or the app defaults to the production URL

---

## 📁 File Structure After Upload

```
public_html/
└── stewardgrid/          (or wherever you extract)
    ├── .env              ← YOUR CONFIGURATION
    ├── app/              ← PHP application code
    ├── config/           ← Configuration files
    ├── database/         ← SQL dump
    ├── public/           ← Web root (point your domain here)
    │   ├── index.php     ← Entry point
    │   ├── app/          ← Flutter web build (mobile app)
    │   ├── uploads/      ← Uploaded files
    │   └── ...
    ├── resources/        ← Views/templates
    ├── routes/           ← Route definitions
    ├── storage/          ← Application storage
    └── vendor/           ← PHP dependencies
```

---

## 🔧 Troubleshooting

### "500 Internal Server Error"
- Check `.env` file has correct database credentials
- Ensure `storage/` and `public/uploads/` are writable
- Check PHP error log in cPanel

### "Database connection failed"
- Verify DB_HOST, DB_NAME, DB_USER, DB_PASSWORD in `.env`
- Make sure the database user has ALL PRIVILEGES

### "Blank page"
- Set `APP_DEBUG=true` temporarily to see errors
- Check PHP version is 8.0+

### "Assets not loading"
- Verify the document root points to the `public/` folder
- Check `.htaccess` is working (Apache mod_rewrite enabled)

### Mobile app shows "Network error"
- Ensure HTTPS is working on the domain
- Check that API routes are accessible: `https://stewardgrid.alphagrdsys.com/api/mobile/platform-logo`

---

## 🔐 Post-Deployment Security

1. Set `APP_DEBUG=false` in `.env`
2. Use strong database passwords
3. Enable SSL/HTTPS (GoDaddy provides free SSL)
4. Remove `repopulate_bezalel.php` and `setup-db.sql` from production
5. Set proper file permissions (644 for files, 755 for directories)

---

## 📞 Developer Support

**Alpha Irresistible Solutions**
- Tel: 0553002745 / 0549940124
- Email: alpha@alphagrdsys.com
