SlideShare a Scribd company logo
1 of 40
Download to read offline
Building Enterprise Mobile Backends
with Open Source Platforms
Antonio Calanducci
http://www.etnatraining.it
www.etnatraining.it
Agenda
!
Overview of mBaaS features
Enterprise requirements for mobility
DreamFactory, the open source REST API
platform
Demo
Build your own mobile backend with LoopBack
Demo
www.etnatraining.it
About me
Founder of EtnaTraining

Appcelerator Training Partner

Titanium Certiļ¬ed Instructor / Developer

Tecnologyst@National Institute of Nuclear Physics
and contract professor@University of Catania, Italy

Consultant at World Food Programme, Rome

@tcaland
antonio@etnatraining.it
www.etnatraining.it
BaaS Overview
Acronym of ā€œBackend as a Serviceā€

APIs that oļ¬€er a set of predeļ¬ned services out of
the box for application developers

Example of services:

Users, Files, Collections, Custom Objects,
Email, Photos, Social Integrations, Analytics

Push Notiļ¬cations, Locations, Geofencing (m)

mBaaS: m stands for ā€œmobileā€
www.etnatraining.it
Beneļ¬ts of mBaaS
Reduce server side coding (or in some simpler
cases, eliminate)

developers can focus on front-end development;
faster schedules 

often providers oļ¬€er SDKs that wrap REST API
calls and handle in/out parameters:

both HTML/JS and native (iOS, Android,
Windows Phone)

No server setup hassle, ready to use

Deployed on the cloud, with built-in scalability
www.etnatraining.it
Popular mBaaS providers
Parse (acquired by Facebook)

JSON Objects, Social, Local Datastore, Custom server-side
login, Push

20Gb storage/2TB transfer/1M recipients/30req/s

Kinvey
AuthLinks/OAuth/Data encryption

100 active users/2Gb/5M push-emails

Appcelerator Cloud Services (ACS)
20built-in services, 5M API calls per month, 20Gb, 250k API
calls per day, Custom Server-side with Node.js
www.etnatraining.it
Commercial mBaaS for enterprise?
Generally data backed on NoSQL db

Enterprise requirements:

generally uses SQL db

integrate with legacy databases

access (structured) relational data with ACLs

Biggest problems: data privacy

where data is stored? who has access to it? is
data replicated? disaster recovery plans

Data lock-in
Any solution?
Build your OWN mBaaS
and deploy it on-premises
(or your virtual private cloud)
www.etnatraining.it
DreamFactory: enter the Service Platform
Provides access to backend services through a
standard REST APIs to:

local and remote SQL Services

storage services

NoSQL databases

No lock-in:

backend can be swapped while app is running or
switched easily from development, test,
production environments

no need to recode client apps
www.etnatraining.it
Cloud Lock-in
The API Jungle!
Developer!
Different interfaces, security
models, and!
user permissions!
NoSQL!
IaaS!
SQL!
External!Storage!
PaaS!
www.etnatraining.it
DreamFactory Service Platform
Client!
Developer!
Uniļ¬ed interface,!
security model, and!
user permissions!
NoSQL!
IaaS!
SQL!
External!Storage!
PaaS!
www.etnatraining.it
DreamFactory: features
Open Source		 

PHP/Symphony/Angular.JS

Deployable in the Cloud or on-premises

Amazon/VMWare/Azure VMs, BitNami installer

Packages for Linux Distros (RedHat, Ubuntu, Debian)

User management, user roles and permissions, and
secure password hashing

Flexible access control over applications, services, ļ¬les,
and database CRUD permissions
www.etnatraining.it
DreamFactory: features
Supported SQL DBs:

MySQL, PostgreSQL, MSSql (Oracle soon)

Supported NoSQL DBs:

MongoDB, CouchDB, DynamoDB, Azure Tables

Storage Supported:

Amazon S3, LocalStorage, OpenStack, Azure BLOB

External WebService (SOAP/REST), OAuth supported with
Portal Service

Custom server side scripts with JavaScript (V8 engine)
www.etnatraining.it
DreamFactory architecture
www.etnatraining.it
DreamFactory: client SDK
Native Mobile Clients:

iOS, Android, Windows 8

HTML5/JavaScript

AngularJS, Sencha, jQuery, PhoneGap/Cordova

Titanium SDK since version 1.5

Titanium Classic, wrapper over HTTP with Promises
www.etnatraining.it
DreamFactory Demo
www.etnatraining.it
Getting started with DreamFactory
Download the Bitnami installer or VM images at:

https://bitnami.com/stack/dreamfactory
or sign up for the Free Hosted Edition at:

https://www.dreamfactory.com/user/register
Open you browser at:

http://localhost:8080
and login to the DSP LaunchPad with your admin credentials

Create a new App, create a new Table (Schema panel), populate the
table (Data panel), browse the table via API/SDK panel

!
www.etnatraining.it
DSP REST APIs
Create an User and a Role, assign the Role to the created App and assign the
Database service to the Role

Login the user with:

curl -X POST -d '{"email": "pippo@email.com", "password": "pippo1234"}'
http://localhost:8080/rest/user/session?app_name=Todo
Keep note of the returned session_id

Fetch all the records with:

curl -H "X-DreamFactory-Session-Token: 8rena0119llqjagvfdn08kh6f2"
http://localhost:8080/rest/db/todo2?app_name=todo
Add some records with:

curl -X POST -H "X-DreamFactory-Session-Token:
8rena0119llqjagvfdn08kh6f2" -d '{"title":"new todo", "location": "somewhere",
"completed": false}' http://localhost:8080/rest/db/todo2?app_name=todo
www.etnatraining.it
Access your existing SQL DB
Create a new service of type Remote SQL DB

API name is the REST endpoint

Set the Username and Password to your DB

Set the connection string to the DB:

mysql:host=localhost;dbname=etnatraining.it
Add the new created services to the previous created Role

Access your DB through REST APIs:

curl -H "X-DreamFactory-Session-Token:
gpapq4itp198g6c38sk3gvr9j3" ā€˜http://localhost:8080/rest/
etna/wp_posts?
app_name=Todo&limit=1&post_type=feedback'
www.etnatraining.it
Titanium DreamFactory
Simple wrapper over DSP REST APIs available here:

https://github.com/dreamfactorysoftware/titanium-dreamfactory

Use JS Promises to avoid callback hell

Provided as a Common.JS module:

include dreamfactory.js and Promises.js

A simple GET request looks like this:

!
www.etnatraining.it
Trainees app
Simple Titanium Alloy App that fetches Trainees that attend to
EtnaTraining classes on Titanium

DSP used to access the www.etnatraining.itā€Ø
WordPress backend

Source code available at:

https://github.com/EtnaTraining/Trainees

!
www.etnatraining.it
DreamFactory features
App hosting for HTML5 apps
Lookup keys
Connect to existing users in SQL or NoSQL

Server Side Filters
Fine grained table permissions based on user, role, application

Server side events
events can trigger custom scripts on select, update, insert, delete,
describe

!
!
www.etnatraining.it
LoopBack
Open Source API framework powered by Node.js

Made by StrongLoop

Developers of a commercial version of Node.js with
clustering and monitoring support

contributors to Node.js and several npm packages

Allows to create REST APIs on top of enterprise data

Provides built-in services to handle:

Push Notiļ¬cations, Geolocation, Oļ¬„ine replication and
synchronization, File Storage
www.etnatraining.it
LoopBack Models
REST APIs are based on Models

deļ¬ned based on existing schema (both relational and no
relational)

open model (free form)

can be discovered automatically

can be synchronized if developer change model deļ¬nition

can be deļ¬ned in code with JavaScript APIs (both in the
client and in the server, isomorphic JS) and/or in JSON ļ¬le
with LDL (LoopBack Deļ¬nition Language)
www.etnatraining.it
LoopBack Connectors
Allows models to talk to diļ¬€erent data sources. Available
connectors:

MySQL, PostgreSQL, Oracle, MSSql

In-memory

REST

NoSQL Db (MongoSQL)
www.etnatraining.it
LoopBack Architecture
www.etnatraining.it
LoopBack features
Model relations support

deļ¬ne hasMany, belongsTo, hasAndBelongsToMany
relationships

User authentication and authorization for models:

oAuth user and registration models

Fine grained Role-based access control list

oļ¬„ine support and data replication (new!)

custom remote method deļ¬nition with events
www.etnatraining.it
Demo
www.etnatraining.it
Getting started with Loopback
Install with npm:

npm install -g strong-cli
Create a LoopBack project

slc lb project mybackend
Create a model interactively

cd mybackend
slc lb model todo -i
slc lb model anything ā€Ø
(free form model)
Run your loopback app:

node app
Browse your REST API at:
http://localhost:3000/
explorer
www.etnatraining.it
Letā€™s play with the REST APIs
Our todos model is available at:

http://localhost:3000/api/todos
Create some todo model instances:

curl -X POST -H "Content-Type:application/json" -d
'{"title": "Buy the milk", "location": "Amsterdam",
"completed": false}' http://localhost:3000/api/todos
Retrieve all the completed todos:

GET to http://localhost:3000/api/todos?ļ¬lter[where]
[completed]=true

curl 'http://localhost:3000/api/todos?ļ¬lter%5Bwhere
%5D5Bcompleted%5D=true'
www.etnatraining.it
Make the model instances persistent
Create a datasource:

slc lb datasource mylocaldb --connector mysql
Install the loopback-connector-mysql

npm install loopback-connector-mysql
Edit the datasources.json:

!
Change models.json and set:

"dataSource": "mylocaldb"
PS: You have to had previously created the todo table into the db
www.etnatraining.it
Model discovery from SQL db
Loopback provides methods to create model from existing data:

Create ļ¬rst the datasource in datasources.json:

!
Call the method discoverSchema() or discoverAndBuildModels() on
the deļ¬ned datasources:

run discovery.js:

!
!
node discovery.js >> wp_posts.json

add the discovered models to models.json
www.etnatraining.it
Some query example with ļ¬lters
Limit the number of entries

http://localhost:3000/api/WpPosts?ļ¬lter[limit]=5
Select only given ļ¬elds:

http://localhost:3000/api/WpPosts?ļ¬lter[ļ¬elds]
[postContent]=true&ļ¬lter[ļ¬elds]
[postTitle]=true&ļ¬lter[limit]=20
Select only ļ¬elds with a given value:

http://localhost:3000/api/WpPosts?ļ¬lter[where]
[postType]=feedback&ļ¬lter[limit]=3
www.etnatraining.it
Model synchronization with SQL db
We have seen how to access pre-existing data on SQL DBs

But we can also deļ¬ne new models and Loopback can create or
update DB schema for us:

Deļ¬ne the datasource

Deļ¬ne the new schemaā€Ø
(you can also in code)

call the ds.automigrate() method

WARNING: if the schema alreadyā€Ø
exists in the DB, it will be droppedā€Ø
and all data lost
www.etnatraining.it
Model synchronization with SQL db
We can also alter the model without destroying existing data, if we
change our Model:

Deļ¬ne the datasource

Deļ¬ne the new schemaā€Ø
(this can also be done in code)

call the ds.autoupdate() method

Loopback will calculate theā€Ø
diļ¬€erences between the new modelā€Ø
and table schema deļ¬nition
www.etnatraining.it
Loopback SDKs
Native Mobile SDKs:

iOS (Objective-C), Android (Java)

Browser SDKs:

Angular.JS (isomorphic LoopBack)

REST APIs

Titanium SDK?

Option 1: Use the REST API

Option 2: Alloy Wrapper (in progress) made by Aaron Saunders:

https://github.com/aaronksaunders/strongloopAlloy
www.etnatraining.it
DreamFactory vs LoopBack
DreamFactory LoopBack
No code required
CLI helps, but deļ¬nitively
required
Super easy to use
Learning curve can be quite
steep
customization is limited (server
side scripts/events)
great customization of your
REST API: itā€™s a platform and
you build an app
Classical Horizontal scaling if
you deploy on the Cloud
(OpenShift)
easy to scale and monitor with
StrongLoop cluster support and
StrongOps
Currently not supported, but
soon available
Provide speciļ¬c mobile
services: cross-platfom push
notiļ¬cation, geolocation
www.etnatraining.it
References
DreamFactory homepage

https://www.dreamfactory.com/ 

DreamFactory Documentation

http://dreamfactorysoftware.github.io

Loopback home page:

http://loopback.io/ 

Loopback documentation

http://docs.strongloop.com/display/LB/LoopBack
Thank you!

More Related Content

More from University of Catania

Lezione 03 Introduzione a react
Lezione 03   Introduzione a reactLezione 03   Introduzione a react
Lezione 03 Introduzione a reactUniversity of Catania
Ā 
Lesson 02 - React Native Development Environment Setup
Lesson 02 - React Native Development Environment SetupLesson 02 - React Native Development Environment Setup
Lesson 02 - React Native Development Environment SetupUniversity of Catania
Ā 
AbilitĆ  Informatiche - Lezione 01 introduzione al corso
AbilitĆ  Informatiche - Lezione 01   introduzione al corsoAbilitĆ  Informatiche - Lezione 01   introduzione al corso
AbilitĆ  Informatiche - Lezione 01 introduzione al corsoUniversity of Catania
Ā 
LAP II - Lezione 01 Introduzione al corso
LAP II - Lezione 01   Introduzione al corsoLAP II - Lezione 01   Introduzione al corso
LAP II - Lezione 01 Introduzione al corsoUniversity of Catania
Ā 
Lezione 02 React and React Native installation and Configuration
Lezione 02   React and  React Native installation and ConfigurationLezione 02   React and  React Native installation and Configuration
Lezione 02 React and React Native installation and ConfigurationUniversity of Catania
Ā 
Presentazione Corso LAP 2 A.A. 2016/2017
Presentazione Corso LAP 2 A.A. 2016/2017Presentazione Corso LAP 2 A.A. 2016/2017
Presentazione Corso LAP 2 A.A. 2016/2017University of Catania
Ā 
Sistemi lezione-iv-internet-e-posta-elettronica
Sistemi lezione-iv-internet-e-posta-elettronicaSistemi lezione-iv-internet-e-posta-elettronica
Sistemi lezione-iv-internet-e-posta-elettronicaUniversity of Catania
Ā 
Sistemi lezione-iii-reti-di-calcolatori
Sistemi lezione-iii-reti-di-calcolatoriSistemi lezione-iii-reti-di-calcolatori
Sistemi lezione-iii-reti-di-calcolatoriUniversity of Catania
Ā 
Sistemi lezione xv - cenni su css
Sistemi   lezione xv - cenni su cssSistemi   lezione xv - cenni su css
Sistemi lezione xv - cenni su cssUniversity of Catania
Ā 
Sistemi lezione i - Presentazione - hardware
Sistemi   lezione i - Presentazione - hardwareSistemi   lezione i - Presentazione - hardware
Sistemi lezione i - Presentazione - hardwareUniversity of Catania
Ā 
Sistemi lezione viii - google altri servizi
Sistemi   lezione viii - google altri serviziSistemi   lezione viii - google altri servizi
Sistemi lezione viii - google altri serviziUniversity of Catania
Ā 
Sistemi lezione xi - picasa web album - social bookmarking - notizie 2
Sistemi   lezione xi - picasa web album - social bookmarking - notizie 2Sistemi   lezione xi - picasa web album - social bookmarking - notizie 2
Sistemi lezione xi - picasa web album - social bookmarking - notizie 2University of Catania
Ā 
Sistemi lezione x - introduzione al web 2.0 - flickr
Sistemi   lezione x - introduzione al web 2.0 - flickrSistemi   lezione x - introduzione al web 2.0 - flickr
Sistemi lezione x - introduzione al web 2.0 - flickrUniversity of Catania
Ā 
Sistemi di elaborazione dell'informazione - Google Docs basics
Sistemi di elaborazione dell'informazione - Google Docs basicsSistemi di elaborazione dell'informazione - Google Docs basics
Sistemi di elaborazione dell'informazione - Google Docs basicsUniversity of Catania
Ā 

More from University of Catania (15)

Lezione 03 Introduzione a react
Lezione 03   Introduzione a reactLezione 03   Introduzione a react
Lezione 03 Introduzione a react
Ā 
Lesson 02 - React Native Development Environment Setup
Lesson 02 - React Native Development Environment SetupLesson 02 - React Native Development Environment Setup
Lesson 02 - React Native Development Environment Setup
Ā 
AbilitĆ  Informatiche - Lezione 01 introduzione al corso
AbilitĆ  Informatiche - Lezione 01   introduzione al corsoAbilitĆ  Informatiche - Lezione 01   introduzione al corso
AbilitĆ  Informatiche - Lezione 01 introduzione al corso
Ā 
LAP II - Lezione 01 Introduzione al corso
LAP II - Lezione 01   Introduzione al corsoLAP II - Lezione 01   Introduzione al corso
LAP II - Lezione 01 Introduzione al corso
Ā 
Lezione 02 React and React Native installation and Configuration
Lezione 02   React and  React Native installation and ConfigurationLezione 02   React and  React Native installation and Configuration
Lezione 02 React and React Native installation and Configuration
Ā 
Presentazione Corso LAP 2 A.A. 2016/2017
Presentazione Corso LAP 2 A.A. 2016/2017Presentazione Corso LAP 2 A.A. 2016/2017
Presentazione Corso LAP 2 A.A. 2016/2017
Ā 
Sistemi lezione-iv-internet-e-posta-elettronica
Sistemi lezione-iv-internet-e-posta-elettronicaSistemi lezione-iv-internet-e-posta-elettronica
Sistemi lezione-iv-internet-e-posta-elettronica
Ā 
Sistemi lezione-iii-reti-di-calcolatori
Sistemi lezione-iii-reti-di-calcolatoriSistemi lezione-iii-reti-di-calcolatori
Sistemi lezione-iii-reti-di-calcolatori
Ā 
Sistemi lezione-ii
Sistemi lezione-iiSistemi lezione-ii
Sistemi lezione-ii
Ā 
Sistemi lezione xv - cenni su css
Sistemi   lezione xv - cenni su cssSistemi   lezione xv - cenni su css
Sistemi lezione xv - cenni su css
Ā 
Sistemi lezione i - Presentazione - hardware
Sistemi   lezione i - Presentazione - hardwareSistemi   lezione i - Presentazione - hardware
Sistemi lezione i - Presentazione - hardware
Ā 
Sistemi lezione viii - google altri servizi
Sistemi   lezione viii - google altri serviziSistemi   lezione viii - google altri servizi
Sistemi lezione viii - google altri servizi
Ā 
Sistemi lezione xi - picasa web album - social bookmarking - notizie 2
Sistemi   lezione xi - picasa web album - social bookmarking - notizie 2Sistemi   lezione xi - picasa web album - social bookmarking - notizie 2
Sistemi lezione xi - picasa web album - social bookmarking - notizie 2
Ā 
Sistemi lezione x - introduzione al web 2.0 - flickr
Sistemi   lezione x - introduzione al web 2.0 - flickrSistemi   lezione x - introduzione al web 2.0 - flickr
Sistemi lezione x - introduzione al web 2.0 - flickr
Ā 
Sistemi di elaborazione dell'informazione - Google Docs basics
Sistemi di elaborazione dell'informazione - Google Docs basicsSistemi di elaborazione dell'informazione - Google Docs basics
Sistemi di elaborazione dell'informazione - Google Docs basics
Ā 

Recently uploaded

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
Ā 
Scaling API-first ā€“ The story of a global engineering organization
Scaling API-first ā€“ The story of a global engineering organizationScaling API-first ā€“ The story of a global engineering organization
Scaling API-first ā€“ The story of a global engineering organizationRadu Cotescu
Ā 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
Ā 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
Ā 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
Ā 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
Ā 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
Ā 
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge GraphSIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge GraphNeo4j
Ā 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
Ā 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
Ā 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
Ā 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
Ā 
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
Ā 
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | DelhiFULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhisoniya singh
Ā 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
Ā 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
Ā 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
Ā 

Recently uploaded (20)

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Ā 
Scaling API-first ā€“ The story of a global engineering organization
Scaling API-first ā€“ The story of a global engineering organizationScaling API-first ā€“ The story of a global engineering organization
Scaling API-first ā€“ The story of a global engineering organization
Ā 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
Ā 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Ā 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
Ā 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Ā 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
Ā 
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge GraphSIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
Ā 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
Ā 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
Ā 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Ā 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Ā 
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Ā 
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | DelhiFULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
Ā 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Ā 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
Ā 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Ā 

Building Enterprise Mobile Backends with Open Source Platforms

  • 1. Building Enterprise Mobile Backends with Open Source Platforms Antonio Calanducci http://www.etnatraining.it
  • 2. www.etnatraining.it Agenda ! Overview of mBaaS features Enterprise requirements for mobility DreamFactory, the open source REST API platform Demo Build your own mobile backend with LoopBack Demo
  • 3. www.etnatraining.it About me Founder of EtnaTraining Appcelerator Training Partner Titanium Certiļ¬ed Instructor / Developer Tecnologyst@National Institute of Nuclear Physics and contract professor@University of Catania, Italy Consultant at World Food Programme, Rome @tcaland antonio@etnatraining.it
  • 4. www.etnatraining.it BaaS Overview Acronym of ā€œBackend as a Serviceā€ APIs that oļ¬€er a set of predeļ¬ned services out of the box for application developers Example of services: Users, Files, Collections, Custom Objects, Email, Photos, Social Integrations, Analytics Push Notiļ¬cations, Locations, Geofencing (m) mBaaS: m stands for ā€œmobileā€
  • 5. www.etnatraining.it Beneļ¬ts of mBaaS Reduce server side coding (or in some simpler cases, eliminate) developers can focus on front-end development; faster schedules often providers oļ¬€er SDKs that wrap REST API calls and handle in/out parameters: both HTML/JS and native (iOS, Android, Windows Phone) No server setup hassle, ready to use Deployed on the cloud, with built-in scalability
  • 6. www.etnatraining.it Popular mBaaS providers Parse (acquired by Facebook) JSON Objects, Social, Local Datastore, Custom server-side login, Push 20Gb storage/2TB transfer/1M recipients/30req/s Kinvey AuthLinks/OAuth/Data encryption 100 active users/2Gb/5M push-emails Appcelerator Cloud Services (ACS) 20built-in services, 5M API calls per month, 20Gb, 250k API calls per day, Custom Server-side with Node.js
  • 7. www.etnatraining.it Commercial mBaaS for enterprise? Generally data backed on NoSQL db Enterprise requirements: generally uses SQL db integrate with legacy databases access (structured) relational data with ACLs Biggest problems: data privacy where data is stored? who has access to it? is data replicated? disaster recovery plans Data lock-in
  • 9. Build your OWN mBaaS and deploy it on-premises (or your virtual private cloud)
  • 10. www.etnatraining.it DreamFactory: enter the Service Platform Provides access to backend services through a standard REST APIs to: local and remote SQL Services storage services NoSQL databases No lock-in: backend can be swapped while app is running or switched easily from development, test, production environments no need to recode client apps
  • 11. www.etnatraining.it Cloud Lock-in The API Jungle! Developer! Different interfaces, security models, and! user permissions! NoSQL! IaaS! SQL! External!Storage! PaaS!
  • 12. www.etnatraining.it DreamFactory Service Platform Client! Developer! Uniļ¬ed interface,! security model, and! user permissions! NoSQL! IaaS! SQL! External!Storage! PaaS!
  • 13. www.etnatraining.it DreamFactory: features Open Source PHP/Symphony/Angular.JS Deployable in the Cloud or on-premises Amazon/VMWare/Azure VMs, BitNami installer Packages for Linux Distros (RedHat, Ubuntu, Debian) User management, user roles and permissions, and secure password hashing Flexible access control over applications, services, ļ¬les, and database CRUD permissions
  • 14. www.etnatraining.it DreamFactory: features Supported SQL DBs: MySQL, PostgreSQL, MSSql (Oracle soon) Supported NoSQL DBs: MongoDB, CouchDB, DynamoDB, Azure Tables Storage Supported: Amazon S3, LocalStorage, OpenStack, Azure BLOB External WebService (SOAP/REST), OAuth supported with Portal Service Custom server side scripts with JavaScript (V8 engine)
  • 16. www.etnatraining.it DreamFactory: client SDK Native Mobile Clients: iOS, Android, Windows 8 HTML5/JavaScript AngularJS, Sencha, jQuery, PhoneGap/Cordova Titanium SDK since version 1.5 Titanium Classic, wrapper over HTTP with Promises
  • 18. www.etnatraining.it Getting started with DreamFactory Download the Bitnami installer or VM images at: https://bitnami.com/stack/dreamfactory or sign up for the Free Hosted Edition at: https://www.dreamfactory.com/user/register Open you browser at: http://localhost:8080 and login to the DSP LaunchPad with your admin credentials Create a new App, create a new Table (Schema panel), populate the table (Data panel), browse the table via API/SDK panel !
  • 19. www.etnatraining.it DSP REST APIs Create an User and a Role, assign the Role to the created App and assign the Database service to the Role Login the user with: curl -X POST -d '{"email": "pippo@email.com", "password": "pippo1234"}' http://localhost:8080/rest/user/session?app_name=Todo Keep note of the returned session_id Fetch all the records with: curl -H "X-DreamFactory-Session-Token: 8rena0119llqjagvfdn08kh6f2" http://localhost:8080/rest/db/todo2?app_name=todo Add some records with: curl -X POST -H "X-DreamFactory-Session-Token: 8rena0119llqjagvfdn08kh6f2" -d '{"title":"new todo", "location": "somewhere", "completed": false}' http://localhost:8080/rest/db/todo2?app_name=todo
  • 20. www.etnatraining.it Access your existing SQL DB Create a new service of type Remote SQL DB API name is the REST endpoint Set the Username and Password to your DB Set the connection string to the DB: mysql:host=localhost;dbname=etnatraining.it Add the new created services to the previous created Role Access your DB through REST APIs: curl -H "X-DreamFactory-Session-Token: gpapq4itp198g6c38sk3gvr9j3" ā€˜http://localhost:8080/rest/ etna/wp_posts? app_name=Todo&limit=1&post_type=feedback'
  • 21. www.etnatraining.it Titanium DreamFactory Simple wrapper over DSP REST APIs available here: https://github.com/dreamfactorysoftware/titanium-dreamfactory Use JS Promises to avoid callback hell Provided as a Common.JS module: include dreamfactory.js and Promises.js A simple GET request looks like this: !
  • 22. www.etnatraining.it Trainees app Simple Titanium Alloy App that fetches Trainees that attend to EtnaTraining classes on Titanium DSP used to access the www.etnatraining.itā€Ø WordPress backend Source code available at: https://github.com/EtnaTraining/Trainees !
  • 23. www.etnatraining.it DreamFactory features App hosting for HTML5 apps Lookup keys Connect to existing users in SQL or NoSQL Server Side Filters Fine grained table permissions based on user, role, application Server side events events can trigger custom scripts on select, update, insert, delete, describe ! !
  • 24. www.etnatraining.it LoopBack Open Source API framework powered by Node.js Made by StrongLoop Developers of a commercial version of Node.js with clustering and monitoring support contributors to Node.js and several npm packages Allows to create REST APIs on top of enterprise data Provides built-in services to handle: Push Notiļ¬cations, Geolocation, Oļ¬„ine replication and synchronization, File Storage
  • 25. www.etnatraining.it LoopBack Models REST APIs are based on Models deļ¬ned based on existing schema (both relational and no relational) open model (free form) can be discovered automatically can be synchronized if developer change model deļ¬nition can be deļ¬ned in code with JavaScript APIs (both in the client and in the server, isomorphic JS) and/or in JSON ļ¬le with LDL (LoopBack Deļ¬nition Language)
  • 26. www.etnatraining.it LoopBack Connectors Allows models to talk to diļ¬€erent data sources. Available connectors: MySQL, PostgreSQL, Oracle, MSSql In-memory REST NoSQL Db (MongoSQL)
  • 28. www.etnatraining.it LoopBack features Model relations support deļ¬ne hasMany, belongsTo, hasAndBelongsToMany relationships User authentication and authorization for models: oAuth user and registration models Fine grained Role-based access control list oļ¬„ine support and data replication (new!) custom remote method deļ¬nition with events
  • 30. www.etnatraining.it Getting started with Loopback Install with npm: npm install -g strong-cli Create a LoopBack project slc lb project mybackend Create a model interactively cd mybackend slc lb model todo -i slc lb model anything ā€Ø (free form model) Run your loopback app: node app Browse your REST API at: http://localhost:3000/ explorer
  • 31. www.etnatraining.it Letā€™s play with the REST APIs Our todos model is available at: http://localhost:3000/api/todos Create some todo model instances: curl -X POST -H "Content-Type:application/json" -d '{"title": "Buy the milk", "location": "Amsterdam", "completed": false}' http://localhost:3000/api/todos Retrieve all the completed todos: GET to http://localhost:3000/api/todos?ļ¬lter[where] [completed]=true curl 'http://localhost:3000/api/todos?ļ¬lter%5Bwhere %5D5Bcompleted%5D=true'
  • 32. www.etnatraining.it Make the model instances persistent Create a datasource: slc lb datasource mylocaldb --connector mysql Install the loopback-connector-mysql npm install loopback-connector-mysql Edit the datasources.json: ! Change models.json and set: "dataSource": "mylocaldb" PS: You have to had previously created the todo table into the db
  • 33. www.etnatraining.it Model discovery from SQL db Loopback provides methods to create model from existing data: Create ļ¬rst the datasource in datasources.json: ! Call the method discoverSchema() or discoverAndBuildModels() on the deļ¬ned datasources: run discovery.js: ! ! node discovery.js >> wp_posts.json add the discovered models to models.json
  • 34. www.etnatraining.it Some query example with ļ¬lters Limit the number of entries http://localhost:3000/api/WpPosts?ļ¬lter[limit]=5 Select only given ļ¬elds: http://localhost:3000/api/WpPosts?ļ¬lter[ļ¬elds] [postContent]=true&ļ¬lter[ļ¬elds] [postTitle]=true&ļ¬lter[limit]=20 Select only ļ¬elds with a given value: http://localhost:3000/api/WpPosts?ļ¬lter[where] [postType]=feedback&ļ¬lter[limit]=3
  • 35. www.etnatraining.it Model synchronization with SQL db We have seen how to access pre-existing data on SQL DBs But we can also deļ¬ne new models and Loopback can create or update DB schema for us: Deļ¬ne the datasource Deļ¬ne the new schemaā€Ø (you can also in code) call the ds.automigrate() method WARNING: if the schema alreadyā€Ø exists in the DB, it will be droppedā€Ø and all data lost
  • 36. www.etnatraining.it Model synchronization with SQL db We can also alter the model without destroying existing data, if we change our Model: Deļ¬ne the datasource Deļ¬ne the new schemaā€Ø (this can also be done in code) call the ds.autoupdate() method Loopback will calculate theā€Ø diļ¬€erences between the new modelā€Ø and table schema deļ¬nition
  • 37. www.etnatraining.it Loopback SDKs Native Mobile SDKs: iOS (Objective-C), Android (Java) Browser SDKs: Angular.JS (isomorphic LoopBack) REST APIs Titanium SDK? Option 1: Use the REST API Option 2: Alloy Wrapper (in progress) made by Aaron Saunders: https://github.com/aaronksaunders/strongloopAlloy
  • 38. www.etnatraining.it DreamFactory vs LoopBack DreamFactory LoopBack No code required CLI helps, but deļ¬nitively required Super easy to use Learning curve can be quite steep customization is limited (server side scripts/events) great customization of your REST API: itā€™s a platform and you build an app Classical Horizontal scaling if you deploy on the Cloud (OpenShift) easy to scale and monitor with StrongLoop cluster support and StrongOps Currently not supported, but soon available Provide speciļ¬c mobile services: cross-platfom push notiļ¬cation, geolocation
  • 39. www.etnatraining.it References DreamFactory homepage https://www.dreamfactory.com/ DreamFactory Documentation http://dreamfactorysoftware.github.io Loopback home page: http://loopback.io/ Loopback documentation http://docs.strongloop.com/display/LB/LoopBack