- Phase 7: Config Consolidation - CONTEXT.md: Defines scope, decisions, and requirements - PLAN.md: 18-task implementation plan with detailed acceptance criteria - Centralize all configs into config/ folder - Update deploy scripts, backend loading, and documentation - Maintain backward compatibility with inventory.env Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
103 lines
4.6 KiB
Markdown
103 lines
4.6 KiB
Markdown
# Phase 7: Config Consolidation - Context
|
|
|
|
**Gathered:** 2026-04-23
|
|
**Status:** Ready for planning
|
|
**Source:** User Requirements
|
|
|
|
---
|
|
|
|
## Phase Boundary
|
|
|
|
Consolidate all application configuration files into a centralized `config/` folder in the project root. This includes backend configurations, frontend configurations, deployment settings, and network configurations. Update all deployment scripts, application startup procedures, and backend/frontend code to load configurations from this centralized location.
|
|
|
|
**Scope:**
|
|
- Create and establish `config/` folder as the single source of truth for all application configuration
|
|
- Migrate existing configuration files (inventory.env and variants) to config folder with meaningful names
|
|
- Update all scripts (deploy.sh, run_standalone.sh, etc.) to reference the new config location
|
|
- Refactor backend config_loader.py and config_manager.py to read from config folder
|
|
- Update frontend environment loading if applicable
|
|
- Verify and clean up root directory scripts that are no longer needed
|
|
- Ensure Docker deployment, standalone deployment, and development all work correctly with new structure
|
|
|
|
**Deliverables:**
|
|
- `config/` folder with structured configuration files
|
|
- Updated backend configuration loading mechanism
|
|
- Updated deployment scripts
|
|
- Updated startup procedures (Docker and standalone)
|
|
- Documentation of configuration structure in README/DEPLOYMENT.md
|
|
|
|
---
|
|
|
|
## Implementation Decisions
|
|
|
|
### Configuration Structure
|
|
- Create `config/` folder in project root as the central location for all configurations
|
|
- Use meaningful filenames: `backend.env`, `frontend.env`, `network.env`, `docker.env` (for docker-compose)
|
|
- Keep backward compatibility: Support both old (`inventory.env`) and new (`config/backend.env`) paths during transition
|
|
- Environment variable precedence: System env vars > Docker build args > config/backend.env > defaults in code
|
|
|
|
### Backend Loading
|
|
- Update `backend/config_loader.py` to look for configs in `config/backend.env` first
|
|
- If not found, fall back to `inventory.env` (backward compatibility)
|
|
- If neither exists, use system environment variables
|
|
- Log which config source is being used for debugging
|
|
|
|
### Deployment Scripts
|
|
- `deploy.sh`: Source environment from `config/network.env` or `config/docker.env` instead of `inventory.env`
|
|
- `run_standalone.sh`: Source configuration from `config/backend.env` and `config/network.env`
|
|
- Docker Compose: Updated to reference `config/docker.env`
|
|
- Scripts should create symlinks or validate that config folder exists before running
|
|
|
|
### Cleanup Actions
|
|
- Remove or archive `inventory.env` templates after migration
|
|
- Audit root directory scripts for redundancy
|
|
- Update .gitignore to ensure config/ folder structure is tracked (if needed)
|
|
|
|
### Documentation Updates
|
|
- Update DEPLOYMENT.md with new config folder structure
|
|
- Update README.md with configuration setup instructions
|
|
- Add config/README.md explaining each config file's purpose
|
|
|
|
---
|
|
|
|
## Specific Ideas
|
|
|
|
1. **Config Files to Create:**
|
|
- `config/backend.env` — Backend-specific variables (database, AI keys, auth settings)
|
|
- `config/frontend.env` — Frontend-specific variables (API endpoints, feature flags)
|
|
- `config/network.env` — Network/deployment variables (ports, SSL, server IPs)
|
|
- `config/docker.env` — Docker-specific overrides (for docker-compose.yml)
|
|
- `config/README.md` — Documentation of all configuration files
|
|
|
|
2. **Scripts to Update:**
|
|
- `deploy.sh` — Update to source from config/ folder
|
|
- `run_standalone.sh` — Update network config loading
|
|
- `export_prod.sh` — Ensure it uses new config structure
|
|
- `install_service.sh` — Update systemd service to reference new config paths
|
|
- `__push_ALL_to_remote.sh` — Review for config-related updates
|
|
|
|
3. **Backend Changes:**
|
|
- `backend/config_loader.py` — Update load order: config/backend.env > inventory.env > env vars
|
|
- `backend/config_manager.py` — Update to read/write from config/backend.env
|
|
- `backend/entrypoint.sh` — Source from config/ instead of root level
|
|
|
|
4. **Testing Requirements:**
|
|
- Docker deployment with new config structure
|
|
- Standalone deployment with new config structure
|
|
- Environment variable override behavior still works
|
|
- Backward compatibility: old inventory.env still loads if config/ doesn't exist
|
|
|
|
---
|
|
|
|
## Deferred Ideas
|
|
|
|
- Dynamic config hot-reload without restart (future optimization)
|
|
- Config validation framework (future enhancement)
|
|
- Encrypted sensitive values in config files (future security enhancement)
|
|
- Web UI for configuration management (future feature)
|
|
|
|
---
|
|
|
|
*Phase: 7-config-consolidation*
|
|
*Context gathered: 2026-04-23 from user requirements*
|