# TechHeck Admin — Namecheap

Admin is a **separate** Node.js app from the static marketing site.

## Recommended production URL

- App: `https://admin.techheck.co` (subdomain → cPanel Node app)
- UI path: `/Admin` via `BASE_PATH=/Admin` → `https://admin.techheck.co/Admin`
- Health: `https://admin.techheck.co/health` (also accepts `/Admin/health`)
- Public settings: `https://admin.techheck.co/Admin/api/public/settings`

## One-time setup

1. Create subdomain `admin.techheck.co` pointing at the Node app root, e.g. FTP folder `techheck-admin/`.
2. Do **not** upload `.env` by hand into git — set variables in cPanel.
3. cPanel → **Setup Node.js App**:
   - Node 20+ (22 preferred when available)
   - Application root: `techheck-admin` (match `PRODUCTION_ADMIN_ROOT`)
   - Application URL: `admin.techheck.co`
   - Startup file: `server.js`
4. Environment variables:

| Name | Value |
| --- | --- |
| `NODE_ENV` | `production` |
| `BASE_PATH` | `/Admin` |
| `SEED_ADMIN_USERNAME` | First owner username (only when `admin_users` is empty) |
| `SEED_ADMIN_PASSWORD` | First owner password |
| `DB_HOST` / `DB_PORT` / `DB_USER` / `DB_PASSWORD` / `DB_NAME` | Same MariaDB as the TechHeck API |
| `ALLOWED_ORIGINS` | `https://techheck.co,https://www.techheck.co` |
| `SESSION_SECRET` | Long random string |
| `GA4_PROPERTY_ID` | Optional |

5. **Run NPM Install** → **Restart**.
6. Open `https://admin.techheck.co/health` → `{"ok":true,...,"database":"connected"}`.
7. Add GitHub `production` secrets from `docs/deployment.md`, then merge/push `main` (or **workflow_dispatch**).

## Ongoing deploys

Push to `main` in `amirchaudhary7722/techheck-admin`. GitHub Actions FTPs the app (no `.env`, no `node_modules`). Restart the Node app in cPanel if health still looks stale.

## Marketing site

```env
NEXT_PUBLIC_ADMIN_API_URL=https://admin.techheck.co/Admin
```

Redeploy the **techheck** site after setting that so the footer can refresh public settings.
