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

API:World 2016 - Applying Domain Driven Design to APIs and Microservices

Embed Size (px)

Citation preview

ApplyingDomainDrivenDesigntoAPIsandMicroservices

JamesHigginbotham@launchany

YourAPItellsastoryandcreatesaconversa3onbetween

youandtheworld

AgreatAPIdesignstrategyiscri3calforAPIproductadop3onandsustainableapplica3on

development

YourAPIdesignisacontractwithyourAPIconsumers.Itis“missioncri3cal”tothem.

YourAPIdesigniscomposedofthecapabili3es(or“skills”)youoffertodevelopers

APISkills==“Iwantto…”

WhatskillsdoyourAPIsneedtooffer?

Outside-InAPIDesignApproachWeb

Applica3on

APIDesign–“TheContract”

InternalApplica3onAPIConsumer Mobile

Applica3on

APIDesignisanarchitecturalconcernthatcombinesbusiness,productdesign,andsoKware

engineering

LackofModularizaIon=Regret

VS

Purpose-Based Module-Based

Highcohesioninternallyforclosely-relatedfuncIonality

Loosecouplingexternallyacrossmoduleswithoutinternaldetails

HighCohesion+LooseCoupling

package package

public

PublicAPIsencourageloosecouplingbetweenmodules

API

Scopingrulesrestrictaccessoutsideofmodules

X

API-CentricSoPwareDesign

SystemsDesignSystem

Subsystem Subsystem

Module Module

Module Module

Subsystem Subsystem

Module Module

LEGOasModularSystemDesign

System

Subsystems

Modules

API

API

API

System/SoluIon

Subsystem Subsystem

Subsystem

Module ModuleModule Module

Module ModuleModule Module

Module ModuleModule Module

Module Module

Module Module

Domain-DrivenDesignhelpswithiden3fyingcontext

boundariesforcomplexAPIs

DomainDrivenDesign(DDD)

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

“Ineedtomul3plytwonumberstogether.So,Iambuildingamicroservicearchitecture.”-almosteveryonetoday

MicroserviceArchitecture

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

ApplyingSystemsDesignandDomain-DrivenDesigntofindAPIboundaries

andresources

ListAvailInventory

DistributorAddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

PointOfSale

RemoveProduct

Customer

Operator

Operator

OrderMgmtListAvailInventory

DistributorAddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

Operator

PointOfSale

RemoveProduct

Customer

Operator

InventoryMgmt

Fulfillment

EachsubsystemhasanAPIthatexposesoneormoreendpoints

OrderAPIListAvailInventory

DistributorAddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

PointOfSale

RemoveProduct

Customer

Operator

InventoryAPI

FulfillmentAPI

Operator

Iden3fyingproductopportuni3esbecomeseasierwhenwehaveboundariesaroundtheAPIs

OrderAPIListAvailInventory

DistributorAddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

Operator

RemoveProduct

InventoryAPI

FulfillmentAPI

#1 #2`

PointOfSale

ForeveryAPI,ask:“Whatresourceswillitoffer?”

Usedomain-drivendesigntofindbusinessen33es,rela3ons,statetransi3ons,andevents

OrderAPIListAvailInventory

AddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

RemoveProduct

InventoryAPI

FulfillmentAPI

OrderAPI

ProductAvailabiliIes

Orders

ProductInventory

Bookings

InventoryAPI

FulfillmentAPI

SameenIty(Products),Conceptuallydifferentto

theAPIcontext!

Availabili3es-product

-date(s)avail-qtyavail

Orders-bookings-ordertotal

Products-name

-availschedule

Bookings-product-date(s)-status

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()

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

MapResourcestotheAPI

APIcomposabilityusingmicroservices

PublicAPIstargetdurabilitythroughexternalcontracts

MicroserviceAPIstarget

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

Availabili3esService

OrdersService

ProductsService

BookingsService

OrdersHTTPAPI

InventoryHTTPAPI

FulfillmentHTTPAPI

Availabili3esService

OrdersService

ProductsService

BookingsService

OrdersHTTPAPI

InventoryHTTPAPI

FulfillmentHTTPAPI

PaymentService

RefundService

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

MigraIngtoMicroservices1.  UseAPIFacadestodefineclearinterfaces2.  Separatecomplexconcernsintoseparate

services3.  UseServiceObjectPaeerntodecompose4.  Buildanautomateddeploymentpipeline5.  Migrateserviceobjectstomicroservices

TheComposableWorldofAPIs

Offers API

Inventory API

Bookings API

Identity API

Accounts API

Rewards API

Partners

Internal Developers

Public App Developers

Consumers

Third-party Approved Apps

ThankyouJamesHigginbotham

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