# Environment Variables

<figure><img src="https://869823119-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpyWVnmtszkUSqMcP8ips%2Fuploads%2F6pkvZDV1mSE76MEDLLDw%2Fdownload.png?alt=media&#x26;token=6fcf0021-5910-46c7-bfa4-9430df727832" alt="Env logo" width="113"><figcaption></figcaption></figure>

### Basic configuration

```bash
# Database
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/pool_appointments"

# Redis
REDIS_URL="redis://localhost:6379"

# JWT
JWT_SECRET="your-secret-key-here"
JWT_REFRESH_SECRET="your-refresh-secret-key-here"

# App
APP_PORT=3000
NODE_ENV=development

# URLs
APP_URL="http://localhost:3000"
ADMIN_URL="http://localhost:3000/admin"
```

### Mail configuration

#### Mailtrap SMTP (Recommended for development)

```bash
# Mailtrap SMTP settings
MAILTRAP_HOST="sandbox.smtp.mailtrap.io"
MAILTRAP_PORT=587
MAILTRAP_USER="your-mailtrap-username"
MAILTRAP_PASS="your-mailtrap-password"
MAILTRAP_FROM="noreply@nine-line.com"
MAILTRAP_FROM_NAME="Nine Line"

# URLs dos Aplicativos
APP_URL="http://localhost:3000"
ANDROID_APP_URL="https://play.google.com/store/apps/details?id=com.nineline.app"
IOS_APP_URL="https://apps.apple.com/app/nine-line/id123456789"
```

#### SMTP (To production)

```bash
# SMTP settings
SMTP_HOST="smtp.gmail.com"
SMTP_PORT=587
SMTP_USER="your-email@gmail.com"
SMTP_PASS="your-app-password"
SMTP_FROM="noreply@yourdomain.com"
```

### Full configuration - Validated environments (Zod Schema)

Can you see this in src/config/.env.ts

```
const envSchema = z.object({
  NODE_ENV: z
    .enum(['development', 'production', 'test'])
    .default('development'),
  APP_PORT: z.coerce.number().default(3000),
  DATABASE_URL: z.string(),
  REDIS_URL: z.string(),
  DOCKER: z.string().default('false'),
  LOG_LEVEL: z
    .enum(['fatal', 'error', 'warn', 'info', 'debug', 'trace'])
    .default('info'),
  JWT_SECRET: z.string(),
  JWT_REFRESH_SECRET: z.string(),
  ALLOWED_ORIGINS: z.string().default('http://localhost:3000'),

  // Notification settings
  SMTP_HOST: z.string().optional(),
  SMTP_PORT: z.coerce.number().optional(),
  SMTP_USER: z.string().optional(),
  SMTP_PASS: z.string().optional(),
  SMTP_FROM: z.string().optional(),

  // Mailtrap SMTP settings
  MAILTRAP_HOST: z.string().default('sandbox.smtp.mailtrap.io'),
  MAILTRAP_PORT: z.coerce.number().default(587),
  MAILTRAP_USER: z.string(),
  MAILTRAP_PASS: z.string(),
  MAILTRAP_FROM: z.string().default('noreply@nine-line.com'),
  MAILTRAP_FROM_NAME: z.string().default('Nine Line'),

  // App URLs
  APP_URL: z.string().default('http://localhost:3000'),
  ANDROID_APP_URL: z.string().default('https://play.google.com/store/apps/details?id=com.nineline.app'),
  IOS_APP_URL: z.string().default('https://apps.apple.com/app/nine-line/id123456789'),
  ADMIN_URL: z.string().default('http://localhost:3000/admin'),
  
  // Rate Limiting
  RATE_LIMIT_WINDOW_MS: z.coerce.number().default(60000), 
  RATE_LIMIT_MAX_REQUESTS: z.coerce.number().default(100),
  RATE_LIMIT_SENSITIVE_MAX_REQUESTS: z.coerce.number().default(10), 
  RATE_LIMIT_CRITICAL_MAX_REQUESTS: z.coerce.number().default(5),
});
```
