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

# Configuration

> All PIKARC_* environment variables for backend configuration.

The Pikarc backend is configured via environment variables with the `PIKARC_` prefix. Settings can also be loaded from a `.env` file.

## Database

| Variable             | Type      | Default     | Description              |
| -------------------- | --------- | ----------- | ------------------------ |
| `PIKARC_DB_HOST`     | `string`  | `localhost` | PostgreSQL host          |
| `PIKARC_DB_PORT`     | `integer` | `5432`      | PostgreSQL port          |
| `PIKARC_DB_USER`     | `string`  | `pikarc`    | PostgreSQL user          |
| `PIKARC_DB_PASSWORD` | `string`  | `pikarc`    | PostgreSQL password      |
| `PIKARC_DB_NAME`     | `string`  | `pikarc`    | PostgreSQL database name |

The connection URL is computed as:

```
postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}
```

## Redis

| Variable           | Type     | Default                    | Description          |
| ------------------ | -------- | -------------------------- | -------------------- |
| `PIKARC_REDIS_URL` | `string` | `redis://localhost:6379/0` | Redis connection URL |

Redis is used for the guardrail cache layer — spend counters, concurrent run tracking, and kill switch state.

## Authentication

| Variable                  | Type      | Default                   | Description                                                                    |
| ------------------------- | --------- | ------------------------- | ------------------------------------------------------------------------------ |
| `PIKARC_JWT_SECRET`       | `string`  | `change-me-in-production` | JWT signing secret. Also used to derive the Fernet key for API key encryption. |
| `PIKARC_JWT_ALGORITHM`    | `string`  | `HS256`                   | JWT signing algorithm                                                          |
| `PIKARC_JWT_EXPIRY_HOURS` | `integer` | `24`                      | JWT token lifetime in hours                                                    |

<Warning>
  Always change `PIKARC_JWT_SECRET` in production. The default value is insecure.
</Warning>

## Stripe (Optional)

| Variable                       | Type             | Default | Description                                                          |
| ------------------------------ | ---------------- | ------- | -------------------------------------------------------------------- |
| `PIKARC_STRIPE_SECRET_KEY`     | `string \| null` | `null`  | Stripe secret key. When not set, plan changes are direct DB updates. |
| `PIKARC_STRIPE_WEBHOOK_SECRET` | `string \| null` | `null`  | Stripe webhook signing secret                                        |
| `PIKARC_STRIPE_PRO_PRICE_ID`   | `string \| null` | `null`  | Stripe Price ID for the Pro plan                                     |
| `PIKARC_STRIPE_SCALE_PRICE_ID` | `string \| null` | `null`  | Stripe Price ID for the Scale plan                                   |

When `PIKARC_STRIPE_SECRET_KEY` is not configured, the billing system degrades gracefully — plan changes happen via direct database updates with no payment required. This is the default for local development.

## Email (Optional)

| Variable                | Type             | Default                       | Description                       |
| ----------------------- | ---------------- | ----------------------------- | --------------------------------- |
| `PIKARC_RESEND_API_KEY` | `string \| null` | `null`                        | Resend API key for sending emails |
| `PIKARC_EMAIL_FROM`     | `string`         | `Pikarc <noreply@pikarc.dev>` | Sender address for emails         |

When `PIKARC_RESEND_API_KEY` is not configured, emails are logged to the console instead of sent.

## Application

| Variable              | Type           | Default                     | Description                                              |
| --------------------- | -------------- | --------------------------- | -------------------------------------------------------- |
| `PIKARC_DEBUG`        | `boolean`      | `false`                     | Enables SQLAlchemy echo and FastAPI debug mode           |
| `PIKARC_CORS_ORIGINS` | `list[string]` | `["http://localhost:3000"]` | Allowed CORS origins                                     |
| `PIKARC_FRONTEND_URL` | `string`       | `http://localhost:3000`     | Frontend URL (used for email links and Stripe redirects) |

## Frontend

The frontend has a single environment variable:

| Variable              | Default                 | Description     |
| --------------------- | ----------------------- | --------------- |
| `NEXT_PUBLIC_API_URL` | `http://localhost:8000` | Backend API URL |

## Example `.env` File

```bash theme={null}
# Database
PIKARC_DB_HOST=localhost
PIKARC_DB_PORT=5432
PIKARC_DB_USER=pikarc
PIKARC_DB_PASSWORD=your-secure-password
PIKARC_DB_NAME=pikarc

# Redis
PIKARC_REDIS_URL=redis://localhost:6379/0

# Auth
PIKARC_JWT_SECRET=your-production-secret-here

# Stripe (optional)
PIKARC_STRIPE_SECRET_KEY=sk_live_...
PIKARC_STRIPE_WEBHOOK_SECRET=whsec_...
PIKARC_STRIPE_PRO_PRICE_ID=price_...
PIKARC_STRIPE_SCALE_PRICE_ID=price_...

# Email (optional)
PIKARC_RESEND_API_KEY=re_...
```
