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

# Configuration

> How MUZE is configured across backend, frontend, and deployment

## Configuration layers

MUZE configuration is layered across three levels:

```mermaid theme={null}
flowchart TD
    A[Environment variables] --> B[NestJS ConfigModule]
    B --> C[Runtime configuration]
    C --> D[Application behaviour]

    E[Frontend .env] --> F[Vite environment]
    F --> G[Compile-time constants]
    G --> H[Client-side behaviour]
```

The complete variable reference is in [Environment variables](/operations/environment-variables).

## Backend configuration

The backend uses `@nestjs/config` with a global module and validates every environment variable at startup with Zod. If a required variable is missing or invalid, the application refuses to start, which prevents silent misconfiguration in production.

All configuration is accessed via `ConfigService`:

```typescript theme={null}
constructor(private configService: ConfigService) {
  const frontendOrigin = this.configService.get<string>('FRONTEND_ORIGIN');
}
```

Key configuration areas:

| Area          | Variables                               |
| ------------- | --------------------------------------- |
| Database      | `DATABASE_URL`, `DIRECT_URL`            |
| Auth          | `BETTER_AUTH_SECRET`, `BETTER_AUTH_URL` |
| CORS          | `FRONTEND_ORIGIN`                       |
| Email         | `BREVO_API_KEY` or SMTP variables       |
| File storage  | `R2_*` variables                        |
| Rate limiting | `THROTTLE_TTL`, `THROTTLE_LIMIT`        |

## Frontend configuration

The frontend uses Vite's environment system. Only variables prefixed with `VITE_` are exposed to the client bundle:

| Variable             | Purpose                                                                                           |
| -------------------- | ------------------------------------------------------------------------------------------------- |
| `VITE_API_BASE_URL`  | Backend API base URL                                                                              |
| `VITE_AUTH_BASE_URL` | Better Auth base URL on the backend                                                               |
| `VITE_APP_URL`       | Canonical production origin; used for SEO metadata and the generated `robots.txt` / `sitemap.xml` |

## Runtime settings

System-wide settings (order number prefixes, approval defaults, notification toggles) are stored in the `SystemSetting` table and edited by admins in the portal. They are runtime configuration, not environment variables.

## Feature flags

MUZE does not currently use feature flags. All features are available based on role.

## Deployment configuration

Deployment config lives in `backend/render.yaml` (Render service definition) and `frontend/firebase.json` (hosting rewrites and headers). Both are documented in [Deployment](/operations/deployment).
