Skip to main content

Overview

DecipherIt consists of two main components that need to be configured:
  1. Frontend - Next.js application with authentication and file storage
  2. Backend - FastAPI server with AI agents and vector search
Each component has its own configuration file with specific requirements.

Frontend Configuration

The frontend uses a .env.local file in the client/ directory.

Database Configuration

DATABASE_URL
string
required
PostgreSQL connection string for Prisma ORM
DATABASE_URL="postgresql://username:password@localhost:5432/decipher"
The same database is used by both frontend and backend. Ensure the connection string is identical in both configuration files.

Authentication Configuration

DecipherIt uses Better Auth for authentication.
BETTER_AUTH_SECRET
string
required
Secret key for signing authentication tokens. Generate a secure random string.
BETTER_AUTH_SECRET="your-secure-random-string-here"
BETTER_AUTH_URL
string
required
Base URL where your application is hosted
# Development
BETTER_AUTH_URL="http://localhost:3000"

# Production
BETTER_AUTH_URL="https://yourdomain.com"
Keep your BETTER_AUTH_SECRET secure and never commit it to version control. Generate it using a cryptographically secure method.

Storage Configuration

DecipherIt uses Cloudflare R2 for object storage (documents, audio files).
R2_ENDPOINT
string
required
Your Cloudflare R2 endpoint URL
R2_ENDPOINT="https://your-account-id.r2.cloudflarestorage.com"
R2_ACCESS_KEY_ID
string
required
R2 access key ID for authentication
R2_ACCESS_KEY_ID="your-r2-access-key"
R2_SECRET_ACCESS_KEY
string
required
R2 secret access key for authentication
R2_SECRET_ACCESS_KEY="your-r2-secret-key"
R2_BUCKET_NAME
string
required
Name of your R2 bucket for file storage
R2_BUCKET_NAME="decipher-files"
R2_PUBLIC_URL
string
required
Public URL for accessing stored files via CDN
R2_PUBLIC_URL="https://files.yourdomain.com"

Application URLs

NEXT_PUBLIC_BASE_URL
string
required
Public base URL of your application (used in client-side code)
# Development
NEXT_PUBLIC_BASE_URL="http://localhost:3000"

# Production
NEXT_PUBLIC_BASE_URL="https://yourdomain.com"
BACKEND_API_URL
string
required
URL of the backend API server
# Development
BACKEND_API_URL="http://localhost:8001"

# Production
BACKEND_API_URL="https://api.yourdomain.com"

Complete Frontend Example

.env.local
DATABASE_URL="postgresql://decipher_user:password@localhost:5432/decipher"
BETTER_AUTH_SECRET="your-secure-random-string-minimum-32-chars"
BETTER_AUTH_URL="http://localhost:3000"
BACKEND_API_URL="http://localhost:8001"
NEXT_PUBLIC_BASE_URL="http://localhost:3000"

R2_ENDPOINT="https://your-account-id.r2.cloudflarestorage.com"
R2_ACCESS_KEY_ID="your-r2-access-key"
R2_SECRET_ACCESS_KEY="your-r2-secret-key"
R2_BUCKET_NAME="decipher-files"
R2_PUBLIC_URL="https://files.yourdomain.com"

Backend Configuration

The backend uses a .env file in the backend/ directory.

Database Configuration

DATABASE_URL
string
required
PostgreSQL connection string (same as frontend)
DATABASE_URL="postgresql://username:password@localhost:5432/decipher"

AI Services Configuration

OpenAI

Used for embeddings and text generation.
OPENAI_API_KEY
string
required
Your OpenAI API key for embeddings
OPENAI_API_KEY="sk-proj-..."
Get your API key from OpenAI Platform.

OpenRouter

Used for accessing Google Gemini models.
OPENROUTER_API_KEY
string
required
Your OpenRouter API key for Gemini models
OPENROUTER_API_KEY="sk-or-v1-..."
Get your API key from OpenRouter.

LemonFox AI

Used for high-quality text-to-speech synthesis.
LEMONFOX_API_KEY
string
required
Your LemonFox API key for TTS
LEMONFOX_API_KEY="your-lemonfox-api-key"
Get your API key from LemonFox AI.

Bright Data Configuration

Bright Data provides web scraping capabilities through the MCP server.
BRIGHT_DATA_API_TOKEN
string
required
Your Bright Data API token
BRIGHT_DATA_API_TOKEN="your-bright-data-token"
BRIGHT_DATA_BROWSER_AUTH
string
required
Browser authentication credentials for Bright Data
BRIGHT_DATA_BROWSER_AUTH="your-bright-data-browser-auth"
Get your credentials from Bright Data after signing up.
Bright Data offers free credits for new users. The Web Unlocker zone is created automatically using your API token.

Vector Database Configuration

QDRANT_API_URL
string
required
Qdrant API endpoint URL
# Local installation
QDRANT_API_URL="http://localhost:6333"

# Cloud instance
QDRANT_API_URL="https://your-cluster.qdrant.io"
QDRANT_API_KEY
string
API key for Qdrant Cloud (not needed for local installation)
QDRANT_API_KEY="your-qdrant-api-key"

Cloud Storage Configuration

CLOUDFLARE_ACCOUNT_ID
string
required
Your Cloudflare account ID
CLOUDFLARE_ACCOUNT_ID="your-cloudflare-account-id"
CLOUDFLARE_R2_ACCESS_KEY_ID
string
required
R2 access key ID (same as frontend)
CLOUDFLARE_R2_ACCESS_KEY_ID="your-r2-access-key"
CLOUDFLARE_R2_SECRET_ACCESS_KEY
string
required
R2 secret access key (same as frontend)
CLOUDFLARE_R2_SECRET_ACCESS_KEY="your-r2-secret-key"

Optional: LangTrace

LANGTRACE_API_KEY
string
API key for LangTrace observability (optional)
LANGTRACE_API_KEY="your-langtrace-api-key"

Complete Backend Example

.env
# Database
DATABASE_URL="postgresql://decipher_user:password@localhost:5432/decipher"

# Bright Data
BRIGHT_DATA_API_TOKEN="your-bright-data-api-token"
BRIGHT_DATA_BROWSER_AUTH="your-bright-data-browser-auth"

# AI Services
OPENROUTER_API_KEY="sk-or-v1-..."
OPENAI_API_KEY="sk-proj-..."
LEMONFOX_API_KEY="your-lemonfox-api-key"

# Vector Database
QDRANT_API_KEY="your-qdrant-api-key"
QDRANT_API_URL="http://localhost:6333"

# Cloud Storage
CLOUDFLARE_ACCOUNT_ID="your-cloudflare-account-id"
CLOUDFLARE_R2_ACCESS_KEY_ID="your-r2-access-key"
CLOUDFLARE_R2_SECRET_ACCESS_KEY="your-r2-secret-key"

# Optional: Observability
LANGTRACE_API_KEY="your-langtrace-api-key"

Security Best Practices

Never commit .env or .env.local files to version control. Add them to .gitignore.
  1. Use Strong Secrets: Generate cryptographically secure random strings for authentication secrets
  2. Restrict API Keys: Use API keys with minimum required permissions
  3. Rotate Credentials: Regularly rotate API keys and secrets
  4. Environment Separation: Use different credentials for development and production
  5. Secure Storage: Store production secrets in a secure vault (e.g., AWS Secrets Manager, HashiCorp Vault)

Production Considerations

HTTPS/TLS

In production, always use HTTPS:
BETTER_AUTH_URL="https://yourdomain.com"
NEXT_PUBLIC_BASE_URL="https://yourdomain.com"

CORS Configuration

The backend has CORS middleware enabled. For production, configure allowed origins in the FastAPI application.

Database Connection Pooling

For production, use connection pooling:
DATABASE_URL="postgresql://user:pass@host:5432/decipher?pool_size=20&max_overflow=10"

Next Steps

Environment Variables

Complete reference of all environment variables

Docker Deployment

Deploy using Docker containers

Build docs developers (and LLMs) love