# Bluehost cPanel / Passenger Deployment

This project is prepared for Bluehost's Node.js hosting through cPanel Application Manager.

## Production runtime

- Install dependencies with `npm install`
- Build with `npm run build`
- Start with `npm start`
- Recommended startup file in Application Manager: `server.js`
- Compatibility startup file: `app.js`

`server.js` runs the Next.js production server on `process.env.PORT` and `process.env.HOSTNAME`, which is compatible with Passenger-style Node hosting.

## Environment variables

Required database configuration:

```bash
DB_HOST=your-postgres-host
DB_PORT=5432
DB_NAME=your_database_name
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_SSL=false
```

Or use a single connection string instead:

```bash
DATABASE_URL=postgres://user:password@host:5432/database
DB_SSL=false
```

Google Places:

```bash
GOOGLE_PLACES_API_KEY=your_key_here
```

Optional runtime overrides:

```bash
HOSTNAME=0.0.0.0
COOKIE_SECURE=
```

Do not set `PORT` manually in cPanel unless Bluehost specifically requires it. Passenger normally injects it.

## What to upload

Upload the application source from this `app/` directory.

Do upload:

- `src/`
- `postgres/`
- `scripts/`
- `package.json`
- `package-lock.json`
- `next.config.js`
- `server.js`
- `app.js`
- `middleware.ts`
- `tailwind.config.js`
- `postcss.config.js`
- `tsconfig.json`
- `.env.example`

Do not upload:

- `node_modules/`
- `.next/` if Bluehost will run `npm install` and `npm run build` on the server
- `.env.local`
- `.local-postgres/`
- `.DS_Store`
- `tsconfig.tsbuildinfo`

If you cannot run a build on Bluehost, then `.next/` must be uploaded from a local production build as a fallback.

## What must exist after build

After a successful production build, these must exist:

- `.next/BUILD_ID`
- `.next/server/`
- `.next/static/`

The runtime also requires:

- `server.js`
- `package.json`
- installed Node dependencies

## cPanel Application Manager

Recommended settings:

- Node.js version: `20.x` if available, otherwise a version compatible with `>=18.17`
- Application mode: `Production`
- Application root: the directory that contains this project's `package.json`
- Application URL: `gm.mspacez.com/`
- Startup file: `server.js`

After uploading new code:

1. Click `Ensure Dependencies`
2. If your Bluehost plan exposes a terminal, run `npm run build` once if you did not upload a prebuilt `.next/`
3. Restart the application from Application Manager

## Notes

- `postinstall` runs `npm run build`, so a normal `npm install` also prepares the production build.
- The app no longer depends on the local embedded PostgreSQL helper in production installs.
- Google Places failures do not block boot. Missing keys, rejected keys, quota exhaustion, and transient upstream errors degrade acquisition gracefully instead of crashing startup.
