* Initial plan * feat: enable connection pool monitoring and configure Prisma connection limits - Start connection pool monitoring automatically in server.ts - Add connection pool configuration logging to db.ts - Update .env.example with detailed connection pool parameters - Configure connection_limit=5 in Docker Compose for PgBouncer - Add DATABASE_URL_DIRECT to production docker-compose - Create comprehensive unit tests for connection pool monitoring Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com> * docs: add connection pooling quick start and implementation guides - Add CONNECTION_POOLING_QUICKSTART.md with practical commands - Add CONNECTION_POOLING_IMPLEMENTATION.md with implementation summary - Include troubleshooting tips and monitoring commands - Document performance tuning strategies Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com> * fix: address code review comments - Fix username consistency in .env.example (use 'spywatcher' instead of 'postgres') - Add clarifying comment for dynamic import pattern in server.ts - Both changes improve code clarity and consistency Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
144 lines
5.4 KiB
Plaintext
144 lines
5.4 KiB
Plaintext
# =============================================================================
|
|
# Discord SpyWatcher - Root Environment Configuration
|
|
# =============================================================================
|
|
# This file contains example values for all environment variables needed
|
|
# across both backend and frontend services.
|
|
#
|
|
# SETUP INSTRUCTIONS:
|
|
# 1. Copy this file to .env in the root directory
|
|
# 2. Copy backend/.env.example to backend/.env
|
|
# 3. Copy frontend/.env.example to frontend/.env
|
|
# 4. Fill in the actual values in each .env file
|
|
# 5. DO NOT commit .env files to version control
|
|
# =============================================================================
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Database Configuration
|
|
# -----------------------------------------------------------------------------
|
|
# PostgreSQL connection string
|
|
# Format: postgresql://username:password@host:port/database?schema=public
|
|
#
|
|
# For production with PgBouncer (recommended):
|
|
# DATABASE_URL=postgresql://spywatcher:password@pgbouncer:6432/spywatcher?pgbouncer=true&connection_limit=5&pool_timeout=20
|
|
#
|
|
# For direct connection (development/migrations):
|
|
# DATABASE_URL=postgresql://spywatcher:password@localhost:5432/spywatcher?schema=public&connection_limit=10&pool_timeout=20&connect_timeout=10
|
|
#
|
|
# Connection Pool Parameters:
|
|
# - connection_limit: Maximum number of connections per Prisma instance (default: 10)
|
|
# * With PgBouncer: Use 3-5 (PgBouncer handles the actual pooling)
|
|
# * Without PgBouncer: Use 10-50 depending on load
|
|
# - pool_timeout: Time in seconds to wait for an available connection (default: 10)
|
|
# - connect_timeout: Time in seconds to wait for initial connection (default: 10)
|
|
DATABASE_URL=postgresql://spywatcher:password@localhost:5432/spywatcher?schema=public&connection_limit=10&pool_timeout=20&connect_timeout=10
|
|
|
|
# Direct database connection URL (used for migrations, bypasses PgBouncer)
|
|
# Always points to PostgreSQL directly, never through PgBouncer
|
|
DATABASE_URL_DIRECT=postgresql://spywatcher:password@localhost:5432/spywatcher?schema=public
|
|
|
|
# Database password (if using separate credential management)
|
|
DB_PASSWORD=your_secure_database_password
|
|
|
|
# PgBouncer admin password (optional, for monitoring)
|
|
PGBOUNCER_ADMIN_PASSWORD=your_secure_pgbouncer_admin_password
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Backend Environment Variables
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Discord Configuration
|
|
DISCORD_BOT_TOKEN=your_discord_bot_token_here_min_50_chars
|
|
DISCORD_CLIENT_ID=your_discord_client_id_here
|
|
DISCORD_CLIENT_SECRET=your_discord_client_secret_here_min_20_chars
|
|
DISCORD_GUILD_ID=your_primary_guild_id_here
|
|
DISCORD_REDIRECT_URI=http://localhost:5173/auth/callback
|
|
|
|
# Bot Configuration
|
|
BOT_GUILD_IDS=guild_id_1,guild_id_2
|
|
ADMIN_DISCORD_IDS=admin_user_id_1,admin_user_id_2
|
|
|
|
# JWT Configuration
|
|
JWT_SECRET=your_jwt_secret_min_32_chars_generate_with_openssl
|
|
JWT_REFRESH_SECRET=your_jwt_refresh_secret_min_32_chars_different_from_jwt_secret
|
|
JWT_ACCESS_EXPIRES_IN=15m
|
|
JWT_REFRESH_EXPIRES_IN=7d
|
|
|
|
# Server Configuration
|
|
NODE_ENV=development
|
|
PORT=3001
|
|
|
|
# CORS Configuration
|
|
CORS_ORIGINS=http://localhost:5173,http://127.0.0.1:5173
|
|
|
|
# Feature Flags
|
|
ENABLE_RATE_LIMITING=true
|
|
ENABLE_IP_BLOCKING=true
|
|
ENABLE_REDIS_RATE_LIMITING=true
|
|
ENABLE_LOAD_SHEDDING=true
|
|
LOG_LEVEL=info
|
|
|
|
# Redis Configuration (Optional)
|
|
# If not set, in-memory rate limiting will be used
|
|
REDIS_URL=redis://localhost:6379
|
|
|
|
# Security Configuration
|
|
MAX_REQUEST_SIZE_MB=10
|
|
|
|
# Frontend URL (for redirects)
|
|
FRONTEND_URL=http://localhost:5173
|
|
|
|
# Redis Configuration (optional - for distributed rate limiting and caching)
|
|
REDIS_URL=redis://localhost:6379
|
|
|
|
# Monitoring Configuration (optional)
|
|
# Sentry DSN for error tracking and APM
|
|
SENTRY_DSN=https://your-sentry-dsn@sentry.io/your-project-id
|
|
|
|
# Grafana Configuration (for centralized logging)
|
|
GRAFANA_ADMIN_USER=admin
|
|
GRAFANA_ADMIN_PASSWORD=admin
|
|
GRAFANA_URL=http://localhost:3000
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Frontend Environment Variables
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# API Configuration
|
|
VITE_API_URL=http://localhost:3001/api
|
|
|
|
# Discord Configuration (Client-side)
|
|
VITE_DISCORD_CLIENT_ID=your_discord_client_id_here
|
|
|
|
# Environment
|
|
VITE_ENVIRONMENT=development
|
|
|
|
# Feature Flags
|
|
VITE_ENABLE_ANALYTICS=false
|
|
|
|
# Analytics (optional)
|
|
VITE_ANALYTICS_TRACKING_ID=
|
|
|
|
# =============================================================================
|
|
# Additional Notes
|
|
# =============================================================================
|
|
#
|
|
# Security Best Practices:
|
|
# - Never commit .env files to version control
|
|
# - Use strong, randomly generated secrets (at least 32 characters)
|
|
# - Rotate secrets regularly in production
|
|
# - Use environment-specific configuration files
|
|
# - Store production secrets in a secure secret management system
|
|
#
|
|
# Generate secure random strings:
|
|
# - macOS/Linux: openssl rand -hex 32
|
|
# - Node.js: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
|
|
#
|
|
# Environment-Specific Files:
|
|
# - .env.development - Development environment
|
|
# - .env.staging - Staging environment
|
|
# - .env.production - Production environment (use secret manager instead)
|
|
# - .env.test - Test environment
|
|
#
|
|
# For more information, see the project documentation.
|
|
# =============================================================================
|