SlideShare a Scribd company logo
1 of 138
Download to read offline
CQRS, REACTJS, DOCKERIN A NUTSHELL
Andrea GiulianoClaudio D'Alicandro Simone Di Maulo
NEW AMAZING
PROJECT
WE CAN WRITE IT
FROM SCRATCH
BUT
immagine manager incazzato
WE NEED IT IN A VERY FEW TIME
AND
IT SHOULD BE
WTF!
WHERE DO WE
START?
COMFORT ZONE
DOMAIN
▸ data come from and go to external entities
▸ users can configure to send a subset of data
▸ users send data based on their plan
send data from a source to a target
GOAL
THE DOMAIN
▸ unpredictable data structures
▸ ad hoc workflow for each vendor
▸ variable number of steps
▸ handle rate limits from different vendors
▸ handle different error cases from different vendors
▸ handle business-oriented limits (based on plans...)
▸ some tasks need to be done asynchronously
IDEA
BLACK BOX REASONING
▸ identify the main entities involved
▸ define a common input and output
▸ find a way to let things talk
INPUT OUTPUT
FROM
BLACK BOXES
TO
BOUNDED CONTEXTS
DEPENDENCIES INFRA BC
MODEL
APPLICATION
PRESENTATION
PROJECT DIRECTORY TREE
APP DIRECTORY TREE
INFRASTRUCTURE DIRECTORY TREE
INSIDE THE
BOUNDED CONTEXT
BC DIRECTORY TREE
BC APPLICATION DIRECTORY TREE
BC MODEL DIRECTORY TREE
BC PRESENTATION DIRECTORY TREE
EVERYTHING'S AWESOME
▸ the framework is an
implementation detail
▸ the directory structure is
explicit
▸ the domain is isolated
WE DON'T WANT TO
MESS THINGS UP
DON'T MESS UP THINGS
WHAT'S THE ISSUE HERE
▸ understandable?
▸ code can't be reused
▸ high coupling
▸ untestable
▸ too many responsibilities
▸ hard to find bugs
▸ not changes-prone
WHAT WE WANT
COMMAND QUERY
RESPONSIBILITY
SEGREGATIONAKA CQRS
A SOLUTION
CQRS
▸ separe reads from writes
▸ commands perform actions
▸ queries return data
▸ heterogeneous data storages
▸ easy scaling
▸ deal with eventual consistency
WRITE STORAGE
QUERY
COMMAND
COMMAND
COMMAND BUS
COMMAND HANDLER
DOMAIN
REPOSITORY
READ STORAGE
REPOSITORY
EVENT BUS
EVENT SUBSCRIBER
IT'S ALL ABOUT
BUSES
IT'S ALL ABOUT
BUSES COMMUNICATION
INTERNAL COMMUNICATION
BC
EVENT
COMMAND
MESSAGE BUS
$ composer require simple-bus/message-bus
COMMANDS
COMMAND BUS
Represent the change that should be done in the domain


They are named with a verb in the imperative tense and may include
the aggregate type, for example ScheduleATask.
COMMANDS
COMMAND BUS
CONTROLLER
$commandBus->handle(

ScheduleATask::fromTaskId($taskId)

);
HANDLER
public function handle(Command $command)

{

//do something with the $command

}
EVENTS
BC 1 BC 2
EVENT BUS
An event represents something that took place in
the domain. 



They are always named with a past-participle verb,
such as TaskScheduled
EVENTS
BC 1 BC 2
EVENT BUS
subscribes_to: 'user-created'
subscribes_to: 'task-stopped'
subscribes_to: 'task-suspended'
EVENTS
BC 1 BC 2
EVENT BUS
$messageBus->handle(

UserCreatedEvent::fromUser($user)

);
subscribes_to: 'user-created'
subscribes_to: 'task-stopped'
subscribes_to: 'task-suspended'
$messageBus->handle(

TaskSuspendedEvent::fromTask($task)

);
COMMUNICATION AMONG BCS
BC 1 BC 2
QUEUE
NETWORK
QUEUE
BC 1 BC 2
QUEUE
$producer->publish($message); $consumer->consume($message);
NETWORK
BC 1 BC 2
NETWORK
$httpClient->post('/tasks/schedule');
POST /tasks/schedule
SCENARIO: TRIGGER THE TASKS SCHEDULE EVERY 10 MINUTES
TIMER
SCENARIO: TRIGGER THE TASKS SCHEDULE EVERY 10 MINUTES
TIMER SCHEDULER
POST /tasks/schedule
SCENARIO: TRIGGER THE TASKS SCHEDULE EVERY 10 MINUTES
TIMER SCHEDULER
POST /tasks/schedule
DATA STORAGE
$taskRepository->getAll()
SCENARIO: TRIGGER THE TASKS SCHEDULE EVERY 10 MINUTES
TIMER SCHEDULER
POST /tasks/schedule
DATA STORAGE
$taskRepository->getAll()
TASK QUEUE
enqueue($taskId)
SCENARIO: TRIGGER THE TASKS SCHEDULE EVERY 10 MINUTES
TIMER SCHEDULER
POST /tasks/schedule
DATA STORAGE
$taskRepository->getAll()
TASK QUEUE
enqueue($taskId)
W1 W2 W3 W..N...
LET ME SEE WHAT
YOU HAVE DONE
IT'S TIME TO SHOW DOWN
WHAT THE TEAM HAS DELIVERED
WHAT THE MANAGEMENT SEE
WHAT THE MANAGEMENT WANTS
LET'S START FROM
THE TEMPLATE
TWIG
THE FRONTEND STUFF
THE FRONTEND STUFF
ORDER DEPENDENT
THE FRONTEND STUFF
GLOBAL SCOPE
<script>

$('.btn').click(function(e){

e.stopPropagation();



// Do something cool!



});

</script>
NEVER TRUST THE GLOBAL SCOPE
A STEP
BACKWARD
WE ARE BACKEND DEVELOPERS
OUR
COMFORT ZONE
OOP
ENCAPSULATION
MODULES
DEPENDENCY
INJECTION
GOOD NEWS
ECMASCRIPT 6
DEFAULT VALUES
CLASSES
INHERITANCE
CREATE YOUR MODULES
IMPORT A MODULE
IMPORT ONLY WHAT YOU NEED
WHAT ABOUT THE UI?
var React = require('react');

var ReactDOM = require('react-dom');
ReactDOM.render(

<h1>Hello, world!</h1>,

document.getElementById('app')

);
https://kangax.github.io/compat-table/es6/
ASSETIC CUSTOM FILTERS
ANOTHER STEP
BACKWARD
REMEMBER THE
BOUNDED CONTEXT
A LOT OF SMALL COMPONENTS
A LOT OF SMALL APPLICATIONS
BOUNDED CONTEXT FACEBOOK BOUNDED CONTEXT MAILCHIMPBOUNDED CONTEXT MAPPING
BOUNDED CONTEXT FACEBOOK BOUNDED CONTEXT MAILCHIMPBOUNDED CONTEXT MAPPING
Gulp Bundler
+
BOUNDED CONTEXT FACEBOOK BOUNDED CONTEXT MAILCHIMPBOUNDED CONTEXT MAPPING
DEVELOPMENT
WORKFLOW
$ docker/gulp
docker-compose run --rm --entrypoint bash npm -c "gulp"
// gulpfile.js

var gulp = require('gulp');

var hub = require('gulp-hub');
process

.env

.WEBPACK_CONFIG_FILE = path.join(

__dirname,

'webpack.config.js'

)

;
hub(['src/**/gulpfile.js']);
BOUNDED CONTEXT FACEBOOK BOUNDED CONTEXT MAILCHIMPBOUNDED CONTEXT MAPPING
gulpfile.js gulpfile.js gulpfile.js
BOUNDED CONTEXT FACEBOOK
gulpfile.js
"## FacebookPresentationBundle.php

$## Resources

"## assets

"## config

"## public

$## views
$ app/console assets:install
LET'S EXPOSE TO THE WEB
APPLICATION ENTRYPOINT
IT'S A BIG WORLD OUT THERE!
THE DEVELOPMENT ENVIRONMENT
▸ Easy to use so many technologies at no installation cost
▸ Prepare the scaffolding for a new developer is extremely
simple
▸ Superior performances over previous systems
docker-compose.yml docker-compose.dev.yml
THE INFRASTRUCTURE
THE INFRASTRUCTURE
THE INFRASTRUCTURE
THE INFRASTRUCTURE
THE INFRASTRUCTURE
VS
THE INFRASTRUCTURE
VS
STAGE
▸ Automate image building
▸ Copy the same structure used in dev
STAGE
▸ Automate image building
▸ Copy the same structure used in dev
AUFS: VOLUMES MIGHT BE A LITTLE HARDER THAN IT SEEMS
SYMFONY PARAMETERS
incenteev/composer-parameter-handler
DOCKER CLOUD REPOSITORY CONFIGURATION
DATA ONLY CONTAINER
DATA ONLY CONTAINER
DATA ONLY CONTAINER
DATA ONLY CONTAINER
FIRST DEPLOY
AN ELEPHANT IN THE ROOM... WE NEED
▸ Automated deploy strategy
▸ The freedom to easily scale
SCALE
$ docker-compose scale 
web=2 
worker=3
HARD TRUTH
fpm:
image: 'adespresso/hubespresso-staging:fpm-latest'
deployment_strategy: every_node
sequential_deployment: true
tags:
- fpm
- hubespresso
- production
volumes:
- /var/www/project
volumes_from:
- shared-fpm.hubespresso-production
SCALE CONTAINERS IS WORTHLESS IF YOU DO NOT SCALE NODES
HARD TRUTH
SCALE CONTAINERS IS WORTHLESS IF YOU DO NOT SCALE NODES
fpm:
image: 'adespresso/hubespresso-staging:fpm-latest'
deployment_strategy: every_node
sequential_deployment: true
tags:
- fpm
- hubespresso
- production
volumes:
- /var/www/project
volumes_from:
- shared-fpm.hubespresso-production
DATA ONLY CONTAINER IS A PAIN
DEPLOYMENT
▸ deploy the infrastructure is not straightforward
▸ multiple container in multiple nodes
▸ every container has its own lifecycle
▸ we are not assuring zero-downtime on deployment
THE SOLUTION: GREEN BLUE DEPLOYMENT
THE SOLUTION: GREEN BLUE DEPLOYMENT
THE SOLUTION: GREEN BLUE DEPLOYMENT
CONCLUSION
CQRSPHP7
DOCKER
REACTJS
MONGODBWEBPACK
GULP
LEAVE THE
COMFORT ZONE
THANKS
QUESTIONS?

More Related Content

Similar to Docker cqrs react

Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018
Ortus Solutions, Corp
 
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache KafkaSolutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Guido Schmutz
 
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
confluent
 
Reactive.architecture.with.Angular
Reactive.architecture.with.AngularReactive.architecture.with.Angular
Reactive.architecture.with.Angular
Evan Schultz
 
Couch db 浅漫游.
Couch db 浅漫游.Couch db 浅漫游.
Couch db 浅漫游.
shyboyzk
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
AOE
 

Similar to Docker cqrs react (20)

Into The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerInto The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and docker
 
Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018
 
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache KafkaSolutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
 
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
 
Zero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google CloudZero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google Cloud
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Reactive.architecture.with.Angular
Reactive.architecture.with.AngularReactive.architecture.with.Angular
Reactive.architecture.with.Angular
 
Deploying configurable frontend web application containers
Deploying configurable frontend web application containersDeploying configurable frontend web application containers
Deploying configurable frontend web application containers
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platforms
 
Couch db 浅漫游.
Couch db 浅漫游.Couch db 浅漫游.
Couch db 浅漫游.
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle Story
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
 
Web development tools { starter pack }
Web development tools { starter pack }Web development tools { starter pack }
Web development tools { starter pack }
 
High-Quality JavaScript
High-Quality JavaScriptHigh-Quality JavaScript
High-Quality JavaScript
 
The Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build ScriptThe Fairy Tale of the One Command Build Script
The Fairy Tale of the One Command Build Script
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with Karma
 
Solutions for bi-directional integration between Oracle RDBMS & Apache Kafka
Solutions for bi-directional integration between Oracle RDBMS & Apache KafkaSolutions for bi-directional integration between Oracle RDBMS & Apache Kafka
Solutions for bi-directional integration between Oracle RDBMS & Apache Kafka
 
Play With Docker
Play With DockerPlay With Docker
Play With Docker
 
Workshop Consul .- Service Discovery & Failure Detection
Workshop Consul .- Service Discovery & Failure DetectionWorkshop Consul .- Service Discovery & Failure Detection
Workshop Consul .- Service Discovery & Failure Detection
 

Recently uploaded

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 

Recently uploaded (20)

Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 

Docker cqrs react