-
Notifications
You must be signed in to change notification settings - Fork 0
Description
📋 Overview
Move the src/domain/config/ module to src/application/command_handlers/create/config/ to align with DDD principles and improve code organization.
Current Location (Incorrect):
src/domain/config/
Target Location (Correct):
src/application/command_handlers/create/config/
🎯 Problem
The config module is currently misplaced in the domain layer, violating Domain-Driven Design principles:
- Serialization concerns in domain: Uses
serde::Deserializefor JSON parsing (data transfer concern, not business logic) - Infrastructure operations in domain: Contains
generate_template_file()withtokio::fsI/O operations - String-based primitives: Uses raw
Stringtypes instead of domain value objects (EnvironmentName,Username) - Acts as DTO: Converts external formats to domain types via
to_environment_params()- this is application layer responsibility - Low cohesion: Exclusively used by create command but separated from it by layer boundaries
✅ Solution
Move config module to be nested under the create command handler for:
- ✅ DDD compliance: Removes DTOs from domain layer
- ✅ Higher cohesion: Config lives with its only consumer
- ✅ Clearer boundaries: Domain remains pure business logic
- ✅ Better discoverability: All create command code in one place
- ✅ No premature abstraction: No generic
dto/folder for single use
📚 Documentation
Full refactoring plan with detailed implementation checklist:
👉 docs/refactors/plans/move-config-to-create-command.md
📝 Implementation Steps
The plan includes 9 major steps:
- Create new directory structure
- Move all 4 files (
mod.rs,environment_config.rs,ssh_credentials_config.rs,errors.rs) - Update module declarations
- Update imports in application layer (5 files)
- Update imports in presentation layer (3 files)
- Update imports in testing utilities (1 file)
- Update documentation and doc examples
- Clean up old directory
- Comprehensive verification (build, test, lint, doc)
🧪 Testing
- All existing tests must continue to pass
- No behavior changes, only import path updates
- Verification includes:
cargo build,cargo test, linters, documentation
🏗️ Architecture
This refactoring aligns with the project's DDD architecture where:
- Domain Layer: Pure business logic, entities, value objects
- Application Layer: Use cases, command handlers, DTOs
- Presentation Layer: CLI, user interaction, config loading
- Infrastructure Layer: External tools, file system, SSH
The config module is a DTO layer for the create command use case, hence belongs in application layer.
⏱️ Estimated Effort
Time: 1-2 hours
Complexity: Medium (multiple file moves, import updates)
Risk: Low (no behavior changes, only structural)