Skip to main content

Architecture Overview

Domain-Driven Design

Both the plugin and theme follow DDD principles with clear layer separation.

Plugin Layers

wp-ecommerce-core/src/
├── Domain/
│ ├── Entities/ # Product, Order, Customer, Invoice, etc.
│ ├── ValueObjects/ # Money, Address, SKU, etc.
│ └── Repositories/ # Repository interfaces
├── Application/
│ └── Services/ # OrderService, StockService, etc.
├── Infrastructure/
│ ├── Persistence/ # MySQL repository implementations
│ └── Gateways/ # Payment, Shipping, myDATA gateways
└── Presentation/
└── Api/ # REST API controllers

Theme Layers

flavor-starter/inc/
├── core/
│ ├── Bootstrap.php # Singleton, DDD boot
│ ├── Container.php # DI container
│ └── helpers.php # 21 infrastructure functions
├── modules/
│ ├── ModuleManager.php
│ └── [module-name]/ # Each module is self-contained
└── translations.php # Translation system

Dependency Injection

Both products use a custom DI container with auto-wiring:

// Register a service
$container->singleton(OrderService::class, function ($c) {
return new OrderService(
$c->make(OrderRepository::class),
$c->make(PaymentGateway::class)
);
});

// Resolve a service
$orderService = $container->make(OrderService::class);

Database Architecture

Plugin Tables ({prefix}ec_*)

TablePurpose
ec_productsProduct catalog
ec_variantsProduct variants (size, color)
ec_ordersOrder records
ec_order_itemsOrder line items
ec_customersCustomer data
ec_optionsPlugin configuration
ec_cachePlugin cache layer
ec_invoicesERP invoices
ec_stock_movementsInventory tracking
ec_journal_entriesAccounting ledger

Theme Tables ({prefix}flavor_*)

TablePurpose
flavor_optionsTheme configuration
flavor_cacheTheme cache layer
flavor_translationsUI translations

Entry Points

Plugin

// wp-ecommerce-core/wp-ec.php (line 1)
// → includes/Bootstrap.php (Singleton init)
// → Container registration
// → Service providers loaded
// → REST API routes registered

Theme

// flavor-starter/functions.php
// → inc/core/Bootstrap.php (Singleton init)
// → Module Manager loads active modules
// → Flavor Options settings registered