docs: update documentation to reflect unified config system

- Update config README to focus on current unified system rather than migration
- Update architecture migration doc to reference unifiedConfig instead of appConfig
- Update implementation summary to reference unified.config.ts
- Remove migration-specific content not relevant for new applications
- Provide clear guidance for working with unified configuration system
This commit is contained in:
William Valentin
2025-09-08 20:43:44 -07:00
parent 25b68ee67d
commit b81f9b2970
3 changed files with 51 additions and 34 deletions

View File

@@ -4,24 +4,23 @@ This directory contains the unified configuration system for the RxMinder applic
## Overview ## Overview
The unified configuration system replaces the previous scattered approach of multiple `.env` files and environment-specific configurations with a centralized, type-safe, and environment-aware system. The unified configuration system serves as the **single source of truth** for all application configuration. It reads from your `.env` file for environment-specific overrides and provides a centralized, type-safe, and environment-aware configuration system.
### Key Benefits ### Key Benefits
- 🎯 **Single Source of Truth**: All configuration in one place - 🎯 **Single Source of Truth**: Unified config with `.env` file overrides
- 🔒 **Type Safety**: Full TypeScript support with interfaces - 🔒 **Type Safety**: Full TypeScript support with interfaces
- 🌍 **Environment Aware**: Automatic environment-specific overrides - 🌍 **Environment Aware**: Reads from `.env` file for environment-specific settings
- 🚀 **Auto-Generation**: Generates all necessary config files automatically - 🚀 **Auto-Generation**: Generates all necessary config files automatically
- 🔄 **Easy Migration**: Smooth transition from old config system - 🔄 **Simplified Architecture**: Clean, maintainable configuration management
- 📝 **Self-Documenting**: Clear structure with validation - 📝 **Self-Documenting**: Clear structure with validation and debugging tools
## File Structure ## File Structure
``` ```
config/ config/
├── README.md # This documentation ├── README.md # This documentation
├── unified.config.ts # Main unified configuration ├── unified.config.ts # Single source of truth configuration
├── app.config.ts # Legacy config (deprecated)
└── generated/ # Auto-generated configs └── generated/ # Auto-generated configs
├── development.config.ts ├── development.config.ts
├── staging.config.ts ├── staging.config.ts
@@ -49,20 +48,21 @@ if (featureFlags.enableOAuth) {
} }
``` ```
### 2. Environment Variables ### 2. Environment Variables (.env file)
The system reads from environment variables with fallbacks to sensible defaults: The system reads from your `.env` file as the primary source for environment-specific overrides:
```bash ```bash
# Required variables # .env file - Primary configuration source
APP_NAME=RxMinder APP_NAME=rxminder
NODE_ENV=production NODE_ENV=production
VITE_COUCHDB_URL=http://couchdb:5984 VITE_COUCHDB_URL=http://rxminder-couchdb-service:5984
VITE_COUCHDB_USER=admin
VITE_COUCHDB_PASSWORD=your-secure-password
# Optional variables with defaults # Container configuration
APP_VERSION=1.0.0 CONTAINER_REGISTRY=your-registry.com
DEBUG_MODE=false CONTAINER_REPOSITORY=your-org/app
ENABLE_OAUTH=true
``` ```
### 3. Generating Config Files ### 3. Generating Config Files
@@ -278,23 +278,29 @@ bun scripts/generate-unified-config.ts production
bun scripts/generate-unified-config.ts --dry-run bun scripts/generate-unified-config.ts --dry-run
``` ```
## Migration from Old System ## Working with the Configuration System
If you're migrating from the old configuration system: ### 1. Basic Usage
### 1. Backup Current Configuration Access configuration in your application:
```bash ```typescript
bun scripts/generate-unified-config.ts production import { unifiedConfig } from './config/unified.config';
const appName = unifiedConfig.app.name;
const dbUrl = unifiedConfig.database.url;
``` ```
### 2. Run Migration ### 2. Environment Overrides
Add variables to your `.env` file:
```bash ```bash
bun scripts/generate-unified-config.ts --all APP_NAME=my-app
VITE_COUCHDB_URL=http://localhost:5984
``` ```
### 3. Generate New Config Files ### 3. Generate Configs
```bash ```bash
make generate-config make generate-config
@@ -402,10 +408,21 @@ make deploy-prod-quick
For questions or issues with the unified configuration system: For questions or issues with the unified configuration system:
1. Check this documentation first 1. Check this documentation first
2. Run diagnostic commands (`make config-debug`, `make validate-config`) 2. Run diagnostic commands:
- `make config-check` - Health check of entire config system
- `make config-debug` - Show current configuration values
3. Review generated configuration files 3. Review generated configuration files
4. Check application logs for configuration-related errors 4. Check `.env` file for environment-specific overrides
5. Check application logs for configuration-related errors
## Configuration Priority
The unified config uses this priority order:
1. **`.env` file** (highest priority) - Environment-specific overrides
2. **Environment configs** (medium priority) - Built-in environment defaults
3. **Default values** (lowest priority) - Fallback defaults in unified.config.ts
--- ---
_This unified configuration system provides a robust, scalable, and maintainable approach to application configuration management._ _The unified configuration system provides a robust, scalable, and maintainable approach to application configuration management with `.env` file integration._

View File

@@ -67,14 +67,14 @@ const dbUrl = process.env.VITE_COUCHDB_URL || 'http://localhost:5984';
#### New Pattern (Recommended) #### New Pattern (Recommended)
```typescript ```typescript
import { appConfig, CONFIG } from '../config/app.config'; import { unifiedConfig } from '../config/unified.config';
// Type-safe, validated configuration // Type-safe, validated configuration
const baseUrl = appConfig.baseUrl; const baseUrl = unifiedConfig.app.baseUrl;
const dbUrl = appConfig.database.url; const dbUrl = unifiedConfig.database.url;
// Or use constants for common values // Or use convenience exports
const isProduction = CONFIG.IS_PRODUCTION; const isProduction = unifiedConfig.app.environment === 'production';
``` ```
### Logging Migration ### Logging Migration
@@ -117,7 +117,7 @@ services/
│ └── Logger.ts # Logger implementation │ └── Logger.ts # Logger implementation
config/ # ✅ Centralized configuration config/ # ✅ Centralized configuration
└── app.config.ts # Main configuration with validation └── unified.config.ts # Main configuration with validation
``` ```
## 🎯 Benefits Achieved ## 🎯 Benefits Achieved

View File

@@ -33,7 +33,7 @@ This report summarizes the major architectural improvements implemented to addre
#### Files Created #### Files Created
- `config/app.config.ts` - Centralized configuration with validation - `config/unified.config.ts` - Centralized configuration with validation
#### Key Improvements #### Key Improvements