> ## Documentation Index
> Fetch the complete documentation index at: https://docs.charlemagnelabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment Variables

> Configuration reference for the Charley API and dashboard

## API (`apps/api/.env`)

### Authentication (Auth0)

| Variable                   | Required | Description                                    |
| -------------------------- | -------- | ---------------------------------------------- |
| `AUTH0_DOMAIN`             | Yes      | Auth0 tenant domain (e.g. `acme.us.auth0.com`) |
| `AUTH0_AUDIENCE`           | Yes      | API identifier configured in Auth0             |
| `AUTH0_MGMT_CLIENT_ID`     | Yes      | M2M client ID for Auth0 Management API         |
| `AUTH0_MGMT_CLIENT_SECRET` | Yes      | M2M client secret                              |

### Database

| Variable          | Required | Description                                    |
| ----------------- | -------- | ---------------------------------------------- |
| `DATABASE_RO_URL` | Yes      | PostgreSQL connection URL (read-only replica)  |
| `DATABASE_RW_URL` | Yes      | PostgreSQL connection URL (read-write primary) |

<Tip>
  For single-server deployments, you can use the same URL for both `DATABASE_RO_URL` and `DATABASE_RW_URL`.
</Tip>

Database URLs follow the standard format:

```
postgres://user:password@host:5432/dbname?sslmode=require
```

### Stripe

| Variable                      | Required | Description                                        |
| ----------------------------- | -------- | -------------------------------------------------- |
| `STRIPE_SECRET_KEY`           | Yes      | Stripe secret key (`sk_live_...` or `sk_test_...`) |
| `STRIPE_WEBHOOK_SECRET`       | Yes      | Webhook signing secret from Stripe dashboard       |
| `STRIPE_PRICE_BASIC_MONTHLY`  | Yes      | Stripe Price ID for Basic monthly                  |
| `STRIPE_PRICE_BASIC_ANNUAL`   | Yes      | Stripe Price ID for Basic annual                   |
| `STRIPE_PRICE_PRO_MONTHLY`    | Yes      | Stripe Price ID for Pro monthly                    |
| `STRIPE_PRICE_PRO_ANNUAL`     | Yes      | Stripe Price ID for Pro annual                     |
| `STRIPE_PRICE_ENT_PER_DEVICE` | Yes      | Stripe Price ID for Enterprise per-device          |

### Email (AWS SES)

| Variable                | Required | Description                                                     |
| ----------------------- | -------- | --------------------------------------------------------------- |
| `SES_FROM_EMAIL`        | Yes      | Verified sender address (e.g. `noreply@charley.yourdomain.com`) |
| `AWS_REGION`            | No       | AWS region (default: `us-east-1`)                               |
| `AWS_ACCESS_KEY_ID`     | No       | AWS access key (not needed if using IAM role on ECS)            |
| `AWS_SECRET_ACCESS_KEY` | No       | AWS secret key (not needed if using IAM role on ECS)            |

### URLs

| Variable        | Required | Description                                              |
| --------------- | -------- | -------------------------------------------------------- |
| `DASHBOARD_URL` | Yes      | Public URL of the React dashboard                        |
| `CORS_ORIGIN`   | No       | Additional CORS origin to allow (beyond `DASHBOARD_URL`) |
| `PORT`          | No       | HTTP port (default: `3001`)                              |

### Slack Integration

| Variable              | Required | Description                   |
| --------------------- | -------- | ----------------------------- |
| `SLACK_CLIENT_ID`     | No       | Slack OAuth app client ID     |
| `SLACK_CLIENT_SECRET` | No       | Slack OAuth app client secret |
| `SLACK_REDIRECT_URI`  | No       | Slack OAuth callback URL      |

***

## Dashboard (`apps/web/.env`)

| Variable               | Required | Description                                                     |
| ---------------------- | -------- | --------------------------------------------------------------- |
| `VITE_AUTH0_DOMAIN`    | Yes      | Auth0 tenant domain                                             |
| `VITE_AUTH0_CLIENT_ID` | Yes      | Auth0 SPA client ID                                             |
| `VITE_AUTH0_AUDIENCE`  | Yes      | Auth0 API audience                                              |
| `VITE_API_BASE_URL`    | Yes      | Base URL of the Charley API (e.g. `https://api.yourdomain.com`) |

***

## Example `.env` Files

### API

```bash theme={null}
AUTH0_DOMAIN=acme.us.auth0.com
AUTH0_AUDIENCE=https://api.charleyanalytics.com
AUTH0_MGMT_CLIENT_ID=...
AUTH0_MGMT_CLIENT_SECRET=...

DATABASE_RO_URL=postgres://charley:secret@db.internal:5432/charley?sslmode=require
DATABASE_RW_URL=postgres://charley:secret@db.internal:5432/charley?sslmode=require

STRIPE_SECRET_KEY=sk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_PRICE_BASIC_MONTHLY=price_...
STRIPE_PRICE_BASIC_ANNUAL=price_...
STRIPE_PRICE_PRO_MONTHLY=price_...
STRIPE_PRICE_PRO_ANNUAL=price_...
STRIPE_PRICE_ENT_PER_DEVICE=price_...

SES_FROM_EMAIL=noreply@charley.acme.com
AWS_REGION=us-east-1

DASHBOARD_URL=https://dashboard.acme.com
PORT=3001
```

### Dashboard

```bash theme={null}
VITE_AUTH0_DOMAIN=acme.us.auth0.com
VITE_AUTH0_CLIENT_ID=...
VITE_AUTH0_AUDIENCE=https://api.charleyanalytics.com
VITE_API_BASE_URL=https://api.acme.com
```
