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 - Austin API Meetup

1,386 views

Published on

A look at the stories our APIs tell, the importance of API design, and how systems design and domain-driven design can be used to build a long-lasting API design

Published in: Software
  • Be the first to comment

Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup

  1. 1. Applying Domain Driven Design to APIs and Microservices James Higginbotham james@launchany.com @launchany
  2. 2. Great API Design is critical for product adoption and long-term API success
  3. 3. API design also tells a story about your company and your vision of what the world can become.
  4. 4. Your API design defines the capabilities or skills your API offers to developers
  5. 5. Credit: http://kinlane.github.io/university-api-workshop/apis/
  6. 6. Architecture is design
  7. 7. API Design is an architectural concern that combines business drivers, product design, and software design
  8. 8. 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
  9. 9. Applying Systems Design and Domain-Driven Design
  10. 10. What skills do your APIs need to offer?
  11. 11. Finding APIs through product and resource boundaries
  12. 12. 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”
  13. 13. Domain-Driven Design helps with identifying context boundaries for complex APIs
  14. 14. Lack of Modularization = Regret VS Function-Based Module-Based
  15. 15. 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
  16. 16. Microservices require a renewed focus on systems and API design
  17. 17. Modeling a System System/Solution Subsystem Subsystem Module Module Module Module Subsystem Subsystem Module Module
  18. 18. LEGO as Modular System Design System Sub-systems Modules
  19. 19. LEGO as a System of Systems System System System System System
  20. 20. Example: Marketplace Platform API
  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. Driving API Design
  24. 24. Each subsystem has an API that exposes one or more endpoints
  25. 25. 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
  26. 26. Identifying product opportunities becomes easier when we have boundaries around the APIs
  27. 27. 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
  28. 28. For every API, ask: “What resources will it offer?”
  29. 29. Use domain-driven design to find business entities, relations, state transitions, and events
  30. 30. 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
  31. 31. Order API Availabilities Orders Products (Inventory) Bookings Inventory API Fulfillment API Same entity (Products), Conceptually different to the API context!
  32. 32. Availabilities - product - date(s) avail - qty avail Orders - bookings - order total Products - name - avail schedule Bookings - product - date(s) - status
  33. 33. 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()
  34. 34. 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
  35. 35. Map Resources to the API
  36. 36. API composability using microservices
  37. 37. Public APIs target durability Microservice APIs target replaceability
  38. 38. Availabilities Service createAvailability() updateAvailability () deleteAvailability () … availabilityChanged( ) Orders Service createOrder() updateOrder () deleteOrder () … created() updated() Products Service createProduct() updateProduct () deleteProduct () … created() removed() updated() Bookings Service lookupBooking() redeemBooking () cancelBooking () … redeemed() cancelled() Order API Inventory API Fulfillment API Orders HTTP API Inventory HTTP API Fulfillment HTTP API
  39. 39. VoiceSkill API Product API Product Messaging … Microservice … API … Microservice … API … Microservice …API … Microservice … API Chatbot Web+ MobileApp API Product Microservice Architecture
  40. 40. 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
  41. 41. 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
  42. 42. Thank you James Higginbotham james@launchany.com @launchany

×