# 🚀 MotorOS / PBS Autos — Production Hosting & Deployment Guide

This package contains everything needed to run MotorOS / PBS Autos on any web hosting environment.

---

## 📦 Which Zip File Should I Use?

| File | Use Case | Description |
| :--- | :--- | :--- |
| **`motoros-deploy.zip`** *(or `pbs-autos-cpanel-deploy.zip`)* | **cPanel Node.js / VPS / Cloud Hosting** | **Full-Stack Application** (Node.js/Express API + SQLite database + Compiled React Web App). Everything is included and self-hosted. |
| **`frontend-dist.zip`** | **Static Web Hosting Only** | **Frontend Only** (Static HTML, CSS, JS with `.htaccess` SPA router) for Netlify, Vercel, or static shared hosting. |

---

## 🛠️ Method 1: cPanel "Setup Node.js App" (Recommended)

### Step 1: Upload & Extract
1. Log in to your **cPanel**.
2. Open **File Manager** and navigate to your application root or domain folder (e.g. `public_html` or a subfolder like `motoros`).
3. Upload `motoros-deploy.zip` (or `pbs-autos-cpanel-deploy.zip`).
4. Right-click the zip file and click **Extract**.

### Step 2: Configure Node.js in cPanel
1. In cPanel, find and click **"Setup Node.js App"**.
2. Click **Create Application**:
   - **Node.js Version**: Select **20.x LTS** (or 18.x / 22.x).
   - **Application Mode**: `Production`.
   - **Application Root**: The directory where your files were extracted (e.g. `motoros` or `public_html`).
   - **Application URL**: Select your domain or subdomain.
   - **Application Startup File**: `app.js`
3. Click **Create**.

### Step 3: Install Production Dependencies
1. In your Node.js application settings page in cPanel, click the **"Run NPM Install"** button.
   > 💡 **Pure WebAssembly Engine Included**: Even if your cPanel host lacks C++ build tools or GLIBC libraries for native `better-sqlite3`, MotorOS automatically falls back to pure WebAssembly SQLite (`sql.js`), guaranteeing 100% zero-configuration database persistence.

### Step 4: Restart & Test
1. Click **"Restart"** in the cPanel Node.js interface.
2. Visit your domain in the browser. You will see PBS Autos live!

---

## 🖥️ Method 2: VPS / Cloud Server (Ubuntu, Debian, PM2)

If hosting on a Linux VPS / Droplet / Dedicated server:

```bash
# 1. Unzip the deployment package
unzip motoros-deploy.zip -d /var/www/motoros
cd /var/www/motoros

# 2. Install production dependencies
npm install --omit=dev

# 3. Start with PM2 (process manager)
npm install -g pm2
pm2 start app.js --name "motoros"
pm2 save
pm2 startup
```

---

## 🔑 Default Bodyshop Login Credentials
All accounts use default password: `password123`

| Role | Name | Email | Default Password |
| :--- | :--- | :--- | :--- |
| **Bodyshop Manager / Admin** | PBS Autos Admin | `admin@pbsautos.co.uk` | `password123` |
| **Customer Intake** | Book In Client | `bookin@pbsautos.co.uk` | `password123` |
| **Sprayer / Refinishing** | Chris | `chris@pbsautos.co.uk` | `password123` |
| **Panel Prep – Bay 1** | Habibi | `habibi@pbsautos.co.uk` | `password123` |
| **Panel Prep – Bay 2** | Paa Jii | `paajii@pbsautos.co.uk` | `password123` |
| **Booking & Bay Allocation** | Ismail | `ismail@pbsautos.co.uk` | `password123` |

---

## ⚙️ Environment Variables (.env)

The deployment package already includes a pre-configured `.env` file:
```env
NODE_ENV=production
PORT=5000
JWT_SECRET=motoros-uk-super-secret-key-2026
```
- You can customize `PORT` or `JWT_SECRET` at any time by editing the `.env` file in File Manager.
