This document provides an overview of the architecture of Yves & Zed, an e-commerce platform. It discusses the following key points:
1. Yves & Zed uses a layered architecture with bundles and packages to structure code and composer to manage dependencies between packages.
2. It features a state machine powered by events and commands to automatically process orders, with visualizations of the business logic.
3. The platform also includes a data warehouse for big data with an ETL process, job scheduling, and order status mapping to dimensions for analysis and reporting.
3. Who?
Fabian Wesner
$year >= 2012 CTO @ Project A Ventures
$year == 2011 CTO @ Rocket Internet
$year == 2010 Lead developer @ Zalando
$year <= 2009 Entrepreneur and Freelancer
Project A Ventures
Building successful companies.
Company Builder with focus on Internet, advertising technology and
mobile.
www.project-a.com
9. Dependency management with composer
- Code is structured in packages
- Packages may require each other
- We use composer to manage dependencies
composer.json of dwh-package
{
"name": "project-a/dwh-package",
"autoload": {
"psr-0": { "ProjectA": "/src" }
},
"require": {
"php": ">=5.4.0",
"project-a/auth-package": ">=0.0.10",
"project-a/library-package": ">=0.0.27"
}
}
How to update Yves & Zed?
(1) add a new version to a composer.json
(2) run php composer.phar install
19. Visualization of business logic
protected function addTransitions()
{
$this->setup->addTransition(
self::STATE_NEW,
self::STATE_PREAUTHORIZED,
self::EVENT_START_PAYMENT,
self::RULE_PAYMENT_TRANSACTION_APPROVED);
$this->setup->addTransition(
self::STATE_NEW,
self::STATE_INVALID,
self::EVENT_START_PAYMENT);
}
protected function addCommands()
{
$preAuthorizeCommand = $this->factory
->getModelOrderprocessCommandPaymentPreAuthorization();
$this->setup->addCommand(
self::STATE_NEW,
self::EVENT_START_PAYMENT,
$preAuthorizeCommand);
}
protected function addDefinitions()
{
$subProcess = $this->factory
->getModelOrderprocessDefinitionSubProcessCancellation()
$this->setup->addDefinition($subProcess);
}
PHP
Graph
20. Automatic processing of thousands of orders per day
Trigger events
Used in several controllers to start the state machine
$this->facadeSales->triggerEvent(„start payment“,items);
$this->facadeSales->triggerEventBulk($eventName,items);
Commands
Classes with logic which are triggered from the state machine
class SaoZedPaymentComponentCommand
PreAuthorization
{
public function __invoke ($orderEntity, $context)
{ ... }
}
Check conditions
Decision which way to go
class SaoZedPaymentComponentCondition
TransactionApproved
{
/** @return bool */
public function check($orderItem, $context)
{ ... }
}
+++ More details: Talk of Oliver Tischlinger tomorrow „Statemachine – Das Mittel gegen Flags!“ +++
22. ETL / job scheduler
<job id="load-order-item-status">
<description>Copies the order item status table into the tmp table
</description>
<commands>
<run-sql-file
file-name="order-statuses/create-order-item-status-tmp-table.sql"
echo-queries="false"/>
<load-from-mysql mysql-database="zed"
file-name="order-statuses/load-order-item-status.sql"
target-table="tmp.order_item_status"/>
</commands>
</job>
<job id="transform-order-item-status">
<description>Copies the order item status table into the dim schema
</description>
<dependencies>
<dependency job="load-order-item-status"/>
<dependency job="load-order-item-status-mapping"/>
</dependencies>
<commands>
<run-sql-file
file-name="order-statuses/transform-order-item-status.sql"
echo-queries="false"/>
</commands>
</job>
23. Order status mapping
Every color has a
simple meaning!
Not paid
Item returned
Paid
etc.
<perspective name="Sales">
<status-group name="Not paid"
description="The items are not yet paid"
color="#557799">
<status ref="shipped"/>
<status ref="waiting for payment"/>
<status ref="capture"/>
</status-group>
<status-group name="Paid"
description="The items are paid"
color="#559955">
<status ref="paid in money collect"/>
<status ref="clarify refund overpayment"/>
<status ref="closed"/>
</status-group>
</perspective>
</status-mapping>