Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Applying	Domain	Driven	Design	to	
APIs	and	Microservices	
James	Higginbotham	
@launchany
Your	API	tells	a	story	and	
creates	a	conversa3on	between	
you	and	the	world
A	great	API	design	strategy	is	
cri3cal	for	API	product	adop3on	
and	sustainable	applica3on	
development
Your	API	design	is	a	contract	
with	your	API	consumers.	It	is	
“mission	cri3cal”	to	them.
Your	API	design	is	composed	of	
the	capabili3es	(or	“skills”)		
you	offer	to	developers
API	Skills	==	“I	want	to…”
What	skills	do	your		
APIs	need	to	offer?
Outside-In	API	Design	Approach	
Web	
Applica3on	
API	Design	–	“The	Contract”	
Internal	
Applica3on	
API	Consumer	
Mobile	
...
API	Design	is	an	architectural	
concern	that	combines	business,	
product	design,	and	soKware	
engineering
Lack	of	ModularizaIon	=	Regret	
VS	
Purpose-Based	 Module-Based
High	cohesion		
internally	for		
closely-related	
funcIonality	
Loose	coupling		
externally	across	
modules	without	
inter...
package	 package	
public	
Public	APIs		
encourage	
loose	coupling	
between	modules	
API	
Scoping	rules	
restrict	access	
o...
Systems	Design	
System	
Subsystem	 Subsystem	
Module	 Module	
Module	 Module	
Subsystem	 Subsystem	
Module	 Module
LEGO	as	Modular	System	Design	
System	
Subsystems	
Modules
API	
API	
API	
System/SoluIon	
Subsystem	 Subsystem	
Subsystem	
Module	 Module	
Module	 Module	
Module	 Module	
Module	 Mo...
Domain-Driven	Design	helps	
with	iden3fying	context	
boundaries	for	complex	APIs
Domain	Driven	Design	(DDD)	
u  Maps	domain	concepts	into	soPware	
u  Heavy	domain	expert	involvement	
u  Common	vocabulary...
“I	need	to	mul3ply	two	numbers	
together.	So,	I	am	building	
a	microservice	architecture.”	
-	almost	everyone	today
Microservice	Architecture	
u  Loosely-coupled,	service-oriented	architecture	
u  Apply	bounded	context	to	limit	cogniIve	l...
Applying	Systems	Design	
and	Domain-Driven	Design	
to	find	API	boundaries		
and	resources
List	Avail	
Inventory	
Distributor	
Add	Product	
to	Order	
Complete	
Order	
Cancel	
Booking	
Add	Product	
to	Inventory	
Up...
Order	Mgmt	
List	Avail	
Inventory	
Distributor	
Add	Product	
to	Order	
Complete	
Order	
Cancel	
Booking	
Add	Product	
to	I...
Each	subsystem	has	an	API	that	
exposes	one	or	more	endpoints
Order	API	
List	Avail	
Inventory	
Distributor	
Add	Product	
to	Order	
Complete	
Order	
Cancel	
Booking	
Add	Product	
to	In...
Iden3fying	product	opportuni3es	
becomes	easier	when	we	have	
boundaries	around	the	APIs
Order	API	
List	Avail	
Inventory	
Distributor	
Add	Product	
to	Order	
Complete	
Order	
Cancel	
Booking	
Add	Product	
to	In...
For	every	API,	ask:		
“What	resources	will	it	offer?”
Use	domain-driven	design	to	
find	business	en33es,	rela3ons,	
state	transi3ons,	and	events
Order	API	
List	Avail	
Inventory	
Add	Product	
to	Order	
Complete	
Order	
Cancel	
Booking	
Add	Product	
to	Inventory	
Upda...
Order	API	
Product	
AvailabiliIes	
Orders	
Product	
Inventory	
Bookings	
Inventory	API	
Fulfillment	API	
Same	enIty	(Produc...
Availabili3es	
-	product	
-	date(s)	avail	
-	qty	avail	
	
Orders	
-	bookings	
-	order	total	
Products	
-	name	
-	avail	sch...
Availabili3es	
-	product	
-	date(s)	avail	
-	qty	avail	
	
availabilityChanged()	
	
Orders	
-	bookings	
-	order	total	
crea...
Availabili3es	
-	product	
-	date(s)	avail	
-	qty	avail	
	
availabilityChanged()	
	
Orders	
-	bookings	
-	order	total	
	
cr...
Map	Resources	to	the	API
API	composability	using	
microservices
Public	APIs	target	durability	
	through	external	contracts	
	
Microservice	APIs	target	
evoluIon	through	
experimentaIon	P...
Availabili3es	Service	
	
Orders	Service	
Products	Service	
Bookings	Service	
Orders	HTTP	API	
Inventory	HTTP	API	
Fulfillme...
Availabili3es	Service	
	
Orders	Service	
Products	Service	
Bookings	Service	
Orders	HTTP	API	
Inventory	HTTP	API	
Fulfillme...
Alexa		
Voice	Skill	
API	
Gateway	
API	
Gateway	
Messaging	
…	
Microservice	
…	
API	
…	
Microservice	
…	
API	
…	
Microserv...
MigraIng	to	Microservices	
1.  Use	API	Facades	to	define	clear	interfaces	
2.  Separate	complex	concerns	into	separate	
ser...
The	Composable	World	of	APIs	
Offers API
Inventory
API
Bookings
API
Identity API
Accounts
API
Rewards
API
Partners
Interna...
Thank	you	
James	Higginbotham	
@launchany	
hep://bit.ly/api-skills
API:World 2016 - Applying Domain Driven Design to APIs and Microservices
API:World 2016 - Applying Domain Driven Design to APIs and Microservices
API:World 2016 - Applying Domain Driven Design to APIs and Microservices
API:World 2016 - Applying Domain Driven Design to APIs and Microservices
API:World 2016 - Applying Domain Driven Design to APIs and Microservices
API:World 2016 - Applying Domain Driven Design to APIs and Microservices
API:World 2016 - Applying Domain Driven Design to APIs and Microservices
API:World 2016 - Applying Domain Driven Design to APIs and Microservices
Upcoming SlideShare
Loading in …5
×

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

1,923 views

Published on

Presentation from API:World 2016 that answers the following questions:

How are APIs and microservices related?
How do I figure out how to find the right size for my microservices?
And how do I get there if I have a monolithic architecture?

Published in: Software

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

  1. 1. Applying Domain Driven Design to APIs and Microservices James Higginbotham @launchany
  2. 2. Your API tells a story and creates a conversa3on between you and the world
  3. 3. A great API design strategy is cri3cal for API product adop3on and sustainable applica3on development
  4. 4. Your API design is a contract with your API consumers. It is “mission cri3cal” to them.
  5. 5. Your API design is composed of the capabili3es (or “skills”) you offer to developers
  6. 6. API Skills == “I want to…”
  7. 7. What skills do your APIs need to offer?
  8. 8. Outside-In API Design Approach Web Applica3on API Design – “The Contract” Internal Applica3on API Consumer Mobile Applica3on
  9. 9. API Design is an architectural concern that combines business, product design, and soKware engineering
  10. 10. Lack of ModularizaIon = Regret VS Purpose-Based Module-Based
  11. 11. High cohesion internally for closely-related funcIonality Loose coupling externally across modules without internal details High Cohesion + Loose Coupling
  12. 12. package package public Public APIs encourage loose coupling between modules API Scoping rules restrict access outside of modules X API-Centric SoPware Design
  13. 13. Systems Design System Subsystem Subsystem Module Module Module Module Subsystem Subsystem Module Module
  14. 14. LEGO as Modular System Design System Subsystems Modules
  15. 15. API API API System/SoluIon Subsystem Subsystem Subsystem Module Module Module Module Module Module Module Module Module Module Module Module Module Module Module Module
  16. 16. Domain-Driven Design helps with iden3fying context boundaries for complex APIs
  17. 17. Domain Driven Design (DDD) u  Maps domain concepts into soPware u  Heavy domain expert involvement u  Common vocabulary (“Ubiquitous Language”) u  Boundary-driven (“Bounded Context”) u  Apply learning over Ime
  18. 18. “I need to mul3ply two numbers together. So, I am building a microservice architecture.” - almost everyone today
  19. 19. Microservice Architecture u  Loosely-coupled, service-oriented architecture u  Apply bounded context to limit cogniIve load u  Independently deployable via automaIon u  Enable replaceability and experimentaIon u  Encourage composability of the business u  Best for large teams, or co-located disparate data
  20. 20. Applying Systems Design and Domain-Driven Design to find API boundaries and resources
  21. 21. List Avail Inventory Distributor Add Product to Order Complete Order Cancel Booking Add Product to Inventory Update Product Qty Locate Booking Redeem Booking Point Of Sale Remove Product Customer Operator Operator
  22. 22. Order Mgmt List Avail Inventory Distributor Add Product to Order Complete Order Cancel Booking Add Product to Inventory Update Product Qty Locate Booking Redeem Booking Operator Point Of Sale Remove Product Customer Operator Inventory Mgmt Fulfillment
  23. 23. Each subsystem has an API that exposes one or more endpoints
  24. 24. Order API List Avail Inventory Distributor Add Product to Order Complete Order Cancel Booking Add Product to Inventory Update Product Qty Locate Booking Redeem Booking Point Of Sale Remove Product Customer Operator Inventory API Fulfillment API Operator
  25. 25. Iden3fying product opportuni3es becomes easier when we have boundaries around the APIs
  26. 26. Order API List Avail Inventory Distributor Add Product to Order Complete Order Cancel Booking Add Product to Inventory Update Product Qty Locate Booking Redeem Booking Operator Remove Product Inventory API Fulfillment API #1 #2 ` Point Of Sale
  27. 27. For every API, ask: “What resources will it offer?”
  28. 28. Use domain-driven design to find business en33es, rela3ons, state transi3ons, and events
  29. 29. Order API List Avail Inventory Add Product to Order Complete Order Cancel Booking Add Product to Inventory Update Product Qty Locate Booking Redeem Booking Remove Product Inventory API Fulfillment API
  30. 30. Order API Product AvailabiliIes Orders Product Inventory Bookings Inventory API Fulfillment API Same enIty (Products), Conceptually different to the API context!
  31. 31. Availabili3es - product - date(s) avail - qty avail Orders - bookings - order total Products - name - avail schedule Bookings - product - date(s) - status
  32. 32. Availabili3es - product - date(s) avail - qty avail availabilityChanged() Orders - bookings - order total created() updated() Products - name - avail schedule created() removed() updated() Bookings - product - date(s) - Status redeemed() cancelled()
  33. 33. Availabili3es - product - date(s) avail - qty avail availabilityChanged() Orders - bookings - order total created() updated() Products - name - avail schedule created() removed() updated() Bookings - product - date(s) - status redeemed() cancelled() Order API Inventory API Fulfillment API
  34. 34. Map Resources to the API
  35. 35. API composability using microservices
  36. 36. Public APIs target durability through external contracts Microservice APIs target evoluIon through experimentaIon Photo Credit: h,ps://www.flickr.com/photos/libel_vox
  37. 37. Availabili3es Service Orders Service Products Service Bookings Service Orders HTTP API Inventory HTTP API Fulfillment HTTP API
  38. 38. Availabili3es Service Orders Service Products Service Bookings Service Orders HTTP API Inventory HTTP API Fulfillment HTTP API Payment Service Refund Service
  39. 39. Alexa Voice Skill API Gateway API Gateway Messaging … Microservice … API … Microservice … API … Microservice … API … Microservice … API Slack Chatbot Web + Mobile App API Gateway Microservice Architecture
  40. 40. MigraIng to Microservices 1.  Use API Facades to define clear interfaces 2.  Separate complex concerns into separate services 3.  Use Service Object Paeern to decompose 4.  Build an automated deployment pipeline 5.  Migrate service objects to microservices
  41. 41. The Composable World of APIs Offers API Inventory API Bookings API Identity API Accounts API Rewards API Partners Internal Developers Public App Developers Consumers Third-party Approved Apps
  42. 42. Thank you James Higginbotham @launchany hep://bit.ly/api-skills

×