SlideShare a Scribd company logo
1 of 27
APIS WITH BOUNDED
CONTEXTS
Modelling APIs with Domain-Driven Design
José Haro Peralta
Consultant and instructor
Founder of microapis.io
API World Conference
28 Oct – 3 Nov 2022
@microapisio
@JoseHaroPeralta
$ whoami
• I’m Jose
• Consultant, author, instructor
• Author of Microservices and APIs
• Founder of microapis.io
@JoseHaroPeralta
@microapisio
35% discount code: ctwapiworld22
microapis.io
39% discount code: ctwapi21
One-click API mock servers
@JoseHaroPeralta
@microapisio
Connect with me!
 Twitter: @JoseHaroPeralta
 GitHub: @abunuwas
 Medium: @joseharoperalta /@python-geek
 LinkedIn: https://www.linkedin.com/in/jose-haro-peralta/
Agenda
 Complexity of creating good API design
 More in particular, good REST API design
 How domain-driven design helps to design better APIs
 Special case of data-driven applications
Ubiquitous APIs
• Using domain-driven design to align with the business helps us
create better APIs
• Think about processes and flows instead of endpoints and
HTTP status codes
• How leveraging API design principles such as uniform interface
helps us create ubiquitous APIs
• Leveraging HTTP semantics helps us create ubiquitous APIs
Reality is more complex than textbook cases
• Many projects start out as an experiment and/or PoC and then there’s pressure to
build the production application quickly (the business case often depends on the
speed of delivery)
• In reality, we often figure out what we’re doing on the go (the domain and the
subdomains become clear as we progress in our work)
• The business often lacks terminology to refer to their own processes and flows and to
their own “entities”
• Data-driven applications are notoriously hard to model (everything is “data”)
APIs for data-driven applications anti-patterns
• API conceived as data gateways
• Lack of API design and validation
• Lacking notion of operations
• Oversimplification through CRUD (CRUDified APIs)
• God models
• Cluttered endpoints
• Lacking HTTP semantics
• Breaking uniform interface
Build a sales forecasting
application
• Digital transformation project in major international retail org
• Automate sales forecasting
• From two forecasts a year to rolling forecast
• More accurate forecast
• Being able to model multiple scenarios
• Keep track of historical forecasts and compare
Starting with an
experiment
• We started with a small experiment
• Early Machine Learning iterations proved successful
Building a PoC
• Built a quick UI using Dash (Python library)
• Weekly iterations
PoC validated – project kicks off
Split UI and backend
1
Expose backend API
2
Operate at scale
3
Project kicks off – new architecture
API design challenges
• It becomes clear that the business lacks terminology to refer to their own processes
and flows, and to their “entities”
• Different countries use different processes and flows
• We think of states instead of different entities and we have a “God model”
API design challenges
• We drag bad models from the PoC
• Cluttered endpoints due to over-reuse
• Very difficult to continue extending the API
• 2 languages: business and data science
God models: using states instead of entities
Bad models
Cluttered endpoints
• POST /forecast => retrieve raw forecast
• POST /forecast + adjustments => create scenario
• POST /forecast + adjustments + new stores => create new store forecast
• PUT /forecast/{forecast_id} => create candidate
• PUT /forecast/{forecast_id} => create submission
From states to entities
Raw forecast
Scenario
Candidate
Submission
New store
forecast
Modeling operations
• Stop thinking in terms of URLs and HTTP methods
• Start thinking in terms of operations
• Decouple your backend data model from your API models
• Leverage HTTP semantics
• Enforce uniform interface
Start with operations, processes, and flows
• Retrieve raw forecast
• Create and update scenarios
• Create and update candidate
• Create submission
• Create forecasts and scenarios for new stores
Use meaningful resource endpoints and
leverage HTTP semantics
Conclusions
• Changing the API is risky – can break integrations => address design issues early
• Don’t think in terms of URLs and HTTP methods => think in terms of operations, processes, and
flows
• Don’t crudify your APIs – if an operation isn’t needed, don’t add it
• Flexible models are bad => create discrete models for each entity
• Clarity over reusability => don’t reuse endpoints and models
Thanks for listening!
Twitter: @JoseHaroPeralta
GitHub: @abunuwas
Medium: @joseharoperalta /@python-geek
LinkedIn: https://www.linkedin.com/in/jose-haro-peralta/
35% discount code: ctwapiworld22
ADDITIONAL READINGS
• Microservice APIs by J. Haro (mng.bz/nz48)
• “Building and deploying reliable APIs with FastAPI” by J. Haro
(https://www.twitch.tv/videos/1088283640)
• Documentation-driven development for APIs by J. Haro
(https://link.medium.com/m2A3rOxUfib)
• “Developing API clients doesn’t need to be a pain” by J. Haro
(https://link.medium.com/0B9vt7DUfib)
• “How bad models ruin an API” by J. Haro (https://microapis.io/blog/how-bad-models-
ruin-an-api)
• “API-first development maturity framework” by J. Haro (https://microapis.io/blog/api-
development-maturity)
ADDITIONAL READINGS
• “Design patterns for modern web APIs” by D. Luecke
(https://blog.feathersjs.com/design-patterns-for-modern-web-apis-1f046635215)
• The design of web APIs by A Lauret (https://www.manning.com/books/the-design-of-
web-apis)
• Designing APIs with Swagger and OpenAPI by J. S. Ponelat and L. L. Rosenstock
(https://www.manning.com/books/designing-apis-with-swagger-and-openapi)
• API Design Patterns by JJ Geewax (https://www.manning.com/books/api-design-
patterns)
• Principle of Web API Design by J. Higginbotham
(https://www.pearson.com/store/p/principles-of-web-api-design-delivering-value-
with-apis-and-microservices/P200000007278/9780137355631)

More Related Content

What's hot

Event Driven Software Architecture Pattern
Event Driven Software Architecture PatternEvent Driven Software Architecture Pattern
Event Driven Software Architecture Patternjeetendra mandal
 
What are Microservices | Microservices Architecture Training | Microservices ...
What are Microservices | Microservices Architecture Training | Microservices ...What are Microservices | Microservices Architecture Training | Microservices ...
What are Microservices | Microservices Architecture Training | Microservices ...Edureka!
 
From Monolithic to Microservices
From Monolithic to Microservices From Monolithic to Microservices
From Monolithic to Microservices Amazon Web Services
 
Speed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red Hat
Speed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red HatSpeed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red Hat
Speed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red HatHostedbyConfluent
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice ArchitectureNguyen Tung
 
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREMicroservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREAraf Karsh Hamid
 
APIs in a Microservice Architecture
APIs in a Microservice ArchitectureAPIs in a Microservice Architecture
APIs in a Microservice ArchitectureWSO2
 
Api gateway in microservices
Api gateway in microservicesApi gateway in microservices
Api gateway in microservicesKunal Hire
 
Microservices Architectures: Become a Unicorn like Netflix, Twitter and Hailo
Microservices Architectures: Become a Unicorn like Netflix, Twitter and HailoMicroservices Architectures: Become a Unicorn like Netflix, Twitter and Hailo
Microservices Architectures: Become a Unicorn like Netflix, Twitter and Hailogjuljo
 
Which Application Modernization Pattern Is Right For You?
Which Application Modernization Pattern Is Right For You?Which Application Modernization Pattern Is Right For You?
Which Application Modernization Pattern Is Right For You?Apigee | Google Cloud
 
Architecting an Enterprise API Management Strategy
Architecting an Enterprise API Management StrategyArchitecting an Enterprise API Management Strategy
Architecting an Enterprise API Management StrategyWSO2
 
OpenAPI Intro (1).pdf
OpenAPI Intro (1).pdfOpenAPI Intro (1).pdf
OpenAPI Intro (1).pdfPostman
 

What's hot (20)

Event Driven Software Architecture Pattern
Event Driven Software Architecture PatternEvent Driven Software Architecture Pattern
Event Driven Software Architecture Pattern
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
What are Microservices | Microservices Architecture Training | Microservices ...
What are Microservices | Microservices Architecture Training | Microservices ...What are Microservices | Microservices Architecture Training | Microservices ...
What are Microservices | Microservices Architecture Training | Microservices ...
 
From Monolithic to Microservices
From Monolithic to Microservices From Monolithic to Microservices
From Monolithic to Microservices
 
Speed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red Hat
Speed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red HatSpeed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red Hat
Speed-Up Kafka Delivery with AsyncAPI & Microcks | Hugo Guerrero, Red Hat
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Microservices
MicroservicesMicroservices
Microservices
 
API Security Fundamentals
API Security FundamentalsAPI Security Fundamentals
API Security Fundamentals
 
Domain Driven Design
Domain Driven Design Domain Driven Design
Domain Driven Design
 
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREMicroservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SRE
 
Why Microservice
Why Microservice Why Microservice
Why Microservice
 
APIs in a Microservice Architecture
APIs in a Microservice ArchitectureAPIs in a Microservice Architecture
APIs in a Microservice Architecture
 
Api gateway in microservices
Api gateway in microservicesApi gateway in microservices
Api gateway in microservices
 
Deep-Dive: Secure API Management
Deep-Dive: Secure API ManagementDeep-Dive: Secure API Management
Deep-Dive: Secure API Management
 
Microservices Architectures: Become a Unicorn like Netflix, Twitter and Hailo
Microservices Architectures: Become a Unicorn like Netflix, Twitter and HailoMicroservices Architectures: Become a Unicorn like Netflix, Twitter and Hailo
Microservices Architectures: Become a Unicorn like Netflix, Twitter and Hailo
 
Which Application Modernization Pattern Is Right For You?
Which Application Modernization Pattern Is Right For You?Which Application Modernization Pattern Is Right For You?
Which Application Modernization Pattern Is Right For You?
 
Architecture for the API-enterprise
Architecture for the API-enterpriseArchitecture for the API-enterprise
Architecture for the API-enterprise
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Architecting an Enterprise API Management Strategy
Architecting an Enterprise API Management StrategyArchitecting an Enterprise API Management Strategy
Architecting an Enterprise API Management Strategy
 
OpenAPI Intro (1).pdf
OpenAPI Intro (1).pdfOpenAPI Intro (1).pdf
OpenAPI Intro (1).pdf
 

Similar to APIs with Bounded Contexts: Modelling Apis with Domain-Driven Design

INTERFACE by apidays 2023 - APIs with bounded contexts, Jose Haro Peralta, mi...
INTERFACE by apidays 2023 - APIs with bounded contexts, Jose Haro Peralta, mi...INTERFACE by apidays 2023 - APIs with bounded contexts, Jose Haro Peralta, mi...
INTERFACE by apidays 2023 - APIs with bounded contexts, Jose Haro Peralta, mi...apidays
 
APIs with Bounded Contexts: Modeling APIs with Domain-Driven Design
APIs with Bounded Contexts: Modeling APIs with Domain-Driven DesignAPIs with Bounded Contexts: Modeling APIs with Domain-Driven Design
APIs with Bounded Contexts: Modeling APIs with Domain-Driven DesignNordic APIs
 
Lessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptxLessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptxapidays
 
Pure APIs: Development workflows for successful API integrations
Pure APIs: Development workflows for successful API integrationsPure APIs: Development workflows for successful API integrations
Pure APIs: Development workflows for successful API integrationsJosé Haro Peralta
 
APIs : Mapping the way
APIs : Mapping the wayAPIs : Mapping the way
APIs : Mapping the wayWSO2
 
Building a REST API for Longevity
Building a REST API for LongevityBuilding a REST API for Longevity
Building a REST API for LongevityMuleSoft
 
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...apidays
 
API Gateways are going through an identity crisis
API Gateways are going through an identity crisisAPI Gateways are going through an identity crisis
API Gateways are going through an identity crisisChristian Posta
 
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...Callon Campbell
 
Sketching Web APIs
Sketching Web APIsSketching Web APIs
Sketching Web APIsronniemitra
 
[DevDay2018] High quality mindset in software development - By: Phat Vu, Scru...
[DevDay2018] High quality mindset in software development - By: Phat Vu, Scru...[DevDay2018] High quality mindset in software development - By: Phat Vu, Scru...
[DevDay2018] High quality mindset in software development - By: Phat Vu, Scru...DevDay.org
 
Documentation-driven development for Python web APIs v2
Documentation-driven development for Python web APIs v2Documentation-driven development for Python web APIs v2
Documentation-driven development for Python web APIs v2José Haro Peralta
 
#SPSOttawa 2017 migrate to the #SharePoint Framework #spfx
#SPSOttawa 2017 migrate to the #SharePoint Framework #spfx#SPSOttawa 2017 migrate to the #SharePoint Framework #spfx
#SPSOttawa 2017 migrate to the #SharePoint Framework #spfxVincent Biret
 
Delivering successful API integrations with documentation-driven development
Delivering successful API integrations with documentation-driven developmentDelivering successful API integrations with documentation-driven development
Delivering successful API integrations with documentation-driven developmentJosé Haro Peralta
 
15 tips for bullet proof requirements analysis on SharePoint projects
15 tips for bullet proof requirements analysis on SharePoint projects15 tips for bullet proof requirements analysis on SharePoint projects
15 tips for bullet proof requirements analysis on SharePoint projectsDocFluix, LLC
 
apidays LIVE Australia 2021 - Confessions of a Product Geek : My First API BY...
apidays LIVE Australia 2021 - Confessions of a Product Geek : My First API BY...apidays LIVE Australia 2021 - Confessions of a Product Geek : My First API BY...
apidays LIVE Australia 2021 - Confessions of a Product Geek : My First API BY...apidays
 
Lifecycle Management with SharePoint Apps and Solutions
Lifecycle Management with SharePoint Apps and SolutionsLifecycle Management with SharePoint Apps and Solutions
Lifecycle Management with SharePoint Apps and SolutionsSPC Adriatics
 
apidays LIVE London 2021 - Confessions of a Product Geek by Rosemary Missier,...
apidays LIVE London 2021 - Confessions of a Product Geek by Rosemary Missier,...apidays LIVE London 2021 - Confessions of a Product Geek by Rosemary Missier,...
apidays LIVE London 2021 - Confessions of a Product Geek by Rosemary Missier,...apidays
 

Similar to APIs with Bounded Contexts: Modelling Apis with Domain-Driven Design (20)

INTERFACE by apidays 2023 - APIs with bounded contexts, Jose Haro Peralta, mi...
INTERFACE by apidays 2023 - APIs with bounded contexts, Jose Haro Peralta, mi...INTERFACE by apidays 2023 - APIs with bounded contexts, Jose Haro Peralta, mi...
INTERFACE by apidays 2023 - APIs with bounded contexts, Jose Haro Peralta, mi...
 
APIs with Bounded Contexts: Modeling APIs with Domain-Driven Design
APIs with Bounded Contexts: Modeling APIs with Domain-Driven DesignAPIs with Bounded Contexts: Modeling APIs with Domain-Driven Design
APIs with Bounded Contexts: Modeling APIs with Domain-Driven Design
 
Lessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptxLessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptx
 
Pure APIs: Development workflows for successful API integrations
Pure APIs: Development workflows for successful API integrationsPure APIs: Development workflows for successful API integrations
Pure APIs: Development workflows for successful API integrations
 
APIs : Mapping the way
APIs : Mapping the wayAPIs : Mapping the way
APIs : Mapping the way
 
API Conference 2021
API Conference 2021API Conference 2021
API Conference 2021
 
Building a REST API for Longevity
Building a REST API for LongevityBuilding a REST API for Longevity
Building a REST API for Longevity
 
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
 
API Gateways are going through an identity crisis
API Gateways are going through an identity crisisAPI Gateways are going through an identity crisis
API Gateways are going through an identity crisis
 
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
Global Azure 2022 - Architecting Modern Serverless APIs with Azure Functions ...
 
Sketching Web APIs
Sketching Web APIsSketching Web APIs
Sketching Web APIs
 
[DevDay2018] High quality mindset in software development - By: Phat Vu, Scru...
[DevDay2018] High quality mindset in software development - By: Phat Vu, Scru...[DevDay2018] High quality mindset in software development - By: Phat Vu, Scru...
[DevDay2018] High quality mindset in software development - By: Phat Vu, Scru...
 
Documentation-driven development for Python web APIs v2
Documentation-driven development for Python web APIs v2Documentation-driven development for Python web APIs v2
Documentation-driven development for Python web APIs v2
 
#SPSOttawa 2017 migrate to the #SharePoint Framework #spfx
#SPSOttawa 2017 migrate to the #SharePoint Framework #spfx#SPSOttawa 2017 migrate to the #SharePoint Framework #spfx
#SPSOttawa 2017 migrate to the #SharePoint Framework #spfx
 
Delivering successful API integrations with documentation-driven development
Delivering successful API integrations with documentation-driven developmentDelivering successful API integrations with documentation-driven development
Delivering successful API integrations with documentation-driven development
 
Smartone v1.0
Smartone v1.0Smartone v1.0
Smartone v1.0
 
15 tips for bullet proof requirements analysis on SharePoint projects
15 tips for bullet proof requirements analysis on SharePoint projects15 tips for bullet proof requirements analysis on SharePoint projects
15 tips for bullet proof requirements analysis on SharePoint projects
 
apidays LIVE Australia 2021 - Confessions of a Product Geek : My First API BY...
apidays LIVE Australia 2021 - Confessions of a Product Geek : My First API BY...apidays LIVE Australia 2021 - Confessions of a Product Geek : My First API BY...
apidays LIVE Australia 2021 - Confessions of a Product Geek : My First API BY...
 
Lifecycle Management with SharePoint Apps and Solutions
Lifecycle Management with SharePoint Apps and SolutionsLifecycle Management with SharePoint Apps and Solutions
Lifecycle Management with SharePoint Apps and Solutions
 
apidays LIVE London 2021 - Confessions of a Product Geek by Rosemary Missier,...
apidays LIVE London 2021 - Confessions of a Product Geek by Rosemary Missier,...apidays LIVE London 2021 - Confessions of a Product Geek by Rosemary Missier,...
apidays LIVE London 2021 - Confessions of a Product Geek by Rosemary Missier,...
 

Recently uploaded

Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 

Recently uploaded (20)

Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 

APIs with Bounded Contexts: Modelling Apis with Domain-Driven Design

  • 1. APIS WITH BOUNDED CONTEXTS Modelling APIs with Domain-Driven Design José Haro Peralta Consultant and instructor Founder of microapis.io API World Conference 28 Oct – 3 Nov 2022 @microapisio @JoseHaroPeralta
  • 2. $ whoami • I’m Jose • Consultant, author, instructor • Author of Microservices and APIs • Founder of microapis.io @JoseHaroPeralta @microapisio 35% discount code: ctwapiworld22
  • 3. microapis.io 39% discount code: ctwapi21 One-click API mock servers @JoseHaroPeralta @microapisio
  • 4. Connect with me!  Twitter: @JoseHaroPeralta  GitHub: @abunuwas  Medium: @joseharoperalta /@python-geek  LinkedIn: https://www.linkedin.com/in/jose-haro-peralta/
  • 5. Agenda  Complexity of creating good API design  More in particular, good REST API design  How domain-driven design helps to design better APIs  Special case of data-driven applications
  • 6. Ubiquitous APIs • Using domain-driven design to align with the business helps us create better APIs • Think about processes and flows instead of endpoints and HTTP status codes • How leveraging API design principles such as uniform interface helps us create ubiquitous APIs • Leveraging HTTP semantics helps us create ubiquitous APIs
  • 7. Reality is more complex than textbook cases • Many projects start out as an experiment and/or PoC and then there’s pressure to build the production application quickly (the business case often depends on the speed of delivery) • In reality, we often figure out what we’re doing on the go (the domain and the subdomains become clear as we progress in our work) • The business often lacks terminology to refer to their own processes and flows and to their own “entities” • Data-driven applications are notoriously hard to model (everything is “data”)
  • 8. APIs for data-driven applications anti-patterns • API conceived as data gateways • Lack of API design and validation • Lacking notion of operations • Oversimplification through CRUD (CRUDified APIs) • God models • Cluttered endpoints • Lacking HTTP semantics • Breaking uniform interface
  • 9. Build a sales forecasting application • Digital transformation project in major international retail org • Automate sales forecasting • From two forecasts a year to rolling forecast • More accurate forecast • Being able to model multiple scenarios • Keep track of historical forecasts and compare
  • 10. Starting with an experiment • We started with a small experiment • Early Machine Learning iterations proved successful
  • 11. Building a PoC • Built a quick UI using Dash (Python library) • Weekly iterations
  • 12. PoC validated – project kicks off Split UI and backend 1 Expose backend API 2 Operate at scale 3
  • 13. Project kicks off – new architecture
  • 14. API design challenges • It becomes clear that the business lacks terminology to refer to their own processes and flows, and to their “entities” • Different countries use different processes and flows • We think of states instead of different entities and we have a “God model”
  • 15. API design challenges • We drag bad models from the PoC • Cluttered endpoints due to over-reuse • Very difficult to continue extending the API • 2 languages: business and data science
  • 16.
  • 17. God models: using states instead of entities
  • 19. Cluttered endpoints • POST /forecast => retrieve raw forecast • POST /forecast + adjustments => create scenario • POST /forecast + adjustments + new stores => create new store forecast • PUT /forecast/{forecast_id} => create candidate • PUT /forecast/{forecast_id} => create submission
  • 20. From states to entities Raw forecast Scenario Candidate Submission New store forecast
  • 21. Modeling operations • Stop thinking in terms of URLs and HTTP methods • Start thinking in terms of operations • Decouple your backend data model from your API models • Leverage HTTP semantics • Enforce uniform interface
  • 22. Start with operations, processes, and flows • Retrieve raw forecast • Create and update scenarios • Create and update candidate • Create submission • Create forecasts and scenarios for new stores
  • 23. Use meaningful resource endpoints and leverage HTTP semantics
  • 24. Conclusions • Changing the API is risky – can break integrations => address design issues early • Don’t think in terms of URLs and HTTP methods => think in terms of operations, processes, and flows • Don’t crudify your APIs – if an operation isn’t needed, don’t add it • Flexible models are bad => create discrete models for each entity • Clarity over reusability => don’t reuse endpoints and models
  • 25. Thanks for listening! Twitter: @JoseHaroPeralta GitHub: @abunuwas Medium: @joseharoperalta /@python-geek LinkedIn: https://www.linkedin.com/in/jose-haro-peralta/ 35% discount code: ctwapiworld22
  • 26. ADDITIONAL READINGS • Microservice APIs by J. Haro (mng.bz/nz48) • “Building and deploying reliable APIs with FastAPI” by J. Haro (https://www.twitch.tv/videos/1088283640) • Documentation-driven development for APIs by J. Haro (https://link.medium.com/m2A3rOxUfib) • “Developing API clients doesn’t need to be a pain” by J. Haro (https://link.medium.com/0B9vt7DUfib) • “How bad models ruin an API” by J. Haro (https://microapis.io/blog/how-bad-models- ruin-an-api) • “API-first development maturity framework” by J. Haro (https://microapis.io/blog/api- development-maturity)
  • 27. ADDITIONAL READINGS • “Design patterns for modern web APIs” by D. Luecke (https://blog.feathersjs.com/design-patterns-for-modern-web-apis-1f046635215) • The design of web APIs by A Lauret (https://www.manning.com/books/the-design-of- web-apis) • Designing APIs with Swagger and OpenAPI by J. S. Ponelat and L. L. Rosenstock (https://www.manning.com/books/designing-apis-with-swagger-and-openapi) • API Design Patterns by JJ Geewax (https://www.manning.com/books/api-design- patterns) • Principle of Web API Design by J. Higginbotham (https://www.pearson.com/store/p/principles-of-web-api-design-delivering-value- with-apis-and-microservices/P200000007278/9780137355631)