SlideShare une entreprise Scribd logo
1  sur  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)

Contenu connexe

Tendances

API Security Best Practices & Guidelines
API Security Best Practices & GuidelinesAPI Security Best Practices & Guidelines
API Security Best Practices & GuidelinesPrabath Siriwardena
 
API Security Best Practices & Guidelines
API Security Best Practices & GuidelinesAPI Security Best Practices & Guidelines
API Security Best Practices & GuidelinesPrabath Siriwardena
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developersPatrick Savalle
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding RESTNitin Pande
 
APISecurity_OWASP_MitigationGuide
APISecurity_OWASP_MitigationGuide APISecurity_OWASP_MitigationGuide
APISecurity_OWASP_MitigationGuide Isabelle Mauny
 
API First Workflow: How could we have better API Docs through DevOps pipeline
API First Workflow: How could we have better API Docs through DevOps pipelineAPI First Workflow: How could we have better API Docs through DevOps pipeline
API First Workflow: How could we have better API Docs through DevOps pipelinePronovix
 
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsTessa Mero
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API PlatformJohannes Ridderstedt
 
API as-a-Product with Azure API Management (APIM)
API as-a-Product with Azure API Management (APIM)API as-a-Product with Azure API Management (APIM)
API as-a-Product with Azure API Management (APIM)Bishoy Demian
 
API Management Part 1 - An Introduction to Azure API Management
API Management Part 1 - An Introduction to Azure API ManagementAPI Management Part 1 - An Introduction to Azure API Management
API Management Part 1 - An Introduction to Azure API ManagementBizTalk360
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUDPrem Sanil
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - APIChetan Gadodia
 

Tendances (20)

API Security Best Practices & Guidelines
API Security Best Practices & GuidelinesAPI Security Best Practices & Guidelines
API Security Best Practices & Guidelines
 
API Security Best Practices & Guidelines
API Security Best Practices & GuidelinesAPI Security Best Practices & Guidelines
API Security Best Practices & Guidelines
 
How Secure Are Your APIs?
How Secure Are Your APIs?How Secure Are Your APIs?
How Secure Are Your APIs?
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
API Management in Azure
API Management in AzureAPI Management in Azure
API Management in Azure
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding REST
 
APISecurity_OWASP_MitigationGuide
APISecurity_OWASP_MitigationGuide APISecurity_OWASP_MitigationGuide
APISecurity_OWASP_MitigationGuide
 
API First Workflow: How could we have better API Docs through DevOps pipeline
API First Workflow: How could we have better API Docs through DevOps pipelineAPI First Workflow: How could we have better API Docs through DevOps pipeline
API First Workflow: How could we have better API Docs through DevOps pipeline
 
API Security Fundamentals
API Security FundamentalsAPI Security Fundamentals
API Security Fundamentals
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple Steps
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API Platform
 
API as-a-Product with Azure API Management (APIM)
API as-a-Product with Azure API Management (APIM)API as-a-Product with Azure API Management (APIM)
API as-a-Product with Azure API Management (APIM)
 
Doing REST Right
Doing REST RightDoing REST Right
Doing REST Right
 
Web API Basics
Web API BasicsWeb API Basics
Web API Basics
 
API Management Part 1 - An Introduction to Azure API Management
API Management Part 1 - An Introduction to Azure API ManagementAPI Management Part 1 - An Introduction to Azure API Management
API Management Part 1 - An Introduction to Azure API Management
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
 
Swagger
SwaggerSwagger
Swagger
 
Rest API
Rest APIRest API
Rest API
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
 

Similaire à 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
 

Similaire à 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,...
 

Dernier

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
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
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
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 

Dernier (20)

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
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
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...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

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)