# v0.4.1 Core App Option A Setup Guide

This build is for the shared-core deployment where one Node.js app/codebase serves both:

- `pestdemo.recovermissedcall.com`
- `hvacdemo.recovermissedcall.com`

The app resolves the tenant from the request hostname and stores each tenant in its own data folder.

## Folder target

Use one application root, for example:

```text
/home/recoverm/fallback-front-desk-core
```

Inside it, tenant data should live here:

```text
/home/recoverm/fallback-front-desk-core/data/tenants/pestdemo/db.json
/home/recoverm/fallback-front-desk-core/data/tenants/hvacdemo/db.json
```

## Required .env values

Keep your current secrets, then add or confirm:

```env
DEFAULT_TENANT_ID=pestdemo
LEGACY_MIGRATION_TENANT_ID=pestdemo
TENANT_DATA_ROOT=/home/recoverm/fallback-front-desk-core/data/tenants
```

## Tenant mapping

The mapping is stored in `config/tenants.json`:

```json
{
  "tenants": [
    {
      "id": "pestdemo",
      "hostnames": ["pestdemo.recovermissedcall.com"]
    },
    {
      "id": "hvacdemo",
      "hostnames": ["hvacdemo.recovermissedcall.com"]
    }
  ]
}
```

## cPanel routing

Both subdomains must route to the same Node.js application. In Node.js Selector, the shared app should use:

```text
Application root: fallback-front-desk-core
Startup file: app.js
```

Then make sure both `pestdemo` and `hvacdemo` point to the same app/proxy.

## Verification URLs

After restart:

```text
https://pestdemo.recovermissedcall.com/api/health
https://hvacdemo.recovermissedcall.com/api/health
```

Expected:

- Pest URL shows `tenant.id = pestdemo`
- HVAC URL shows `tenant.id = hvacdemo`
- Both show `version = 0.4.1`

## Telnyx tool URLs

Use separate assistant/tool URLs so each demo sends leads to the right hostname:

```text
Pest: https://pestdemo.recovermissedcall.com/api/ai-tools/submit-lead
HVAC: https://hvacdemo.recovermissedcall.com/api/ai-tools/submit-lead
```

The same core app receives both, and hostname routing saves the lead to the correct tenant database.
