Project Context
A UK green energy provider (100Green.com) needed to migrate from an outdated .NET website to a more affordable hosting solution. The sales department sold them WordPress, but WordPress's architecture isn't ideal for complex business logic. The challenge: separate business logic from the delivery mechanism (WordPress) while maintaining the client's requirement.
Technical Challenge
The client's CRM provides raw tariff data via API based only on postal code. The system needed to calculate complex tariff rates (Day Rate, Night Rate, Standing Charge, Estimated Monthly Spend) based on multiple variables: energy type (gas, electricity, or both), smart meter (yes/no), 2-rate-meter (yes/no), and consumption type (low, medium, high, or custom usage). The CRM couldn't perform these calculations—we had to build a domain calculator that processes raw data using specific business formulas.
Architectural Solution
Instead of coupling everything to WordPress's spaghetti architecture, we designed a solution that separates bounded contexts from the delivery mechanism:
- • WordPress API plugin: A module that creates endpoints to receive requests only from our domain (with proper security mechanisms to prevent cross-domain requests)
- • Raw PHP libraries (framework-free): Vertical sliced structures with Application layer (use cases), Domain layer (policies, interfaces, contracts), and Infrastructure layer (specific implementations)
- • React application embedded in WordPress: A calculator that communicates with our custom API, which contains all business rules abstracted in our libraries that consult the client's CRM
- • Stability rule principle: The most stable modules (business libraries) are furthest from the most volatile (React frontend), creating a clear separation between presentation and business logic
Results
Minimal friction with WordPress: only a React app embedded in the DOM of a WordPress page. The rest is pure business logic, properly separated. The system demonstrates how to apply DDD, hexagonal architecture, bounded contexts, and service-oriented architecture principles even when constrained by a delivery mechanism like WordPress.
Technologies
- • WordPress (delivery mechanism)
- • Raw PHP (framework-free)
- • React
- • Domain-Driven Design
- • Hexagonal Architecture
- • Vertical Sliced Structures
- • Stability Rule Principle
Key Achievements
- • Complete separation of business logic from WordPress delivery mechanism
- • Domain calculator independent of infrastructure
- • Vertical sliced architecture with clear boundaries
- • Stability rule applied: stable modules protected from volatile frontend