← Back to Case Studies

ETL middleware: Framework-independent product generation for e-commerce

Project Context

A B2B project for a textile retailer focused on integrating analytical data exposed through Power BI into multiple Magento storefronts. Rather than treating Magento as the core of the business logic, the decision was made to externalize and centralize the domain complexity in a dedicated middleware, positioning Magento as a downstream consumer responsible only for commerce execution. This approach allowed the system to evolve independently from Magento's internal data model and import mechanisms.

Technical Challenge

The main challenge was the Transform phase of the ETL process, where analytical data needed to be converted into complete commercial products.

This required:

  • • Interpreting Power BI datasets
  • • Applying complex and evolving business rules
  • • Generating full product definitions: attributes and attribute sets, configurable products and variations, pricing logic and textile-specific constraints

Given the critical nature of this logic, correctness, predictability, and testability were as important as functional completeness.

Architectural Solution

The solution was a custom ETL middleware built using Domain-Driven Design and Hexagonal Architecture (Ports & Adapters).

  • • Hexagonal core and framework independence: At the center lies a pure domain layer, free of framework and infrastructure dependencies. The Domain defines entities and Value Objects, Use Cases representing ETL transformations, and Output contracts (Ports) describing transformation results. Infrastructure concerns are pushed outward and connected through adapters, ensuring the domain remains stable even if the surrounding technology changes.
  • • Ports, Adapters, and controlled side effects: All external interactions are handled through Ports defined in the Domain and Adapters implemented in the Infrastructure layer. This approach allows multiple concrete implementations, seamless replacement of frameworks (Laravel, Symfony, etc.), and controlled and explicit side effects. Dependency Injection recipes wire the system together without leaking infrastructure into the domain.
  • • ETL as a domain-driven workflow: The ETL process was modeled as a business workflow, not a technical script: data extraction and normalization into DTOs, execution of domain Use Cases, application of business rules, and emission of normalized Results via the Result Pattern. Magento importers consume these results asynchronously via cron jobs.

Testing & Quality Strategy

Testing and quality were first-class concerns, directly enabled by the hexagonal architecture.

  • • Domain-level testing: The Domain layer is fully testable in isolation. No framework bootstrapping required, no database, filesystem, or external services involved. Tests focus on business rules, transformation correctness, edge cases and validation scenarios.
  • • Adapter substitution for tests: Simplified or fake adapters were injected during tests. Infrastructure behavior could be simulated deterministically, allowing fast and reliable test execution.
  • • Result-driven validation: The use of the Result Pattern made outcomes explicit. Tests could assert successful transformations, partial successes with warnings, and business validation errors. This eliminated ambiguity and reduced reliance on side effects or logs.
  • • Confidence in change: Because business logic was isolated, deterministic, and covered by focused tests, the system could evolve safely, even as business rules changed frequently.

Results

The architecture achieved strong decoupling between business logic and e-commerce platforms, full framework independence at the domain level, high testability enabling confident refactoring, and a scalable architecture suitable for multi-channel growth. The system could evolve safely as business rules changed, with tests providing immediate feedback on correctness.

Technologies

  • • PHP 7/8
  • • Domain-Driven Design (DDD)
  • • Hexagonal Architecture (Ports & Adapters)
  • • ETL Architecture
  • • Use Cases Pattern
  • • DTOs & Result Pattern
  • • Dependency Injection Containers (DIC)
  • • Magento 2
  • • Power BI
  • • Cron-based import pipelines

Key Achievements

  • • Complete decoupling between business logic and e-commerce platforms
  • • Framework-independent domain core with zero infrastructure dependencies
  • • Hexagonal architecture enabling multiple infrastructure implementations
  • • ETL process modeled as domain-driven business logic
  • • Scalable architecture suitable for multi-channel growth
Discuss Your Project