# BCP — Production Deployment Runbook

How code reaches `https://bcp.binduit.com`, established by direct inspection of the production server on 2026-09-08 through cPanel Terminal, plus read-only HTTP probes of the live site.

Everything in section 1 was **read off the server itself**. Everything in section 6 is **not verified** and is labelled as such. Nothing in this document is inferred and then presented as fact.

| Field | Value |
| :--- | :--- |
| Date established | 2026-09-08 |
| Method | cPanel Terminal (read-only commands) + HTTP `GET`/`HEAD` against the live site |
| Companion runbook | `docs/BACKUP_AND_DISASTER_RECOVERY.md` — database backup and restore |
| Related | In the binduhost repository under `docs/`: `PHASE_2A_WEB_HOSTING_STATUS.md`, `PHASE_2B_ORDER_SETTLEMENT_STATUS.md`, `PHASE_2C_CTA_REPOINT_STATUS.md` |

---

## 1. VERIFIED FACTS

Each row was produced by a command run on the production server, or by an HTTP response from it.

### 1.1 How code gets there

| Item | Value | How it was verified |
| :--- | :--- | :--- |
| **Deployment method** | **Direct Git working copy on production.** No CI, no build step, no artifact upload | `.git` directory found inside the application root |
| **Repository** | `https://github.com/mdhasanulislam/bcp.git` | `git remote -v` on the server |
| **Branch** | `feature/saas-billing-api` | `git rev-parse --abbrev-ref HEAD` |
| **Current production commit** | **`685342f`** — *"fix: a deleted SMS order stays deleted in the admin panel"* | `git log -1 --oneline` |
| Last git operation on the server | 2026-09-04 17:03 | mtime of `.git` |
| Working tree state | Clean of real edits. 11 files show as modified — all `.gitignore` files under `storage/` and `bootstrap/cache/` — but the diff is **0 insertions, 0 deletions**, i.e. permission-mode changes only, made by the host | `git status --short`, `git diff --stat` |

> **Production is NOT running `master`.** `master` is at `79ccb88` and lacks the SaaS billing API, `/api/v1/sms/balance`, two-factor authentication and the committed `public/build` assets — all of which the live site serves.

### 1.2 Where it lives

| Item | Value |
| :--- | :--- |
| cPanel account | `binduit` on host `s15175` |
| **Application path** | `/home/binduit/bcp.binduit.com` |
| **Document root** | `/home/binduit/bcp.binduit.com` — **the application root, NOT `public/`** |
| Front controller | `/home/binduit/bcp.binduit.com/public/index.php`, reached by rewrite |
| Web server | LiteSpeed |

The domain's document root is the application root. A `.htaccess` at that root rewrites every request into `public/`:

```apache
RedirectMatch 404 /\..*$
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/public%{REQUEST_URI} -f
RewriteRule ^(.*)$ public/$1 [L]
RewriteRule ^ public/index.php [L]
```

This file is **not tracked by Git**. See safety rule 2.

Confirmed from outside: `/composer.json` → 404, `/artisan` → 404, `/index.php` → 302, `/build/manifest.json` → 200. Every one of those is what the rewrite above produces.

### 1.3 Runtime

| Item | Value |
| :--- | :--- |
| **PHP binary (web + cron)** | `/opt/cpanel/ea-php83/root/usr/bin/php` |
| **PHP version** | **8.3** (Composer reports 8.3.33) |
| **Composer** | `/usr/local/bin/composer`, version **2.9.4** |
| **SSH / cPanel Terminal** | **Available** |
| **`vendor/`** | Present on the server, installed there by Composer. It is gitignored, so it does **not** arrive with a pull |
| Compiled front-end assets | Travel **in the repository** under `public/build`. The host has no Node, so `npm run build` cannot run there — see BCP commit `3f7b4cf` |

⚠️ The account also runs PHP 8.2 for the POS application (`/opt/cpanel/ea-php82/...`). Using a bare `php` risks the wrong version. See safety rule 3.

### 1.4 Scheduled processes

Both confirmed present via `crontab -l`:

```cron
* * * * * /opt/cpanel/ea-php83/root/usr/bin/php /home/binduit/bcp.binduit.com/artisan schedule:run >/dev/null 2>&1
* * * * * /opt/cpanel/ea-php83/root/usr/bin/php /home/binduit/bcp.binduit.com/artisan queue:work --stop-when-empty --max-time=55 >/dev/null 2>&1
```

| Cron | Purpose |
| :--- | :--- |
| `schedule:run`, every minute | Drives `subscriptions:evaluate` (every 5 minutes) and the hourly ShurjoPay reconciliation sweeper |
| `queue:work --stop-when-empty --max-time=55`, every minute | Drains the queue and exits, so no long-lived worker is needed on shared hosting |

The same account also runs POS crons on PHP 8.2 and BinduAI Python workers. **None of those belongs to BCP and none should be touched by a BCP deployment.**

---

## 2. MANDATORY SAFETY RULES

These are not preferences. Each one exists because breaking it causes a specific, known failure.

### 1. NEVER run `git clean`

`git clean -fd` (or `-fdx`) deletes untracked files. On this server that includes the root `.htaccess`, which is what routes the site into `public/`. Removing it takes the site down **and** exposes the `.git` directory to the public web at the same moment.

### 2. Preserve the server-side root `.htaccess`

`/home/binduit/bcp.binduit.com/.htaccess` is untracked and exists only on the server. It is not in any commit, so a fresh clone or any destructive clean will not restore it. **Copy it before any deployment**, and check it is still present afterwards.

### 3. Always use the full PHP 8.3 binary path

```
/opt/cpanel/ea-php83/root/usr/bin/php
```

Never a bare `php`. The account hosts PHP 8.2 for POS, and the shell's default may not be 8.3. Both cron entries use this full path; deployment commands must match, or artisan will run under a different runtime from the one serving the site.

### 4. Do not expose or commit `.env`

`.env` exists only on the server and is in no repository. It holds `APP_KEY`, database credentials and the ShurjoPay credentials. `APP_KEY` decrypts sessions and every encrypted column — losing it loses that data. Never print it, never copy it into a repository, never paste it into a chat or an issue. Back it up into the secret store only.

### 5. Do not run `git pull` casually

A pull changes what production serves. It belongs inside the sequence in section 4, after a backup, and only for a reviewed commit.

### 6. `.git` sits inside the document root

Because the document root is the application root, `.git` is under the web root. It is currently blocked — the root `.htaccess` returns 404 for any dotted path, and the host returns 403 for `/.git/*` — but that protection is configuration, not structure. **BinduHost hit exactly this problem and fixed it in commit `18da3e8`, "Keep the cloned .git directory out of the web root".** Relocating BCP's document root to `<app>/public` is the permanent fix. It is **out of scope for the Phase 2A deployment** and should be planned separately, because changing the document root changes how every request is served.

---

## 3. PHASE 2A — PENDING DEPLOYMENT

| Field | Value |
| :--- | :--- |
| **Status** | **PENDING — not deployed** |
| **Commit** | `57c1f20b86d0bd8cbc60de3ef29a735d0b35a691` |
| Subject | `feat: add BinduHost web hosting plans and pricing` |
| Branch | `feature/saas-billing-api` — already pushed to GitHub |
| Parent | `685342f` — the commit production currently runs |
| Distance | production is **exactly 1 commit behind** |
| Files | 5 changed, 783 insertions(+), 1 deletion(-) |
| **Migrations** | **none** |
| **New Composer dependencies** | **none** — `composer install` is not required for this deployment |
| **New CSS/JS** | none — no asset rebuild required |
| Database write required | yes, one seeder — see section 4 step 5 |

### What it delivers

The four Web Hosting packages the BinduHost homepage advertises, on all three terms: 12 purchasable plans from ৳1,200 to ৳7,200, with 45 feature lines each taken from the homepage price table. The superseded un-termed rows and the development test plan are deactivated, not deleted. Covered by 11 tests and 838 assertions; the full BCP suite is green at 994 passed, 1 skipped, 5,053 assertions.

**No renewal price, rule or field is written anywhere.** Renewal pricing policy remains undecided and this commit does not decide it.

---

## 4. DEPLOYMENT SEQUENCE

**Not yet executed.** Written out so it can be reviewed before it is.

```bash
APP=/home/binduit/bcp.binduit.com
PHP=/opt/cpanel/ea-php83/root/usr/bin/php
```

**Step 1 — back up.** Database dump per `docs/BACKUP_AND_DISASTER_RECOVERY.md`, plus a copy of the server's `.env` and of the untracked root `.htaccess`. Record the current commit `685342f` — that is the rollback target.

**Step 2 — confirm the working tree is still clean.**
`git -C "$APP" status --short` should show only the 11 permission-mode `.gitignore` entries and the untracked `.htaccess`.

**Step 3 — pull.**
`git -C "$APP" pull origin feature/saas-billing-api` — moves `685342f` → `57c1f20`, five files. **No `git clean`, no `git reset`, no `checkout`.**

**Step 4 — rebuild caches.**
`$PHP "$APP"/artisan config:clear`, then `config:cache`, `route:cache`, `view:cache`.
Route and view caches matter: stale caches serve the old term label and, after later phases, routes that no longer exist.

**Step 5 — seed the catalogue.**
`$PHP "$APP"/artisan db:seed --class=WebHostingPlanSeeder --force`
Idempotent — `updateOrCreate` on natural keys, and it deletes nothing.

**Step 6 — verify.** Sign in to `/portal/binduhost/shop` and confirm 12 plans, the correct prices, and term labels reading `/ year`, `/ 2 years`, `/ 3 years`. Confirm `Portal Test Monthly` is absent. Confirm `.htaccess` is still present and the site still loads.

> ⚠️ **Production plan IDs will differ from the local development IDs 12–23.** Never carry local IDs into a production instruction or link.

---

## 5. PHASE 2A ROLLBACK

Phase 2A adds no migration, so there is nothing to `migrate:rollback`. Rollback has two independent halves and the code half is enough to undo the visible change.

**Code — return to `685342f`:**

```bash
git -C "$APP" checkout 685342f    # or: git -C "$APP" reset --hard 685342f
$PHP "$APP"/artisan config:clear && $PHP "$APP"/artisan config:cache
$PHP "$APP"/artisan route:cache && $PHP "$APP"/artisan view:cache
```

Then confirm the root `.htaccess` still exists. **Do not follow either command with `git clean`.**

A stale route or view cache after a code rollback serves the wrong thing, so the cache rebuild is part of the rollback, not an optional extra.

**Database — reverse at data level, never by deleting:**

- Set `is_active = false` on the 12 Web Hosting plans, and `true` on whatever was active before.
- **Do not delete any plan row.** An order line or a subscription may already reference one, and deleting it breaks that history.
- If the seeder ran and no order was placed against a new plan, deactivating the 12 rows is a complete reversal.
- The seeder also deactivated `portal-test-monthly` and the un-termed rows. Reactivate those only if the previous catalogue is genuinely wanted back; leaving a test plan deactivated is correct in every case.

**Full disaster recovery** — restoring the database itself — follows `docs/BACKUP_AND_DISASTER_RECOVERY.md`: restore to a **new** database, never over `bcp_control_panel`.

---

## 6. NOT VERIFIED — assumptions and open questions

Listed so nothing in section 1 is diluted by something that was merely inferred.

| # | Item | Status |
| :--- | :--- | :--- |
| U1 | **Whether cPanel's Git™ Version Control UI manages this clone** | **UNKNOWN.** A `.git` working copy exists with the correct remote, but the cPanel Git screen itself was never opened. The clone may have been created manually over SSH. This matters only for *how* you trigger a pull, not for whether one works |
| U2 | **How the server authenticates to GitHub** | **UNKNOWN.** The remote is HTTPS. A pull succeeded on 2026-09-04, so either the repository is public or a credential helper / token is stored on the server. If the repository is private and the credential has since expired, step 3 will prompt or fail. **Check this before the deployment window, not during it** |
| U3 | **Whether database backups are actually running** | **UNKNOWN.** `docs/BACKUP_AND_DISASTER_RECOVERY.md` describes a four-hourly encrypted dump against managed PostgreSQL with a secret manager and `verify-full` TLS. Whether any of that infrastructure matches this cPanel host, and whether the schedule runs, was never confirmed. **Treat step 1 as a manual backup you must perform, not one you can assume exists** |
| U4 | **The document root as cPanel records it** | Established from the root `.htaccess` and five matching HTTP responses, all consistent. The cPanel **Domains** screen was never read, so the field value itself is unconfirmed |
| U5 | **`SURJOPAY_ENABLED` in production** | **NOT READ**, deliberately. Payment configuration is not inspected or changed without an explicit instruction |
| U6 | **Deployment history before 2026-09-04** | **UNKNOWN.** No deployment log, script or record exists in the repository — this runbook is the first written record of the method |
| U7 | **What modified the 11 `.gitignore` permissions** | **UNKNOWN.** Harmless — the content diff is empty — but the cause was not traced |

### Assumption to retire

Nothing in this repository described the deployment method before this document. Any earlier statement that BCP deploys the way BinduHost does is **wrong**: BinduHost builds in GitHub Actions and publishes a static export to a `deploy` branch that cPanel Git pulls into `public_html`. **BCP has no workflow, no `deploy` branch and no build step** — it is a plain server-side clone of a feature branch.

---

## PRODUCTION STATE AT TIME OF WRITING

```
production   685342f   feature/saas-billing-api      ← running
GitHub       57c1f20   feature/saas-billing-api      ← Phase 2A, pushed, NOT deployed
master       79ccb88                                 ← 17 commits behind, not used in production
```

**Nothing has been deployed. No production file, database, `.env`, cron or service has been changed.**
