SlideShare a Scribd company logo
1 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Device	Independent	API	Design
PRESENTED	BY:	AMRITA	JAIN
DIRECTOR,	DIGITAL	TECHNOLOGIES,	BEACHBODY,	LLC.
MICROSERVICES+GRAPHQL+SERVERLESS
2 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Agenda
Mission Statement
Milestone1: Microservices
Milestone2: GraphQL
Milestone3: Serverless
Key Takeaways
Q & A
3 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Journey	so	far..
1990s and earlier 2000s 2014s 2017s
Monolithic
Tight coupling
Traditional SOA
Loosely coupled
Microservices
Decoupled
Serverless
Cheap decoupling
4 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Evolution	of	clients/consumption
5 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Evolution	of	APIs/	Role	of	APIs
https://www.blog.vba-market.com/2016/10/19/10-useful-real-world-api-examples/
6 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
0
2
4
6
8
10
12
14
16
18
20
Monolithic BE+FE Microservices Serverless
Platforms Subscribers Team size
Journey	I	took	at	Beachbody
Evolution of API
architecture with the
growth in
1. Platforms (1 to 6)
2. Subscribers
(200K to > 1.5M)
3. Team size (1 to 20)
* Units in 100K
2014 2015 2016 2018
7 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Design APIs that
scales with traffic, platforms, team size
and
minimizes cost in terms of dollars, personnel and latency.
Mission	Statement
8 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
“
”
Unix Philosophy
Write programs that
do one thing
and
do it well.
Write programs to
work together.
Peter H. Salus
Milestone:	
Microservices
9 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
•Independently managed, clearly defined
services.
•Each microservice owns its data-source.
•Better scaling, failover and recovery.
•Flexibility in choice of language and
deliverables.
Microservices:	Benefits
10 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
•Redundant code for common
functionality.
•Inconsistency in common behaviors.
•Harder for clients developers
•Service Discovery
•Data aggregation.
•Performance and bandwidth
constraints.
•Automation, CI/CD is non negotiable.
Microservices:	Challenges
11 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Best	practices:	Get	ahead	of	Heterogeneity
Convention over configuration
• Develop and adopt standards and
conventions
• Agree/Disagree but commit
• Reduce decision-making for common
trivial problems
12 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Best	practices:	Get	ahead	of	Heterogeneity
Custom MicroService Framework for PHP
• Enforces same code flow for all
MicroServices
• Consistent error handling and response
codes
• Circuit Breaker Failover Handling
• Provides utilities such as database, search
engine, cache wrappers
• Unifies security practices
13 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Best	practices:	Service	Discovery
API Gateway
• Route to proper microservice
• Rate Limiting
• Tracing + Debugging + Monitoring
• Caching + Invalidations
My address ?
14 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Best	Practice:	Monitoring
System-level monitoring
◦ CPU, Memory, I/O etc.
◦ StatsD, Graphite
Application-level monitoring
◦ Exceptions, error logs
APM
◦ Performance Issues & Bottlenecks
Dashboards
◦ Graphana
Which service caused failure?
15 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
“
”
Evolving
APIs
without
versions
one vertex
at a time
Lee Byron
Milestone:	
GraphQL
16 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Device specific data
• iTunes id, google account id etc.
• Device-specific features eg. showing
promo banner only on Android
• Device specific images
Response	Parity
17 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
{ "images": {
"badgeBoxArt": {},
"largeBoxArt": {},
"heroImageTablet": {},
"popularProgramMedium": {},
"devicesBannerImage": {},
"devicesStvBoxArt": {},
"devicesChromecast": {},
"devicesParallaxImage": {},
"devicesTabletHomepageLandscape1x": {},
"devicesTabletHomepageLandscape2x": {},
"devicesTabletProgramLandscape2x": {},
"devicesTabletProgramPortrait2x": {},
"devicesGlobalImage": {}
}}
Response	Parity	:	Example
18 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Performance tradeoffs
• Clients that can parallelize prefer many calls
smalls
• Other clients prefer minimal data in one call.
Bandwidth constraints
• Prefers minimal data in one go.
• Offline downloads, support batch
Performance	and	Bandwidth
19 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
• Always have to support all versions until
all users have upgraded their apps.
• Tedious & Expensive
• Developer Time (∝ O(versions))
• Error Prone (∝ O(versions))
• Testing time (∝ O(versions ×
platforms x
platformVersion))
API	versioning
20 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
GraphQL:	In	Action
21 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
GraphQL:	In	Action
22 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
ü Root node and think of data as graph.
ü Implement Graphql schema.
ü Define Query types: field on the query is processed
ü Map the underlying API/Data
ü Data manipulation can be done via resolvers
ü Need help?
ü Slack
ü User Groups
Implementation	Tips
23 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Implementation	Tips
Ref: https://github.com/webonyx/graphql-php/blob/master/examples/00-hello-world/graphql.php
curl http://localhost:8080 -d
'{"query": "query { echo(message: "Hello World") }" }'
24 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Implementation	Tips
Ref: https://github.com/webonyx/graphql-php/blob/master/examples/00-hello-world/graphql.php
curl http://localhost:8080 -d
'{"query": "query { echo(message: "Hello World") }" }'
{"data": {"echo": "You said Hello World" }}
25 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Best	practices:	Start	Small
Incremental Adoption
• Start with one client
• Start with APIs with more content-
based data
Image ref:https://www.youtube.com/watch?v=WQLzZf34FJ8
26 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Best	practices:	KISS	Principle
Thin Interface
• No extra business logic, framework
stuff.
• Depth and amount limiting
• Query cost analysis and checks.
1 Request
27 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Adding an extra layer and keeping it updated.
Workarounds:
• Apollo Graphql libs
• Dynamic schema based on Swagger:
https://github.com/amritajain/swagger-graphene
• Start here: https://github.com/chentsulin/awesome-graphql
Caveat:	Extra	Layer
28 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
“
”
Perfection
is achieved not when
there is nothing
more to add,
but
when there is
nothing left
to take away
Antoine de Saint-Exupery
Milestone:	
Serverless
29 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Serverless	Benefits
No Servers to
provision or
manage
Only pay what
you use for
Standardization
and ease of
deployments
Event driven
Scaling, built-in
availability and
fault tolerance
30 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
• Auto-scaling Websites and APIs
• Serving up static content
• Image and Video Manipulation
• Event streaming
• ETLs, Time-based batched jobs
• 30 serverless architectures in 30 minutes
Serverless:	In	Action
31 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Serverless:	Sample	yaml file
32 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Serverless:	Sample	yaml file
serverless deploy --accountID <AWS::AccountId>
--stage <dev|qa|prod>
--deploymentBucket <bucketName>
33 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Serverless:	Sample	yaml file
34 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Serverless:	Sample	yaml file
serverless deploy --accountID <AWS::AccountId>
--stage <dev|qa|prod>
--deploymentBucket <bucketName>
35 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
• Avoid fat/monolithic functions
• Optimize for language of choice
• Cloud agnostic frameworks
• Logging: Log-levels, capture device names, OS versions, and types in request
headers
• Store all environment variables separately and keep them encrypted.
Best	Practices
36 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
• Cold starts
• Invariable Demand
• Local setups: 3rd-party libs that can help
Common	Pitfalls
37 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
“
”
Nothing good
comes easy
because
nothing easy
does any good.
Unknown
Best	Practices	
&	Learnings
38 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
• Follow microservice principle: One microservice, One repo, One datasource.
• Clear lines of ownership
• Core framework: injected via composer
• Git Flow
• Dev prod parity
Learning:	Codebase
39 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Learning:	Development	Processes
Integrated into CI process
• Unittests
• Integrated with Travis
• Integration tests
• All microservice collections include
Postman tests
• Used by devs to for quick validation.
• Used by clients for parallel implementation
40 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
• Swagger
• Provide swagger documentation for every API
• Baked into the framework
• Lucidcharts
• Sequence/Architecture diagrams in Lucidcharts.
• Confluence Documentation
• Must for handoff and demo.
Learning:	Development	Processes
41 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
§ Setup patterns and standards on Day1.
§ Things change: what may seem right today might not be tomorrow, be ready
to evolve.
§ Think of APIs as a product and make it a complete package.
Key	Takeaways
42 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN
Thank	you!
@amritajain973
https://joind.in/talk/a578f
Currently @ Twitch!

More Related Content

PPTX
Cloud Native Application Development - build fast, cheap, scalable and agile ...
PPTX
Make your Cloud Applications Function for real – A Complete Overview of Oracl...
PPTX
Code with Honor – on the importance and beauty of software programming (Oracl...
PDF
API Description Languages
PDF
I Love APIs 2015 : Zero to Thousands TPS Private Cloud Operations Workshop
PDF
I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger
PDF
API Description Languages: Which Is The Right One For Me?
PPTX
Operational API design anti-patterns (Jason Harmon)
Cloud Native Application Development - build fast, cheap, scalable and agile ...
Make your Cloud Applications Function for real – A Complete Overview of Oracl...
Code with Honor – on the importance and beauty of software programming (Oracl...
API Description Languages
I Love APIs 2015 : Zero to Thousands TPS Private Cloud Operations Workshop
I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger
API Description Languages: Which Is The Right One For Me?
Operational API design anti-patterns (Jason Harmon)

What's hot (18)

PPTX
Gotta Block ‘Em All – Observations on Controlling Access to Mobile APIs using...
PPTX
Maintainable API Docs and Other Rainbow Colored Unicorns
PDF
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
PDF
Coders Workshop: API First Mobile Development Featuring Angular and Node
PDF
Cloud-native Patterns (July 4th, 2019)
PPTX
App & API Monitoring: Building a 5-Star Reputation for your Apps
PPTX
API Design Best Practices & Tech Talk : API Craft Meetup @ Apigee
PPTX
Design-first API Development using Swagger and Node
PDF
API Copyrights: New Considerations for Building or Using APIs
PPTX
API Description Languages: Which is the Right One for Me?
PDF
Delivering Mobile Apps to the Field with Oracle JET
PDF
Top 7 wrong common beliefs about Enterprise API implementation
PPT
Modernizing an Existing SOA-based Architecture with APIs
PPTX
Apigee Products Overview
PDF
Octo API-days 2015
PDF
Api Gateway
PDF
Pivotal + Apigee Workshop (June 4th, 2019)
PDF
Entity Linking and REST Patterns in SOA
Gotta Block ‘Em All – Observations on Controlling Access to Mobile APIs using...
Maintainable API Docs and Other Rainbow Colored Unicorns
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
Coders Workshop: API First Mobile Development Featuring Angular and Node
Cloud-native Patterns (July 4th, 2019)
App & API Monitoring: Building a 5-Star Reputation for your Apps
API Design Best Practices & Tech Talk : API Craft Meetup @ Apigee
Design-first API Development using Swagger and Node
API Copyrights: New Considerations for Building or Using APIs
API Description Languages: Which is the Right One for Me?
Delivering Mobile Apps to the Field with Oracle JET
Top 7 wrong common beliefs about Enterprise API implementation
Modernizing an Existing SOA-based Architecture with APIs
Apigee Products Overview
Octo API-days 2015
Api Gateway
Pivotal + Apigee Workshop (June 4th, 2019)
Entity Linking and REST Patterns in SOA
Ad

Similar to Device Independent API design (20)

PDF
API Security - OWASP top 10 for APIs + tips for pentesters
PDF
What’s behind a high quality web API? Ensure your APIs are more than just a ...
PPTX
Serverless Single Page Apps with React and Redux at ItCamp 2017
PPTX
Android Effective UI: Tips, Tricks and Patterns
PPTX
WSO2 Workshop Sydney 2016 - APIs
PDF
apidays Singapore 2023 - Beyond REST, Claudio Tag, IBM
ODP
Effective DevSecOps
PPTX
IBM API Connect Deployment `Good Practices - IBM Think 2018
PPTX
API Best Practices
PPT
How to Manage Your Cloud by Drupal (DrupalCon CPH 2010)
PDF
A Journey to Building an Autonomous Streaming Data Platform—Scaling to Trilli...
PDF
Delivering New Digital Experiences Fast - Introducing Choreo
PDF
@avanttic_meetup Oracle Technology MAD_BCN: Oracle Cloud API Platform evoluc...
PDF
Serverless - Developers.IO 2019
PDF
INTERFACE by apidays 2023 - Digital Platforms, Taking API to production, Micr...
PPTX
Achieve Full API Lifecycle Management Using NGINX Controller
PDF
nginxcontrollerapimanagementwebinar-190123215258.pdf
PDF
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
PDF
API workshop by AWS and 3scale
PDF
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
API Security - OWASP top 10 for APIs + tips for pentesters
What’s behind a high quality web API? Ensure your APIs are more than just a ...
Serverless Single Page Apps with React and Redux at ItCamp 2017
Android Effective UI: Tips, Tricks and Patterns
WSO2 Workshop Sydney 2016 - APIs
apidays Singapore 2023 - Beyond REST, Claudio Tag, IBM
Effective DevSecOps
IBM API Connect Deployment `Good Practices - IBM Think 2018
API Best Practices
How to Manage Your Cloud by Drupal (DrupalCon CPH 2010)
A Journey to Building an Autonomous Streaming Data Platform—Scaling to Trilli...
Delivering New Digital Experiences Fast - Introducing Choreo
@avanttic_meetup Oracle Technology MAD_BCN: Oracle Cloud API Platform evoluc...
Serverless - Developers.IO 2019
INTERFACE by apidays 2023 - Digital Platforms, Taking API to production, Micr...
Achieve Full API Lifecycle Management Using NGINX Controller
nginxcontrollerapimanagementwebinar-190123215258.pdf
Why Kubernetes? Cloud Native and Developer Experience at Zalando - OWL Tech &...
API workshop by AWS and 3scale
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
Ad

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Big Data Technologies - Introduction.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
KodekX | Application Modernization Development
PPT
Teaching material agriculture food technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Understanding_Digital_Forensics_Presentation.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
NewMind AI Weekly Chronicles - August'25 Week I
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
MYSQL Presentation for SQL database connectivity
Unlocking AI with Model Context Protocol (MCP)
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Big Data Technologies - Introduction.pptx
The AUB Centre for AI in Media Proposal.docx
Review of recent advances in non-invasive hemoglobin estimation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
KodekX | Application Modernization Development
Teaching material agriculture food technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Chapter 3 Spatial Domain Image Processing.pdf

Device Independent API design

  • 1. 1 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Device Independent API Design PRESENTED BY: AMRITA JAIN DIRECTOR, DIGITAL TECHNOLOGIES, BEACHBODY, LLC. MICROSERVICES+GRAPHQL+SERVERLESS
  • 2. 2 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Agenda Mission Statement Milestone1: Microservices Milestone2: GraphQL Milestone3: Serverless Key Takeaways Q & A
  • 3. 3 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Journey so far.. 1990s and earlier 2000s 2014s 2017s Monolithic Tight coupling Traditional SOA Loosely coupled Microservices Decoupled Serverless Cheap decoupling
  • 4. 4 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Evolution of clients/consumption
  • 5. 5 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Evolution of APIs/ Role of APIs https://www.blog.vba-market.com/2016/10/19/10-useful-real-world-api-examples/
  • 6. 6 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN 0 2 4 6 8 10 12 14 16 18 20 Monolithic BE+FE Microservices Serverless Platforms Subscribers Team size Journey I took at Beachbody Evolution of API architecture with the growth in 1. Platforms (1 to 6) 2. Subscribers (200K to > 1.5M) 3. Team size (1 to 20) * Units in 100K 2014 2015 2016 2018
  • 7. 7 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Design APIs that scales with traffic, platforms, team size and minimizes cost in terms of dollars, personnel and latency. Mission Statement
  • 8. 8 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN “ ” Unix Philosophy Write programs that do one thing and do it well. Write programs to work together. Peter H. Salus Milestone: Microservices
  • 9. 9 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN •Independently managed, clearly defined services. •Each microservice owns its data-source. •Better scaling, failover and recovery. •Flexibility in choice of language and deliverables. Microservices: Benefits
  • 10. 10 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN •Redundant code for common functionality. •Inconsistency in common behaviors. •Harder for clients developers •Service Discovery •Data aggregation. •Performance and bandwidth constraints. •Automation, CI/CD is non negotiable. Microservices: Challenges
  • 11. 11 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Best practices: Get ahead of Heterogeneity Convention over configuration • Develop and adopt standards and conventions • Agree/Disagree but commit • Reduce decision-making for common trivial problems
  • 12. 12 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Best practices: Get ahead of Heterogeneity Custom MicroService Framework for PHP • Enforces same code flow for all MicroServices • Consistent error handling and response codes • Circuit Breaker Failover Handling • Provides utilities such as database, search engine, cache wrappers • Unifies security practices
  • 13. 13 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Best practices: Service Discovery API Gateway • Route to proper microservice • Rate Limiting • Tracing + Debugging + Monitoring • Caching + Invalidations My address ?
  • 14. 14 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Best Practice: Monitoring System-level monitoring ◦ CPU, Memory, I/O etc. ◦ StatsD, Graphite Application-level monitoring ◦ Exceptions, error logs APM ◦ Performance Issues & Bottlenecks Dashboards ◦ Graphana Which service caused failure?
  • 15. 15 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN “ ” Evolving APIs without versions one vertex at a time Lee Byron Milestone: GraphQL
  • 16. 16 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Device specific data • iTunes id, google account id etc. • Device-specific features eg. showing promo banner only on Android • Device specific images Response Parity
  • 17. 17 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN { "images": { "badgeBoxArt": {}, "largeBoxArt": {}, "heroImageTablet": {}, "popularProgramMedium": {}, "devicesBannerImage": {}, "devicesStvBoxArt": {}, "devicesChromecast": {}, "devicesParallaxImage": {}, "devicesTabletHomepageLandscape1x": {}, "devicesTabletHomepageLandscape2x": {}, "devicesTabletProgramLandscape2x": {}, "devicesTabletProgramPortrait2x": {}, "devicesGlobalImage": {} }} Response Parity : Example
  • 18. 18 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Performance tradeoffs • Clients that can parallelize prefer many calls smalls • Other clients prefer minimal data in one call. Bandwidth constraints • Prefers minimal data in one go. • Offline downloads, support batch Performance and Bandwidth
  • 19. 19 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN • Always have to support all versions until all users have upgraded their apps. • Tedious & Expensive • Developer Time (∝ O(versions)) • Error Prone (∝ O(versions)) • Testing time (∝ O(versions × platforms x platformVersion)) API versioning
  • 20. 20 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN GraphQL: In Action
  • 21. 21 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN GraphQL: In Action
  • 22. 22 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN ü Root node and think of data as graph. ü Implement Graphql schema. ü Define Query types: field on the query is processed ü Map the underlying API/Data ü Data manipulation can be done via resolvers ü Need help? ü Slack ü User Groups Implementation Tips
  • 23. 23 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Implementation Tips Ref: https://github.com/webonyx/graphql-php/blob/master/examples/00-hello-world/graphql.php curl http://localhost:8080 -d '{"query": "query { echo(message: "Hello World") }" }'
  • 24. 24 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Implementation Tips Ref: https://github.com/webonyx/graphql-php/blob/master/examples/00-hello-world/graphql.php curl http://localhost:8080 -d '{"query": "query { echo(message: "Hello World") }" }' {"data": {"echo": "You said Hello World" }}
  • 25. 25 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Best practices: Start Small Incremental Adoption • Start with one client • Start with APIs with more content- based data Image ref:https://www.youtube.com/watch?v=WQLzZf34FJ8
  • 26. 26 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Best practices: KISS Principle Thin Interface • No extra business logic, framework stuff. • Depth and amount limiting • Query cost analysis and checks. 1 Request
  • 27. 27 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Adding an extra layer and keeping it updated. Workarounds: • Apollo Graphql libs • Dynamic schema based on Swagger: https://github.com/amritajain/swagger-graphene • Start here: https://github.com/chentsulin/awesome-graphql Caveat: Extra Layer
  • 28. 28 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN “ ” Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away Antoine de Saint-Exupery Milestone: Serverless
  • 29. 29 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Serverless Benefits No Servers to provision or manage Only pay what you use for Standardization and ease of deployments Event driven Scaling, built-in availability and fault tolerance
  • 30. 30 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN • Auto-scaling Websites and APIs • Serving up static content • Image and Video Manipulation • Event streaming • ETLs, Time-based batched jobs • 30 serverless architectures in 30 minutes Serverless: In Action
  • 31. 31 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Serverless: Sample yaml file
  • 32. 32 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Serverless: Sample yaml file serverless deploy --accountID <AWS::AccountId> --stage <dev|qa|prod> --deploymentBucket <bucketName>
  • 33. 33 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Serverless: Sample yaml file
  • 34. 34 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Serverless: Sample yaml file serverless deploy --accountID <AWS::AccountId> --stage <dev|qa|prod> --deploymentBucket <bucketName>
  • 35. 35 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN • Avoid fat/monolithic functions • Optimize for language of choice • Cloud agnostic frameworks • Logging: Log-levels, capture device names, OS versions, and types in request headers • Store all environment variables separately and keep them encrypted. Best Practices
  • 36. 36 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN • Cold starts • Invariable Demand • Local setups: 3rd-party libs that can help Common Pitfalls
  • 37. 37 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN “ ” Nothing good comes easy because nothing easy does any good. Unknown Best Practices & Learnings
  • 38. 38 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN • Follow microservice principle: One microservice, One repo, One datasource. • Clear lines of ownership • Core framework: injected via composer • Git Flow • Dev prod parity Learning: Codebase
  • 39. 39 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Learning: Development Processes Integrated into CI process • Unittests • Integrated with Travis • Integration tests • All microservice collections include Postman tests • Used by devs to for quick validation. • Used by clients for parallel implementation
  • 40. 40 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN • Swagger • Provide swagger documentation for every API • Baked into the framework • Lucidcharts • Sequence/Architecture diagrams in Lucidcharts. • Confluence Documentation • Must for handoff and demo. Learning: Development Processes
  • 41. 41 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN § Setup patterns and standards on Day1. § Things change: what may seem right today might not be tomorrow, be ready to evolve. § Think of APIs as a product and make it a complete package. Key Takeaways
  • 42. 42 DEVICE INDEPENDENT API DESIGN BY AMRITA JAIN Thank you! @amritajain973 https://joind.in/talk/a578f Currently @ Twitch!