designing apis and microservices using domain-driven design
TRANSCRIPT
![Page 1: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/1.jpg)
Applying Domain Driven Design to APIs and Microservices
James Higginbotham@launchany
![Page 2: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/2.jpg)
Your API tells a story about your company and your vision
![Page 3: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/3.jpg)
![Page 4: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/4.jpg)
![Page 5: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/5.jpg)
![Page 6: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/6.jpg)
A great API design strategy is critical for API product adoption and
sustainable application development
![Page 7: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/7.jpg)
![Page 8: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/8.jpg)
Your APIs may not be considered “mission critical” like Stripe. But
your API design is a contract with your API consumers.
![Page 9: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/9.jpg)
![Page 10: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/10.jpg)
Your API design is composed of the capabilities (or “skills”)
you offer to developers
![Page 11: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/11.jpg)
API Skills == “I want to…”
![Page 12: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/12.jpg)
What skills do your APIs need to offer?
![Page 13: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/13.jpg)
Outside-In API Design ApproachWeb
Application
API Design – “The Contract”
Internal ApplicationAPI Consumer Mobile
Application
![Page 14: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/14.jpg)
API Design is an architectural concern that combines business, product design, and software engineering
![Page 15: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/15.jpg)
![Page 16: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/16.jpg)
Lack of Modularization = Regret
VS
Function-Based Module-Based
![Page 17: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/17.jpg)
High cohesion internally for commonfunctionality
Loose coupling externally acrossmodules
High Cohesion + Loose Coupling
![Page 18: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/18.jpg)
Public APIs encourageloose couplingbetween modules
API
Scoping rulesrestrict accessoutside of modules
X
API-Centric Software Design
![Page 19: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/19.jpg)
Systems DesignSystem
Subsystem Subsystem
Module Module
Module Module
Subsystem Subsystem
Module Module
![Page 20: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/20.jpg)
LEGO as Modular System Design
System
Sub-systems
Modules
![Page 21: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/21.jpg)
API
API
API
System/Solution
Subsystem Subsystem
Subsystem
Module ModuleModule Module
Module ModuleModule Module
Module ModuleModule Module
Module Module
Module Module
![Page 22: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/22.jpg)
Domain-Driven Design helps with identifying context
boundaries for complex APIs
![Page 23: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/23.jpg)
Domain Driven Design (DDD) Maps domain concepts into software Heavy domain expert involvement Common vocabulary (“Ubiquitous Language”) Boundary-driven (“Bounded Context”) Applies learning over time
![Page 24: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/24.jpg)
“I need to multiply two numbers together. So, I am building
a microservice architecture.”- almost everyone today
![Page 25: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/25.jpg)
Microservice Architecture Loosely-coupled, service-oriented architecture Apply bounded context to limit cognitive load Independently deployable via automation Enable replaceability and experimentation Encourage composability of the business Best for larger teams
![Page 26: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/26.jpg)
Applying Systems Designand Domain-Driven Design
to find API boundaries and resources
![Page 27: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/27.jpg)
![Page 28: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/28.jpg)
List Avail Inventory
DistributorAdd Product
to Order
CompleteOrder
Cancel Booking
Add Product to Inventory
Update Product Qty
LocateBooking
Redeem Booking
PointOf Sale
Remove Product
Customer
Operator
Operator
![Page 29: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/29.jpg)
Order MgmtList Avail Inventory
DistributorAdd Product
to Order
CompleteOrder
Cancel Booking
Add Product to Inventory
Update Product Qty
LocateBooking
Redeem Booking
Operator
PointOf Sale
Remove Product
Customer
Operator
Inventory Mgmt
Fulfillment
![Page 30: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/30.jpg)
Each subsystem has an API that exposes one or more endpoints
![Page 31: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/31.jpg)
Order APIList Avail Inventory
DistributorAdd Product
to Order
CompleteOrder
Cancel Booking
Add Product to Inventory
Update Product Qty
LocateBooking
Redeem Booking
PointOf Sale
Remove Product
Customer
Operator
Inventory API
Fulfillment API
Operator
![Page 32: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/32.jpg)
Identifying product opportunities becomes easier when we have
boundaries around the APIs
![Page 33: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/33.jpg)
Order APIList Avail Inventory
DistributorAdd Product
to Order
CompleteOrder
Cancel Booking
Add Product to Inventory
Update Product Qty
LocateBooking
Redeem Booking
Operator
Remove Product
Inventory API
Fulfillment API
#1 #2`
PointOf Sale
![Page 34: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/34.jpg)
For every API, ask: “What resources will it offer?”
![Page 35: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/35.jpg)
Use domain-driven design to find business entities, relations,
state transitions, and events
![Page 36: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/36.jpg)
Order APIList Avail Inventory
Add Product to Order
CompleteOrder
Cancel Booking
Add Product to Inventory
Update Product Qty
LocateBooking
Redeem Booking
Remove Product
Inventory API
Fulfillment API
![Page 37: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/37.jpg)
Order API
Product Availabilities
Orders
ProductInventory
Bookings
Inventory API
Fulfillment API
Same entity (Products), Conceptually different to
the API context!
![Page 38: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/38.jpg)
Availabilities- product
- date(s) avail- qty avail
Orders- bookings
- order total
Products- name
- avail schedule
Bookings- product- date(s)- status
![Page 39: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/39.jpg)
Availabilities- 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()
![Page 40: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/40.jpg)
Availabilities- 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
![Page 41: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/41.jpg)
Map Resources to the API
![Page 42: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/42.jpg)
API composability using microservices
![Page 43: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/43.jpg)
Public APIs target durability through external contracts.
Microservice APIs target evolution through learning and experimentation
![Page 44: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/44.jpg)
Availabilities Service Orders Service
Products Service
Bookings Service
Orders HTTP API
Inventory HTTP API
Fulfillment HTTP API
![Page 45: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/45.jpg)
Availabilities Service Orders Service
Products Service
Bookings Service
Orders HTTP API
Inventory HTTP API
Fulfillment HTTP API
Payment Service Refund Service
![Page 46: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/46.jpg)
Alex
a Vo
ice
Skill
API
Gate
way
API
Gate
way
Mes
sagi
ng
…Microservice
…
API
…Microservice
…
API
…Microservice
…
API
…Microservice
…AP
I
Slac
k Ch
atbo
tW
eb +
M
obile
App
API
Gate
way
Microservice Architecture
![Page 47: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/47.jpg)
The Composable World of APIs
Offers API
Inventory API
Bookings API
Identity API
Accounts API
Rewards API
Partners
InternalDevelopers
Public AppDevelopers
Consumers
Third-partyApproved Apps
![Page 48: Designing APIs and Microservices Using Domain-Driven Design](https://reader031.vdocuments.site/reader031/viewer/2022021815/587561411a28ab00528b745f/html5/thumbnails/48.jpg)
Thank youJames Higginbotham
@launchanyhttp://bit.ly/api-skills