# SulejaMarket — cPanel Deployment Guide

Comprehensive step-by-step guide to deploying SulejaMarket to your **cPanel** web hosting environment with PHP, MySQL, and the Gamified Vendor Loyalty & In-App Notification System.

---

## 📋 System Requirements

* **cPanel** Web Hosting (Apache or LiteSpeed Web Server)
* **PHP**: 7.4, 8.0, 8.1, 8.2, or 8.3 (with `pdo` & `pdo_mysql` extensions enabled)
* **Database**: MySQL 5.7+ or MariaDB 10.3+

---

## 🚀 Step-by-Step Deployment Instructions

### 1️⃣ Step 1: Create a MySQL Database in cPanel

1. Log into your **cPanel Dashboard**.
2. Under the **Databases** section, click **MySQL® Database Wizard**.
3. **Create a Database Name**: Enter a name (e.g. `sulejamarkets`) and click *Next Step*. (Full name will look like `username_sulejamarkets`).
4. **Create a Database User**: Enter a username (e.g. `suleja_user`) and a strong password. Click *Create User*.
5. **Set Privileges**: Check the box for **ALL PRIVILEGES** and click *Make Changes*.
6. 📝 *Save your Database Name, Username, and Password for Step 3.*

---

### 2️⃣ Step 2: Upload & Extract Zip Package in File Manager

1. In cPanel, navigate to **File Manager** (under Files section).
2. Go to your web root folder:
   * Main domain: `public_html/`
   * Subdomain or Addon Domain: `public_html/yoursubdomain/`
3. Click **Upload** in the top menu bar.
4. Select `sulejamarkets_cpanel.zip` from your computer and wait for the upload bar to reach **100% (Green)**.
5. Return to File Manager, select `sulejamarkets_cpanel.zip`, and click **Extract** in the top toolbar (or right-click -> Extract).

---

### 3️⃣ Step 3: Configure Database Connection (`api/db.php`)

1. In File Manager, navigate into the **`api/`** folder.
2. Right-click **`db.php`** and select **Edit**.
3. Update lines 11–14 with your cPanel database details:

```php
$host = '127.0.0.1'; // or 'localhost'
$db   = 'username_sulejamarkets'; // Your full database name from Step 1
$user = 'username_suleja_user';   // Your full database username from Step 1
$pass = 'YOUR_DB_PASSWORD';        // Your database password
```

4. Click **Save Changes** at the top right.

---

### 4️⃣ Step 4: Run Auto-Database Setup & Table Creation

1. Open your web browser and navigate to:
   ```
   https://yourdomain.com/api/setup.php
   ```
   *(Replace `yourdomain.com` with your actual domain or subdomain name).*

2. You should see the green confirmation message:
   > **Database initialized successfully! Go to App**

3. 🎉 `setup.php` automatically creates all required tables:
   * `vendors` (with `wallet_balance`, `loyalty_coins`, `is_verified`)
   * `products` (with `is_featured`, `is_top`, `is_flash`)
   * `orders`, `order_items`, `order_history`
   * `withdrawals`
   * `reviews`
   * `loyalty_transactions`
   * `notifications`
   * `top_banners`, `hero_banners`
   * Initial seed products & admin account.

---

### 5️⃣ Step 5: Test Key Features

1. **Storefront**: Visit `https://yourdomain.com/` to browse categories, flash sales, top sellers, and featured vendor items.
2. **In-App Notifications**: Click the **Bell Icon** in the top navigation header to view real-time notifications.
3. **Vendor Loyalty Hub**: Visit `https://yourdomain.com/vendor` to view vendor profiles, wallet payouts, and the **🪙 Loyalty Coins Hub**.
4. **Delivered Order Reward**: When an order is marked as `Delivered` in `/admin` or vendor dispatch control:
   * The vendor wallet balance receives sales funds.
   * **100 Loyalty Coins** are credited to the vendor.
   * Buyers & Sellers receive in-app notifications.
5. **Product Featuring**: Vendors can spend 100 Loyalty Coins to feature items with a **✨ Featured** badge across the marketplace!

---

## 🛠️ Troubleshooting & Notes

* **CORS / API Routing Errors**: The included `.htaccess` file handles route rewrites and PHP execution automatically.
* **PHP File Upload Limits**: Upload limits are pre-configured in `.htaccess` (`64M` max upload size).
* **Default Admin Login**:
  * Username: `admin`
  * Password: `heropass1234`

Enjoy selling on SulejaMarket! 🚀
