Upgrade to Pro — share decks privately, control downloads, hide ads and more …

INTERFACE by apidays 2023 - APIs with bounded c...

INTERFACE by apidays 2023 - APIs with bounded contexts, Jose Haro Peralta, microapis.io

INTERFACE by apidays 2023
APIs for a “Smart” economy. Embedding AI to deliver Smart APIs and turn into an exponential organization
June 28 & 29, 2023

APIs with bounded contexts: modelling APIs with domain-driven design
Jose Haro Peralta, Author, Instructor, Consultant at microapis.io

------

Check out our conferences at https://www.apidays.global/

Do you want to sponsor or talk at one of our conferences?
https://apidays.typeform.com/to/ILJeAaV8

Learn more on APIscene, the global media made by the community for the community:
https://www.apiscene.io

Explore the API ecosystem with the API Landscape:
https://apilandscape.apiscene.io/

apidays

July 11, 2023
Tweet

More Decks by apidays

Other Decks in Programming

Transcript

  1. APIs with Bounded Contexts Better design with domain-driven APIs José

    Haro Peralta Consultant, author, and instructor Founder of microapis.io APIDays Interface June 29, 2023
  2. $ whoami • I’m Jose • Consultant, author, instructor •

    Author of Microservice APIs • Founder of microapis.io @JoseHaroPeralta @microapis
  3. Connect with me!  Twitter: @JoseHaroPeralta  GitHub: @abunuwas 

    Newsletter: https://microapis.substack.com  LinkedIn: https://www.linkedin.com/in/jose-haro-peralta/
  4. Giveaway!  3 ebook copies of Microservice APIs  15

    free signups for Build APIs with Python https://bit.ly/apidays-int
  5. Agenda  Why is API design difficult?  How DDD

    helps us design better APIs  How do we model flows?
  6. API design is difficult Raw materials:  URLs  HTTP

    methods  Status codes  Schemas  HTTP headers
  7. Heuristics are a means to an end CRUD heuristic 

    Create  Read  Update  Delete CRUD vs CRUDE APIs
  8. What is DDD?  Align software with business  Incorporate

    the language of the business  Create a Ubiquitous Language  Under the processes and flows of the business  Facilitate conversations between software and business
  9. Domains, subdomains, and bounded contexts  Domain represents the core

    area of the business  Subdomain represents a specific area of the business  A bounded context is a space within which the vocabulary acquires specific meaning
  10. How do we model operations in APIs? 1. Customer adds

    items to the cart. 2. Customer proceeds to check out. 3. After applying coupons, discounts, and so on, the system calculates the total. 4. Customer selects a payment method and enters payment details. 5. System processes payment. 6. System confirms the order.
  11. Heuristics for modeling operations  How do we model payment?

     Paying is an operation, not an object or resource  Semantics of a POST => create a resource or send data for processing  POST will process the payment and create a payment object in our server  Return the outcome of this operation to the user  Using this heuristic, we can model nearly every business operation through the API.
  12. How do we model flows in APIs? How do we

    represent the relationship between endpoints to document the flow?  HATEOAS  OpenAPI links  Workflows
  13. Benefits of using standards  Mock servers  Code generation

     Documentation UIs (Swagger, Redoc, etc.)  Automatic testing
  14. API testing  Fundamental to ensure accurate implementation  Necessary

    to deliver reliable integrations  Fuzzy testers like schemathesis  Property-based testing  Structural testing
  15. Giveaway!  3 ebook copies of Microservice APIs  15

    free signups for Build APIs with Python https://bit.ly/apidays-int
  16. Further reading  I wrote some thoughts on bringing DDD

    and API design together in “APIs with Bounded Contexts”.  An insightful and pioneering overview of how domain-driven design can help and empower the API design process is James Higginbotham’s Principles of Web API Design. Another great resource that encourages a DDD approach to API design is Patterns for API Design, by Olaf Zimmerman, Mirko Stocker, Daniel Lübke, Uwe Zdun, and Cesare Pautasso.  For a comprehensive overview of API design, check out Arnaud Lauret’s The Design of Web APIs. David Biesack’s newsletter API Design Matters is also a rich source of ideas and information about good API design.  For more about API design heuristics for REST/OpenAPI, check out Josh Ponelat and Lukas Rosenstock’s Designing APIs with Swagger and OpenAPI. Check out Lukas’s talk “From Domain Model to API” for more examples of heuristics.  For ideas on modelling complex concepts like trust and liability, check out Martin Verraes and Rebecca Wirfs-Brock’s article “Models and Metaphors”.