Top Banner
Applying Domain Driven Design to APIs and Microservices James Higginbotham @launchany
50

Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

May 05, 2018

Download

Documents

dodiep
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

ApplyingDomainDrivenDesigntoAPIsandMicroservices

JamesHigginbotham@launchany

Page 2: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

YourAPItellsastoryandcreatesaconversa3onbetween

youandtheworld

Page 3: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices
Page 4: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices
Page 5: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

AgreatAPIdesignstrategyiscri3calforAPIproductadop3onandsustainableapplica3on

development

Page 6: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices
Page 7: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

YourAPIdesignisacontractwithyourAPIconsumers.Itis“missioncri3cal”tothem.

Page 8: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices
Page 9: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

YourAPIdesigniscomposedofthecapabili3es(or“skills”)youoffertodevelopers

Page 10: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

APISkills==“Iwantto…”

Page 11: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

WhatskillsdoyourAPIsneedtooffer?

Page 12: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

Outside-InAPIDesignApproachWeb

Applica3on

APIDesign–“TheContract”

InternalApplica3onAPIConsumer Mobile

Applica3on

Page 13: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

APIDesignisanarchitecturalconcernthatcombinesbusiness,productdesign,andsoKware

engineering

Page 14: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices
Page 15: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

LackofModularizaIon=Regret

VS

Purpose-Based Module-Based

Page 16: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

Highcohesioninternallyforclosely-relatedfuncIonality

Loosecouplingexternallyacrossmoduleswithoutinternaldetails

HighCohesion+LooseCoupling

Page 17: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

package package

public

PublicAPIsencourageloosecouplingbetweenmodules

API

Scopingrulesrestrictaccessoutsideofmodules

X

API-CentricSoPwareDesign

Page 18: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

SystemsDesignSystem

Subsystem Subsystem

Module Module

Module Module

Subsystem Subsystem

Module Module

Page 19: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

LEGOasModularSystemDesign

System

Subsystems

Modules

Page 20: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

API

API

API

System/SoluIon

Subsystem Subsystem

Subsystem

Module ModuleModule Module

Module ModuleModule Module

Module ModuleModule Module

Module Module

Module Module

Page 21: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

Domain-DrivenDesignhelpswithiden3fyingcontext

boundariesforcomplexAPIs

Page 22: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

DomainDrivenDesign(DDD)

u MapsdomainconceptsintosoPwareu Heavydomainexpertinvolvementu  Commonvocabulary(“UbiquitousLanguage”)u  Boundary-driven(“BoundedContext”)u ApplylearningoverIme

Page 23: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices
Page 24: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices
Page 25: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

“Ineedtomul3plytwonumberstogether.So,Iambuildingamicroservicearchitecture.”-almosteveryonetoday

Page 26: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

MicroserviceArchitecture

u  Loosely-coupled,service-orientedarchitectureu  ApplyboundedcontexttolimitcogniIveloadu  IndependentlydeployableviaautomaIonu  EnablereplaceabilityandexperimentaIonu  Encouragecomposabilityofthebusinessu  Bestforlargeteams,orco-locateddisparatedata

Page 27: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

ApplyingSystemsDesignandDomain-DrivenDesigntofindAPIboundaries

andresources

Page 28: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices
Page 29: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

ListAvailInventory

DistributorAddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

PointOfSale

RemoveProduct

Customer

Operator

Operator

Page 30: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

OrderMgmtListAvailInventory

DistributorAddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

Operator

PointOfSale

RemoveProduct

Customer

Operator

InventoryMgmt

Fulfillment

Page 31: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

EachsubsystemhasanAPIthatexposesoneormoreendpoints

Page 32: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

OrderAPIListAvailInventory

DistributorAddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

PointOfSale

RemoveProduct

Customer

Operator

InventoryAPI

FulfillmentAPI

Operator

Page 33: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

Iden3fyingproductopportuni3esbecomeseasierwhenwehaveboundariesaroundtheAPIs

Page 34: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

OrderAPIListAvailInventory

DistributorAddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

Operator

RemoveProduct

InventoryAPI

FulfillmentAPI

#1 #2`

PointOfSale

Page 35: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

ForeveryAPI,ask:“Whatresourceswillitoffer?”

Page 36: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

Usedomain-drivendesigntofindbusinessen33es,rela3ons,statetransi3ons,andevents

Page 37: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

OrderAPIListAvailInventory

AddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

RemoveProduct

InventoryAPI

FulfillmentAPI

Page 38: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

OrderAPI

ProductAvailabiliIes

Orders

ProductInventory

Bookings

InventoryAPI

FulfillmentAPI

SameenIty(Products),Conceptuallydifferentto

theAPIcontext!

Page 39: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

Availabili3es-product

-date(s)avail-qtyavail

Orders-bookings-ordertotal

Products-name

-availschedule

Bookings-product-date(s)-status

Page 40: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

Availabili3es-product

-date(s)avail-qtyavail

availabilityChanged()

Orders

-bookings-ordertotal

created()updated()

Products-name

-availschedule

created()removed()updated()

Bookings-product-date(s)-Status

redeemed()cancelled()

Page 41: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

Availabili3es-product

-date(s)avail-qtyavail

availabilityChanged()

Orders

-bookings-ordertotal

created()updated()

Products-name

-availschedule

created()removed()updated()

Bookings-product-date(s)-status

redeemed()cancelled()

OrderAPI InventoryAPI

FulfillmentAPI

Page 42: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

MapResourcestotheAPI

Page 43: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

APIcomposabilityusingmicroservices

Page 44: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

PublicAPIstargetdurabilitythroughexternalcontracts

MicroserviceAPIstarget

evoluIonthroughexperimentaIonPhotoCredit:h,ps://www.flickr.com/photos/libel_vox

Page 45: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

Availabili3esService

OrdersService

ProductsService

BookingsService

OrdersHTTPAPI

InventoryHTTPAPI

FulfillmentHTTPAPI

Page 46: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

Availabili3esService

OrdersService

ProductsService

BookingsService

OrdersHTTPAPI

InventoryHTTPAPI

FulfillmentHTTPAPI

PaymentService

RefundService

Page 47: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

Alexa

VoiceSkill

API

Gatew

ay

API

Gatew

ay

Messaging

…Microservice

API

…Microservice

API

…Microservice

API

…Microservice

…AP

I

Slack

Chatbo

tWeb

+

Mob

ileApp

API

Gatew

ay

MicroserviceArchitecture

Page 48: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

MigraIngtoMicroservices1.  UseAPIFacadestodefineclearinterfaces2.  Separatecomplexconcernsintoseparate

services3.  UseServiceObjectPaeerntodecompose4.  Buildanautomateddeploymentpipeline5.  Migrateserviceobjectstomicroservices

Page 49: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

TheComposableWorldofAPIs

Offers API

Inventory API

Bookings API

Identity API

Accounts API

Rewards API

Partners

Internal Developers

Public App Developers

Consumers

Third-party Approved Apps

Page 50: Applying Domain Driven Design to APIs and Microservicesschd.ws/hosted_files/apiworld2016/dc/Designing APIs Microservices... · Applying Domain Driven Design to APIs and Microservices

ThankyouJamesHigginbotham

@launchanyhep://bit.ly/api-skills