Skip to content

Stages Pattern ๐ŸŽญ

Overview ๐Ÿ“‹

This pattern describes the three-stage deployment model: Development (dev), QA (staging), and Production (prod). Each stage serves specific purposes in the software development lifecycle and has distinct characteristics and requirements.

Goals ๐ŸŽฏ

  • Clear separation of development, testing, and production workloads
  • Consistent progression of changes through environments
  • Reliable testing and QA processes
  • Protected production environment
  • Traceable deployments

Stage Definitions ๐Ÿ”„

Development (dev) ๐Ÿ’ป

Purpose: Active development and integration testing

Characteristics

  • ๐Ÿ”ง Reflects current development state
  • ๐ŸŒฟ Deployed from dev branches
  • ๐Ÿงช Allows experimental features
  • ๐Ÿ”„ Frequent updates
  • ๐Ÿ“ฆ Latest dependencies

Configuration

# dev environment configuration
environment: development
debug: true
log_level: debug
feature_flags:
experimental: enabled

QA (staging) ๐Ÿงช

Purpose: Quality assurance and pre-production verification

Characteristics

  • ๐Ÿ“Š Mirrors production setup
  • ๐Ÿ” QA testing environment
  • ๐Ÿ“‘ Production data copies (anonymized)
  • ๐ŸŒฟ Deployed from main branch
  • ๐Ÿ”„ Regular but controlled updates

Configuration

# staging environment configuration
environment: staging
debug: false
log_level: info
feature_flags:
experimental: configurable

Production (prod) ๐Ÿš€

Purpose: Live system serving real users

Characteristics

  • โœ… Stable and verified code
  • ๐Ÿท๏ธ Deployed from version tags
  • ๐Ÿ”’ Strict access control
  • ๐Ÿ“ˆ Production monitoring
  • ๐Ÿ” Security hardening

Configuration

# production environment configuration
environment: production
debug: false
log_level: warn
feature_flags:
experimental: disabled

Workflow ๐Ÿ”„

Code Progression

graph LR
A[dev Branch] --> B[main Branch] --> C[Version Tag]
A --> D[dev Environment]
B --> E[staging Environment]
C --> G[Change] --> F[prod Environment]

Database Handling

Database state is exported from production into the backup system. From there a backup is imported into a fresh staging environment.

Access Control Matrix ๐Ÿ”

ResourceDevStagingProduction
Environment Access๐Ÿ”ด Only Team and Stakeholders๐Ÿ”ด Only Team and Stakeholders๐ŸŸข Users
Deployment trigger๐ŸŸข Dev-Branch Commit๐ŸŸก Signed maintainer commit after merge๐Ÿ”ด Signed Version Release

Quality Gates

Development to Staging

  • โœ“ All tests passing
  • โœ“ Code review completed
  • โœ“ Main branch merge
  • โœ“ Automated deployment

Staging to Production

  • โœ“ QA approval
  • โœ“ Performance testing
  • โœ“ Security scan
  • โœ“ Version tagged
  • โœ“ Release notes
  • โœ“ Deployment plan

Anti-patterns to Avoid โš ๏ธ

  • โŒ Bypassing staging environment
  • โŒ Using production data in development
  • โŒ Manual configuration changes
  • โŒ Inconsistent environments
  • โŒ Direct production hotfixes

Best Practices ๐Ÿ’ก

  • ๐Ÿ“ฆ Use infrastructure as code
  • ๐Ÿ”„ Automate deployment processes
  • ๐Ÿ” Maintain environment parity
  • ๐Ÿ“Š Regular staging refreshes
  • ๐Ÿ” Strict access control
  • ๐Ÿ“ Comprehensive logging
  • ๐ŸŽฏ Feature flags for control

Environment Setup Checklist ๐Ÿ“‹

  1. Infrastructure provisioned
  2. Security groups configured
  3. Monitoring enabled
  4. Backup strategy implemented
  5. Access control configured
  6. Deployment pipeline tested
  7. Documentation updated
  • ๐Ÿ”„ Deployment Pipeline
  • ๐Ÿ” Access Control
  • ๐Ÿ“Š Monitoring Strategy
  • ๐Ÿ—„๏ธ Database Management
  • ๐Ÿ“ Change Management