Skip to main content

Overview

Quail BI uses environment variables for configuration. All variables should be defined in a .env.local file in the project root.
Never commit .env.local to version control. Use .env.example as a template.

Required Variables

These variables must be configured for Quail to function:

Encryption Key

.env.local
NEXT_PUBLIC_ENCRYPTION_KEY=your-32-character-base64-encoded-key
Purpose: Encrypts database connection strings using AES-256-GCM before storing them.
Generate a secure key:
openssl rand -base64 32
The key must be exactly 32 bytes (256 bits) when decoded from base64. If the application throws an encryption error on startup, regenerate the key.

Supabase Configuration

.env.local
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-public-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-secret-key

SUPABASE_URL

Your Supabase project URL from the dashboard

ANON_KEY

Public anonymous key for client-side auth

SERVICE_ROLE_KEY

Secret key for server-side operations
Where to find these:
1

Open Supabase Dashboard

Navigate to your project at app.supabase.com
2

Go to Settings

Click Settings in the sidebar, then API
3

Copy Keys

Copy the Project URL, anon public key, and service_role secret key

MongoDB Configuration

.env.local
MONGODB_URI=mongodb+srv://username:[email protected]/database_name
Purpose: Stores user accounts, database connections (encrypted), dashboards, and chat history.
Connection string format:
mongodb+srv://username:[email protected]/database_name?retryWrites=true&w=majority

Optional Variables

Default Database Connection

.env.local
NEXT_PUBLIC_DEFAULT_DB_CONNECTION_STRING=
Purpose: Optional demo/test database connection string shown to users.
Leave empty in production or provide a read-only demo database.

Azure AI Configuration

.env.local
NEXT_PUBLIC_AZURE_RESOURCE_NAME=your-resource-name
NEXT_PUBLIC_AZURE_API_KEY=your-api-key
NEXT_PUBLIC_AZURE_FUNCTION_ENDPOINT=https://your-function.azurewebsites.net
Purpose: Enables AI-powered features like natural language to SQL, chart generation, and query explanations.

RESOURCE_NAME

Your Azure OpenAI resource name (not the full endpoint URL)

API_KEY

API key from Azure OpenAI resource

FUNCTION_ENDPOINT

Azure Function endpoint for AI processing (optional)
1

Create Azure OpenAI Resource

In Azure Portal, create an Azure OpenAI resource
2

Get Resource Name

Copy the resource name (e.g., quail-openai from quail-openai.openai.azure.com)
3

Get API Key

Copy the API key from Keys and Endpoint in the Azure Portal
4

Configure Function Endpoint (Optional)

If using Azure Functions for AI processing, set the function app URL
If you don’t configure Azure AI, you can still use Quail, but AI-powered features will be disabled.

Stripe Configuration

.env.local
NEXT_PUBLIC_STRIPE_PK=pk_test_...
STRIPE_SK=sk_test_...
STRIPE_ENDPOINT_SECRET=whsec_...
Purpose: Enables subscription billing and payment processing for Free and Pro tiers.

STRIPE_PK

Publishable key for client-side Stripe integration

STRIPE_SK

Secret key for server-side payment processing

ENDPOINT_SECRET

Webhook secret for validating Stripe events
Quail has two pricing tiers: Free (limited monthly usage) and Pro (unlimited). Stripe integration is required for Pro subscriptions.

Application URL

.env.local
NEXT_PUBLIC_APP_URL=http://localhost:3000
Purpose: Base URL for the application, used for redirects and webhooks.
Change this to your production domain:
NEXT_PUBLIC_APP_URL=https://quail.yourdomain.com

Environment Variable Reference

Complete .env.local Template

.env.local
# ========================================
# REQUIRED VARIABLES
# ========================================

# Encryption Key (REQUIRED)
# Generate with: openssl rand -base64 32
NEXT_PUBLIC_ENCRYPTION_KEY=

# Supabase Configuration (REQUIRED)
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=
SUPABASE_ADMIN=

# MongoDB Configuration (REQUIRED)
MONGODB_URI=
MONGODB_DB_NAME=quail

# ========================================
# OPTIONAL VARIABLES
# ========================================

# Default Database Connection (optional)
NEXT_PUBLIC_DEFAULT_DB_CONNECTION_STRING=

# Azure AI Configuration (optional)
NEXT_PUBLIC_AZURE_RESOURCE_NAME=
NEXT_PUBLIC_AZURE_API_KEY=
NEXT_PUBLIC_AZURE_FUNCTION_ENDPOINT=

# Stripe Configuration (optional for Free tier, required for Pro)
NEXT_PUBLIC_STRIPE_PK=
STRIPE_SK=
STRIPE_ENDPOINT_SECRET=

# Usage Limits
FREE_TIER_MONTHLY_LIMIT=100

# Application Settings (optional)
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_BASE_URL=http://localhost:3000

Platform-Specific Configuration

Vercel

Add environment variables in the Vercel dashboard:
1

Open Project Settings

Navigate to your project, then Settings → Environment Variables
2

Add Each Variable

Add all required variables from your .env.local
3

Select Environments

Choose Production, Preview, and/or Development
4

Redeploy

Trigger a new deployment for changes to take effect
Use different values for Production and Preview environments (e.g., separate Supabase projects for staging).

Docker

Pass environment variables to Docker:
docker run -p 3000:3000 --env-file .env.local quail-bi

Kubernetes

Use ConfigMaps and Secrets:
kubernetes/secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: quail-secrets
type: Opaque
stringData:
  NEXT_PUBLIC_ENCRYPTION_KEY: your-key
  SUPABASE_SERVICE_ROLE_KEY: your-service-role-key
  MONGODB_URI: mongodb+srv://...
  AZURE_OPENAI_API_KEY: your-api-key
  STRIPE_SECRET_KEY: sk_...
  STRIPE_WEBHOOK_SECRET: whsec_...
kubernetes/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: quail-config
data:
  NEXT_PUBLIC_SUPABASE_URL: https://your-project.supabase.co
  NEXT_PUBLIC_APP_URL: https://quail.yourdomain.com
  AZURE_OPENAI_ENDPOINT: https://your-resource.openai.azure.com/
  AZURE_OPENAI_DEPLOYMENT_NAME: gpt-4o
kubernetes/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: quail
spec:
  template:
    spec:
      containers:
      - name: quail
        image: quail-bi:latest
        envFrom:
        - configMapRef:
            name: quail-config
        - secretRef:
            name: quail-secrets

AWS, Azure, GCP

Use AWS Systems Manager Parameter Store or Secrets Manager:
# Store secrets
aws secretsmanager create-secret \
  --name quail/encryption-key \
  --secret-string "your-key"

# Reference in application
const key = await getSecretValue('quail/encryption-key');

Security Best Practices

Never expose secret environment variables to the client. Only variables prefixed with NEXT_PUBLIC_ are exposed to the browser.

Use Secret Management

Store secrets in platform-specific secret managers, not in environment files

Rotate Keys Regularly

Change encryption keys and API keys periodically

Use Different Keys per Environment

Never reuse production keys in development or staging

Restrict Access

Limit who can view or modify environment variables

Troubleshooting

The encryption key is missing or not set correctly:
  1. Verify .env.local exists in the project root
  2. Check the variable name matches exactly: NEXT_PUBLIC_ENCRYPTION_KEY
  3. Ensure there are no spaces around the = sign
  4. Restart the development server after changes
# Generate a new key
openssl rand -base64 32

# Add to .env.local
echo "NEXT_PUBLIC_ENCRYPTION_KEY=$(openssl rand -base64 32)" >> .env.local
The encryption key must be exactly 32 bytes when decoded:
# Test key length
echo "your-key" | base64 -d | wc -c
# Should output: 32

# If not 32, regenerate:
openssl rand -base64 32
Platform-specific issues:
  • Vercel: Ensure variables are added in dashboard and deployment is triggered
  • Docker: Verify --env-file path or -e flags are correct
  • Kubernetes: Check ConfigMap and Secret are applied and referenced
  • Others: Ensure environment variables are set before running node server.js

Next Steps

Database Setup

Configure MongoDB and Supabase

Configuration

Advanced configuration options

Security

Secure your environment variables

Troubleshooting

Fix common environment issues

Build docs developers (and LLMs) love