# ExpertAims (EAC) — AimsHub CMS · Deployment Guide

Target: **https://clients.expertaims.in/eac/** on the `expertaims.in` cPanel.
The CMS is the same engine that already runs `…/ntppa`, forked for EAC. All
11 pages are pre-loaded as editable, enable/disable-able, reorderable sections.

> **Security first — do these before anything else**
> 1. **Rotate the cPanel password.** It was shared in plain text, so treat it as
>    compromised: cPanel → *Password & Security* → change it now.
> 2. The steps below need cPanel/database login. **I can't (and shouldn't) log in
>    on your behalf** — you run the authenticated steps; everything else is built
>    and ready in this folder.

---

## What's in this folder

```
eac-cms/
  index.php            front controller (routing, form capture, HQ status API)
  app/                 engine: bootstrap, db, env, helpers, icons, render, config.sample
  admin/               AimsHub admin panel (setup, login/reset, dashboard)
  assets/              the approved EAC theme (site.css, site.js, cms-forms.js, brand/, img/)
  database/schema.sql  tables + EAC seed (settings, 11 pages, 44 sections)
  .env.example         copy to .env and fill in (DB creds + APP_KEY)
  .htaccess            routing for the /eac subfolder (+ security headers)
  DEPLOY.md            this file
```

---

## Step 1 — Create the database (cPanel → MySQL® Databases)

1. **Create database:** `expertin_eac`
2. **Create user:** `expertin_eac` with a **strong new password** (save it for Step 3).
3. **Add the user to the database** with **ALL PRIVILEGES**.

*(cPanel prefixes with your account name, so the real names may look like
`expertin_eac`. Use whatever cPanel shows — put those exact values in `.env`.)*

## Step 2 — Import the schema + content (cPanel → phpMyAdmin)

1. Select the `expertin_eac` database.
2. **Import** tab → choose `database/schema.sql` → **Go**.
3. You should see `users`, `pages` (11 rows), `sections` (44 rows), `settings`, etc.

## Step 3 — Upload the files

1. cPanel → **File Manager** → go to the docroot for `clients.expertaims.in`
   (usually `public_html/clients/` or the subdomain's docroot).
2. Create the folder **`eac`** and upload everything from this `eac-cms/` folder
   **into** it (so the app lives at `…/eac/index.php`).
   - Upload the ZIP and **Extract** in place (fastest), then delete the ZIP.
   - `.htaccess`, `.env.example` and dotfiles must come across too — in File
     Manager enable *Settings → Show Hidden Files* before uploading.

## Step 4 — Configure secrets (`.env`)

1. In `…/eac/`, copy **`.env.example`** to **`.env`**.
2. Edit `.env`:
   ```
   DB_HOST=localhost
   DB_NAME=expertin_eac          # exact name from Step 1
   DB_USER=expertin_eac          # exact user from Step 1
   DB_PASS=your-new-db-password  # from Step 1
   BASE_URL=/eac
   SITE_URL=https://clients.expertaims.in/eac
   APP_KEY=                      # paste a long random string (see Step 6)
   ```
3. Leave `ADMIN_RESET_KEY` blank — setup writes one for you.
4. Confirm `.htaccess` has `RewriteBase /eac/` (it does). If the subdomain's
   docroot **is** the `/eac` folder itself (not a subfolder), change both the
   `RewriteBase` to `/` and `.env`'s `BASE_URL` to empty.

## Step 5 — Create the first admin user

1. Visit **https://clients.expertaims.in/eac/admin/setup.php**
2. Enter your name, email and a strong password → **Create admin**.
3. It shows an `ADMIN_RESET_KEY` **once** — copy it into `.env` (and keep a copy).
4. Log in at **/eac/admin/**. Delete `admin/setup.php` afterwards (optional; it
   self-locks once a user exists).

## Step 6 — Link to AimsHub HQ Mission Control

The site exposes a signed status endpoint HQ polls:
`GET /eac/?api=status` (and `&scope=analytics`), authenticated by
`X-HQ-Token: hmac_sha256("hq-status", APP_KEY)`.

1. Generate a random `APP_KEY` and the matching HQ token. On any machine with
   PHP, or in cPanel's **Terminal**:
   ```bash
   php -r '$k=bin2hex(random_bytes(24)); echo "APP_KEY=$k\nHQ_TOKEN=".hash_hmac("sha256","hq-status",$k)."\n";'
   ```
   (No PHP handy? Any 32+ char random string works as `APP_KEY`; compute the
   token later.)
2. Put `APP_KEY=…` in `/eac/.env`.
3. In the **HQ fleet dashboard**, add a site:
   - **Name:** ExpertAims (EAC)
   - **Status URL:** `https://clients.expertaims.in/eac/?api=status`
   - **Token:** the `HQ_TOKEN` from step 1
4. Verify: `curl -H "X-HQ-Token: <HQ_TOKEN>" "https://clients.expertaims.in/eac/?api=status"`
   returns JSON (`ok:true`, page/section counts, unread enquiries). A wrong/empty
   token returns `403` — that's correct.

## Step 7 — Smoke test

- Open **/eac/** → homepage renders with the hero slider, all bands, footer.
- Click through Services, Projects, About, Clients, Innovation (atlas),
  News, Careers, Companies, Products, Contact.
- **Contact page:** submit the form → you should see the “thank you” state, and
  the enquiry appears in **admin → Enquiries** (and the HQ unread count ticks up).
  With JS off it still falls back to opening the mail client.
- In **admin → Pages → (any page) → Sections**, toggle a section's visibility and
  reorder — confirm the live page reflects it.

---

## Editing model (what the client can do)

- **Every page** is in *admin → Pages*. **Every band** on every page is a
  *Section* you can **enable/disable, reorder, edit, add or delete**.
- Sections carry the approved markup, so edits are safe HTML blocks. Global bits
  (phones, WhatsApp, email, addresses, social, site name) live in **Settings**
  and update the header/footer across all pages at once.
- **Header nav, mega-menus and footer** are fixed site chrome (not per-page
  sections) — change contact details in Settings; structural nav changes are code.

## Known follow-ups (optional enhancements)

- **Field-by-field editors** for the repeatable sets (hero **slides**,
  **certifications**, **case files**) — today those are edited as whole HTML
  blocks. Add dedicated section types if you want per-item add/remove in the UI.
- **Careers “Apply”** form still uses the mail-client flow (to
  `careers@expertaims.com`). Wiring it into the CMS *Applications* inbox (with CV
  upload) is a small addition best tested against the live server.

---

*Build note: this CMS was assembled and validated by inspection; there is no PHP
runtime on the build machine, so its first live execution is Step 5–7 above. If
`setup.php` or a page errors, it's almost always a `.env` value (DB name/user/pass
or BASE_URL) — fix and reload.*
