applying domain-driven design to apis and microservices - austin api meetup
TRANSCRIPT
![Page 2: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/2.jpg)
Great API Design is critical for product adoption and long-term
API success
![Page 3: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/3.jpg)
![Page 4: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/4.jpg)
![Page 5: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/5.jpg)
API design also tells a story about your company and your vision of what the world can
become.
![Page 6: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/6.jpg)
![Page 7: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/7.jpg)
![Page 8: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/8.jpg)
![Page 9: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/9.jpg)
Your API design defines the capabilities or skills your API
offers to developers
![Page 10: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/10.jpg)
Credit: http://kinlane.github.io/university-api-workshop/apis/
![Page 11: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/11.jpg)
![Page 12: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/12.jpg)
Architecture is design
![Page 13: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/13.jpg)
API Design is an architectural concern that combines business
drivers, product design, and software design
![Page 14: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/14.jpg)
Outside-In API Design Approach
“My data model is not my object model”– Data model is for internal storage
“My object model is not my resource model”– Resources is for external, context-based collaboration– Object model is for internal software collaboration
“My resource model is not my representation model”– There are many ways to represent resources
e.g. JSON, XML, CSV, HTML
- Mike Amundsen, API-Craft Google Group- https://groups.google.com/forum/#!search/my$20resource$20model$20is$20not/api-craft/n2Efmju5nLM/
KUEyMOFIBAAJ
![Page 15: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/15.jpg)
Applying Systems Designand Domain-Driven Design
![Page 16: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/16.jpg)
What skills do your APIs need to offer?
![Page 17: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/17.jpg)
![Page 18: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/18.jpg)
Finding APIs through product and resource boundaries
![Page 19: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/19.jpg)
Domain Driven Design (DDD)
Mapping domain concepts into software Heavy focus on domain expert involvement Common vocabulary (“Ubiquitous Language”) Boundary-driven (“Bounded Context”) Applies learning over time Based on Eric Evans' book "Domain Driven
Design”
![Page 20: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/20.jpg)
Domain-Driven Design helps with identifying context
boundaries for complex APIs
![Page 21: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/21.jpg)
![Page 22: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/22.jpg)
Lack of Modularization = Regret
VS
Function-Based Module-Based
![Page 23: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/23.jpg)
Microservice Architecture
Microservices are independently deployable, loosely-coupled components
Apply bounded context to limit cognitive load Benefit from heavy automation (CI/CD) Enable replaceability and experimentation Encourage composability of the business for
new products
![Page 24: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/24.jpg)
Microservices require a renewed focus on
systems and API design
![Page 25: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/25.jpg)
Modeling a System
System/Solution
Subsystem Subsystem
Module Module
Module Module
Subsystem SubsystemModule Module
![Page 26: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/26.jpg)
LEGO as Modular System Design
System
Sub-systems
Modules
![Page 27: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/27.jpg)
LEGO as a System of Systems
System
System
System
SystemSystem
![Page 28: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/28.jpg)
Example: Marketplace Platform API
![Page 29: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/29.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 30: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/30.jpg)
Order Mgmt
List 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 31: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/31.jpg)
Driving API Design
![Page 32: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/32.jpg)
Each subsystem has an API that exposes one or more endpoints
![Page 33: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/33.jpg)
Order API
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
Inventory API
Fulfillment API
Operator
![Page 34: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/34.jpg)
Identifying product opportunities becomes easier
when we have boundaries around the APIs
![Page 35: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/35.jpg)
Order API
List 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 36: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/36.jpg)
For every API, ask: “What resources will it offer?”
![Page 37: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/37.jpg)
Use domain-driven design to find business entities, relations,
state transitions, and events
![Page 38: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/38.jpg)
Order API
List 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 39: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/39.jpg)
Order API
Availabilities
Orders
Products(Inventory)
Bookings
Inventory API
Fulfillment API
Same entity (Products), Conceptually different to
the API context!
![Page 40: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/40.jpg)
Availabilities- product
- date(s) avail- qty avail
Orders- bookings
- order total
Products- name
- avail schedule
Bookings- product- date(s)- status
![Page 41: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/41.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 42: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/42.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 43: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/43.jpg)
Map Resources to the API
![Page 44: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/44.jpg)
API composability using microservices
![Page 45: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/45.jpg)
Public APIs target durability
Microservice APIs target replaceability
![Page 46: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/46.jpg)
Availabilities Service
createAvailability()updateAvailability ()deleteAvailability ()
…availabilityChanged()
Orders ServicecreateOrder()
updateOrder ()deleteOrder ()
…created()updated()
Products ServicecreateProduct()
updateProduct ()deleteProduct ()
…created()
removed()updated()
Bookings ServicelookupBooking()
redeemBooking ()cancelBooking ()
…redeemed()cancelled()
Order API Inventory API
Fulfillment API
Orders HTTP API Inventory HTTP API
Fulfillment HTTP API
![Page 47: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/47.jpg)
Voic
e Sk
ill
API
Prod
uct
API
Prod
uct
Mes
sagi
ng
…Microservice
…
API
…Microservice
…
API
…Microservice
…AP
I
…Microservice
…
APICh
atbo
tW
eb +
M
obile
App
API
Prod
uct
Microservice Architecture
![Page 48: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/48.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 49: Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup](https://reader036.vdocuments.net/reader036/viewer/2022062503/587561341a28ab00528b7413/html5/thumbnails/49.jpg)
Summary
Great API design is critical for product adoption and long-term API success
API Design is an architectural concern that combines business drivers, product design, and software design
Systems design and DDD help with designing long-lasting APIs
Use microservices where appropriate to increase composability of your business or product
Be a storyteller using APIs