Skip to content

Environment Configuration System - File Overview

This document provides an overview of all files created for the environment configuration system and their purposes.

Configuration Files

/config/ Directory

File Purpose Notes
local.env Local development configuration Default ports: 3000, 5000, 5001
production.env Production server configuration Configured for star.cs.wwu.edu
staging.env Staging environment configuration Alternative testing environment
README.md Configuration documentation Usage instructions

Utility Scripts

Environment Management

File Purpose Usage
load-env.sh Loads environment variables source load-env.sh
setup-frontend-env.sh Creates React .env file Called automatically

Deployment Scripts

File Purpose Usage
deploy-production.sh Automated production deployment ./deploy-production.sh
start_all_servers.sh Environment-aware startup ./start_all_servers.sh
start_all_servers.sh.backup Original backup Reference only

Documentation

File Purpose Audience
ENVIRONMENT_GUIDE.md Complete usage guide Developers
PRODUCTION_DEPLOYMENT.md Production deployment guide DevOps/Deployment
ENVIRONMENT_FILES_OVERVIEW.md This file Reference

Architecture Integration

With Systemd Services

  • asd-backend.service: Python Flask API (updated to use environment file)
  • asd-node-backend.service: Node.js API (created for production stability)

With Nginx

  • Configuration automatically uses correct ports from environment
  • Frontend build process integrates with environment variables
  • API routing matches environment URL patterns

With Application Code

  • Backend: app.py and server.js load environment variables
  • Frontend: React components use REACT_APP_* environment variables
  • Database: Connection string configurable per environment

Best Practices Implemented

Security

  • Production secrets can be overridden via environment variables
  • Debug modes disabled in production
  • Database URLs configurable per environment

Maintainability

  • Single source of truth for configuration
  • Environment-specific settings clearly separated
  • Automated deployment reduces human error

Development Experience

  • Local development remains unchanged
  • Easy switching between environments
  • Clear documentation and usage guides

Production Ready

  • Systemd service integration
  • Nginx reverse proxy compatibility
  • Automated health checks and verification

Usage Summary

Local Development

# Just works as before
./start_all_servers.sh

Production Deployment

# One command deployment
./deploy-production.sh

Environment Testing

# Test different environments
ENVIRONMENT=staging ./start_all_servers.sh
ENVIRONMENT=production ./start_all_servers.sh

Migration Notes

What Changed

  1. Added: Environment configuration system
  2. Updated: Application code to use environment variables
  3. Enhanced: Startup scripts to be environment-aware
  4. Fixed: JSON parsing issue (description field)
  5. Added: Systemd service for Node.js backend

What Stayed the Same

  • Local development workflow (no changes needed)
  • Database structure and connections
  • Core application functionality
  • Nginx and Gunicorn setup (just enhanced)

Backward Compatibility

  • Original startup scripts backed up
  • Local development unchanged
  • Existing systemd services enhanced, not replaced

This system provides a robust, production-ready configuration management approach while maintaining simplicity for local development.