# BNKFX — cPanel & Shared Hosting Deployment Guide

This guide details how to deploy the BNKFX Online Banking Platform on cPanel shared hosting or VPS environments.

---

## 1. Hosting & Server Requirements

- **PHP Version**: PHP 8.2 or newer (PHP 8.2 or 8.3 recommended)
- **Database**: MySQL 8.0+ or MariaDB 10.5+
- **PHP Extensions**:
  - `pdo` and `pdo_mysql`
  - `bcmath` (required for decimal-safe monetary calculations)
  - `mbstring`
  - `openssl`
  - `json`
  - `curl`

---

## 2. Directory Separation (Security Best Practice)

To prevent unauthorized public access to sensitive `.env` files, configuration, and internal logic, organize your files as follows:

```
/home/yourusername/
├── bnkfx_app/              <-- Core private application files
│   ├── app/
│   ├── database/
│   ├── storage/
│   ├── .env
│   └── composer.json
└── public_html/            <-- Document root (only public assets)
    ├── assets/
    ├── index.php
    └── .htaccess
```

### Steps:
1. Upload the entire project into a private directory outside `public_html`, such as `/home/yourusername/bnkfx_app/`.
2. Move the contents of `bnkfx_app/public/` directly into your web root (`public_html/`).
3. In `public_html/index.php`, update the relative path to point to the core autoloader:
   ```php
   require_once __DIR__ . '/../bnkfx_app/app/Core/Autoloader.php';
   \App\Core\Autoloader::register();
   require_once __DIR__ . '/../bnkfx_app/app/Core/helpers.php';
   ```

---

## 3. Database Setup via cPanel

1. Log into your cPanel dashboard.
2. Under **Databases**, click **MySQL Database Wizard**.
3. Create a new database (e.g. `youruser_bnkfx`).
4. Create a database user and assign a strong password.
5. Add the user to the database and select **ALL PRIVILEGES**.
6. Open **phpMyAdmin**, select your newly created database, and click the **Import** tab.
7. Choose and import `database/schema.sql`.
8. Next, choose and import `database/seed.sql` to install initial card products, vault accounts, and demo credentials.

---

## 4. Environment Configuration (`.env`)

Edit your `.env` file via the cPanel File Manager:

```env
APP_ENV=production
APP_DEBUG=false
APP_NAME="Bnkfx Online Banking"
APP_URL=https://yourdomain.com

DB_DRIVER=mysql
DB_HOST=localhost
DB_PORT=3306
DB_NAME=youruser_bnkfx
DB_USER=youruser_dbuser
DB_PASSWORD=YourStrongPasswordHere

CRYPTO_PROVIDER=manual_native
CRYPTO_WEBHOOK_SECRET=GenerateStrong32CharSecretKeyHere
SESSION_SECURE_COOKIE=true
```

---

## 5. SSL / HTTPS Enforcement

Under cPanel **Security**, ensure **SSL/TLS Status** has an active Let's Encrypt or AutoSSL certificate.
The included `.htaccess` file will automatically enforce URL routing and HTTPS redirection.

---

## 6. Cron Job Setup (Optional Background Workers)

To periodically check blockchain confirmations or perform automated nightly ledger reconciliation audits, add a cron job in cPanel:

```bash
# Run every 5 minutes
*/5 * * * * php -q /home/yourusername/bnkfx_app/database/migrate.php >/dev/null 2>&1
```
