# cPanel deployment for crm.microcode.email

Target subdomain: `crm.microcode.email`

Target folder: `public_html/crm.microcode.email`

This project is a Node/Express CRM app. The `/admin` CRM needs the Express API and SQLite database, so deploy the complete application folder, not only `server/public`.

## cPanel Node.js setup

1. Open cPanel > Setup Node.js App.
2. Select Node.js 20 or newer.
3. Create or edit the application for `crm.microcode.email`.
4. Set application root to the folder that contains this project.
5. Set startup file to `server/server.js`.
6. Run `npm install --omit=dev`.
7. Run `npm run preflight:production`.
8. Run `npm run verify:production` before restart if rebuilding on the server.
9. Restart the Node.js app.

## Environment values

Set these values for the cPanel Node.js app:

```env
NODE_ENV=production
APP_URL=https://crm.microcode.email
CLIENT_ORIGIN=https://crm.microcode.email
DATABASE_PATH=server/db/office365.sqlite
SESSION_SECRET=<keep-current-live-secret-or-generate-long-random-value>
SMTP_ENCRYPTION_KEY=<keep-current-live-secret-or-generate-long-random-value>
PASSWORD_RESET_SECRET=<keep-current-live-secret-or-generate-long-random-value>
```

Keep the existing SMTP and admin settings from the live CRM if this is replacing an existing deployment.

## Release verification

Before uploading or switching the app root, run:

```bash
npm run preflight:production
npm run verify:production
npm run release:checksum
```

The preflight command confirms runtime versions and required release files are present. The verifier runs the Node test suite and then builds the React frontend into `server/public`. The checksum command verifies the latest release archive against its matching `.sha256` file without rebuilding. Keep the generated `.handoff.md` note beside the archive for deployment records.

Do not upload local SQLite WAL/SHM files, old patch ZIP archives, or `.env` from a different environment. Keep the live database and live secrets backed up before replacing code.

Use `RELEASE_CHECKLIST.md` as the final pre-release checklist.

After restart, verify:

```bash
curl -fsS https://crm.microcode.email/api/health
```

The response should include `"ok":true`, `"frontendReady":true`, and `"databaseReady":true`.

## Public site behavior

The public website displays the configured CRM/site content. The protected CRM functionality remains inside `/admin`.
