# Production — mortgage.gventure.live

| Item | Value |
|------|--------|
| Public URL | https://mortgage.gventure.live |
| Server repo | `/var/www/html/gventure/mortgage` |
| Next.js app | `/var/www/html/gventure/mortgage/web` (if the full repo is checked out) |
| Node listen | `127.0.0.1:4350` (Apache proxies the domain here) |
| Process | PM2 app `mortgage-nextjs` (`web/ecosystem.config.cjs`) |

## Deploy on the server

```bash
cd /var/www/html/gventure/mortgage
chmod +x web/deploy/deploy.sh
bash web/deploy/deploy.sh
```

If `web/` is not used and `package.json` sits directly in `/var/www/html/gventure/mortgage`, the same script still works.

Put production secrets in `/var/www/html/gventure/mortgage/web/.env`:

```
DATABASE_URL="mysql://root:@127.0.0.1:3306/customer_profiles"
OPENAI_API_KEY=
OPENAI_CHAT_MODEL=gpt-4o-mini
```

Empty password is the blank segment between `root:` and `@` (`mysql://root:@127.0.0.1:3306/...`). Prisma does **not** create the database; MySQL must have schema `customer_profiles` first.

### One-time MySQL (live, root with no password)

```bash
mysql -u root -h 127.0.0.1 --protocol=TCP -e \
  "CREATE DATABASE IF NOT EXISTS customer_profiles CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
```

Or:

```bash
cd /var/www/html/gventure/mortgage/web
mysql -u root -h 127.0.0.1 < deploy/create-database.sql
npx prisma migrate deploy
npx prisma generate
```

Then restart PM2. `deploy.sh` now runs create-database + `prisma migrate deploy` on each deploy.

## Apache

Copy `web/deploy/mortgage.gventure.live.conf` into `sites-available`, enable `proxy` / `ssl`, point certificates at Let’s Encrypt, then reload Apache. The vhost must proxy to **4350**, not 3391.
