Docs/Development

Environments

Development, staging, and production environments with isolated configuration.

Environment Management

Overview

AlgorithmShift provides a robust environment management system that enables safe development, testing, and deployment workflows. Each environment is isolated with its own configuration, database, and secrets.


Environment Types

Default Environments

EnvironmentPurposeDeploymentAccess
DevelopmentActive developmentAuto on pushDevelopers
StagingPre-production testingManual promoteTeam + QA
ProductionLive usersManual + ApprovalRestricted

Custom Environments

Create additional environments for:

  • Feature branches
  • Client demos
  • Load testing
  • Security audits
  • Regional deployments

Database Configuration

Per-Environment Databases

Each environment can have its own database configuration:

typescript
interface DatabaseConnection {
  id: string;
  name: string;           // "Primary Database"
  type: 'postgres';

  // Connection (per environment)
  values: {
    development: {
      host: 'dev-db.example.com';
      port: 5432;
      database: 'myapp_dev';
    };
    staging: {
      host: 'staging-db.example.com';
      database: 'myapp_staging';
    };
    production: {
      host: 'prod-db.example.com';
      database: 'myapp_prod';
      ssl: true;
      poolSize: 20;
    };
  };
}

Secrets Management

Secret Storage

Secrets are stored securely in AWS Secrets Manager:

typescript
interface Secret {
  id: string;
  name: string;           // STRIPE_SECRET_KEY
  description: string;
  rotationEnabled: boolean;
  rotationDays?: number;
}

Common Secrets

SecretPurpose
DB_PASSWORDDatabase credentials
STRIPE_SECRET_KEYPayment processing
SENDGRID_API_KEYEmail service
AWS_ACCESS_KEY_IDCloud services
JWT_SECRETToken signing
ENCRYPTION_KEYData encryption

Deployment Pipeline

Pipeline Visualization

┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│ Development │───▶│   Staging   │───▶│ Production  │
│             │    │             │    │             │
│ Auto-deploy │    │   Manual    │    │  Approval   │
│ on push     │    │   promote   │    │  required   │
└─────────────┘    └─────────────┘    └─────────────┘

Promotion Flow

  1. Code Commit → Development auto-deploys
  2. Testing Complete → Promote to Staging
  3. UAT Approved → Request Production deploy
  4. Approval Received → Deploy to Production

Best Practices

Development Environment

  • Enable all feature flags
  • Use debug logging
  • Disable rate limiting
  • Use test data
  • Allow CORS from localhost

Staging Environment

  • Mirror production configuration
  • Use production-like data (anonymized)
  • Enable performance monitoring
  • Test with realistic load
  • Verify integrations

Production Environment

  • Enable all security measures
  • Configure proper logging (warn/error)
  • Set up monitoring and alerts
  • Implement rate limiting
  • Use read replicas for scale
  • Regular backup schedule
  • Document runbooks