Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

πŸ—οΈ ARCHITECTURE: Component Installation System RefactorΒ #76

@jordanpartridge

Description

@jordanpartridge

Refactor component installation architecture to eliminate main composer.json pollution and implement proper component isolation with git-tag based versioning.

🚨 Current Problem

The current component installation system has critical architectural flaws identified in PR #75 analysis:

Issues:

  • ❌ Components modify main composer.json via composer require
  • ❌ Dual storage anti-pattern (JSON + database registry)
  • ❌ Components ship with core Conduit product
  • ❌ No proper versioning or rollback capability
  • ❌ Security vulnerabilities in package installation

🎯 Proposed Architecture: Isolated Component System

Component Isolation Pattern:

conduit/
β”œβ”€β”€ composer.json ← Clean\! Only core dependencies
β”œβ”€β”€ vendor/ ← Only core dependencies  
└── conduit-components/
    β”œβ”€β”€ components.json ← Version registry
    β”œβ”€β”€ env-manager/           ← Git repo at specific tag
    β”‚   β”œβ”€β”€ .git/
    β”‚   β”œβ”€β”€ composer.json      ← Component's own deps
    β”‚   β”œβ”€β”€ vendor/            ← Isolated component deps
    β”‚   └── src/
    └── docker/                ← Git repo at specific tag
        β”œβ”€β”€ .git/
        β”œβ”€β”€ composer.json
        β”œβ”€β”€ vendor/
        └── src/

Version Registry System:

{
  "registry": {
    "env-manager": {
      "package": "jordanpartridge/conduit-env-manager",
      "version": "v1.2.3",
      "git_url": "https://github.com/jordanpartridge/conduit-env-manager.git",
      "installed_at": "2025-01-28T10:30:00Z",
      "status": "active"
    }
  }
}

πŸ”§ Implementation Plan

Phase 1: Git-Tag Based Installation

class ComponentInstaller
{
    public function install(string $componentName, string $version = 'latest'): ComponentResult
    {
        // 1. Resolve version to specific tag
        $resolvedVersion = $this->resolveVersion($componentName, $version);
        
        // 2. Clone component at specific tag
        $componentPath = $this->cloneComponent($componentName, $resolvedVersion);
        
        // 3. Run composer install in component directory  
        $this->installComponentDependencies($componentPath);
        
        // 4. Register in local registry
        $this->registerComponent($componentName, $resolvedVersion);
        
        // 5. Register autoloader
        $this->registerComponentAutoloader($componentPath);
    }
}

Phase 2: Version Resolution

// Support composer-like version constraints
conduit components install env-manager          // latest
conduit components install env-manager@v1.2.3   // exact
conduit components install env-manager@^1.0     // semver range
conduit components install env-manager@~1.2.0   // patch range

Phase 3: Runtime Component Loading

class ComponentLoader
{
    public function loadActiveComponents(): void
    {
        foreach ($this->getActiveComponents() as $component) {
            $componentPath = base_path("conduit-components/{$component}");
            
            // Load component's isolated autoloader
            $autoloadFile = "{$componentPath}/vendor/autoload.php";
            if (file_exists($autoloadFile)) {
                require_once $autoloadFile;
            }
            
            // Register service provider
            $this->app->register($component['service_provider']);
        }
    }
}

βœ… Benefits

  • βœ… Clean Core: Main composer.json never touched
  • βœ… Proper Versioning: Git tags with semver support
  • βœ… Isolated Dependencies: Each component manages its own deps
  • βœ… Easy Updates: git fetch && git checkout v1.3.0
  • βœ… Rollback Capability: Switch between any tagged version
  • βœ… True Microkernel: Components are completely optional
  • βœ… Security: No main project pollution

🎯 User Experience

# Clean, familiar commands
conduit components install env-manager@^1.0
conduit components update env-manager
conduit components list
conduit components remove env-manager

# Version-aware operations
conduit components history env-manager
conduit components rollback env-manager v1.1.0

πŸ” Security Improvements

  • Remove hardcoded package whitelist
  • Implement proper path validation
  • Add component signing verification
  • Comprehensive input sanitization

πŸ“‹ Acceptance Criteria

  • Git-tag based component installation
  • Semantic version resolution (^1.0, ~1.2.0)
  • Isolated component dependencies
  • Runtime autoloader registration
  • Component update/rollback commands
  • Clean main composer.json (never modified)
  • Migration path from current system
  • Comprehensive security improvements

πŸ”— Dependencies

⚠️ Breaking Changes

This will require migrating existing component installations. Plan proper migration strategy and documentation.


Priority: High - Foundational architecture that enables proper component ecosystem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions