Presented by:
Abstract: MongoDB Stitch is our new Backend as a Service (BaaS) that makes it easy for developers to create and launch applications across mobile and web platforms. Stitch provides a REST API on top of MongoDB with read, write, and validation rules built-in and full integration with the services you love. This talk will cover the what, why, and how of MongoDB Stitch. We’ll discuss everything from features to the architecture. You’ll walk away knowing how Stitch can kickstart your new project or take your existing application to the next level.
8. #MDBlocal
How requests work…
1. Application request is made
2. Stitch parses and applies rules
3. Stitch orchestrates DB + Services
3
3
9. #MDBlocal
How requests work…
1. Application request is made
2. Stitch parses and applies rules
3. Stitch orchestrates DB + Services
4. Stitch aggregates and applies rules
4
10. #MDBlocal
How requests work…
1. Application request is made
2. Stitch parses and applies rules
3. Stitch orchestrates DB + Services
4. Stitch aggregates and applies rules
5. Client receives results 5
17. client.executeFunction('sendWeather', 'Bengaluru');
MongoDB Services Functions
Stitch Concepts
//Function sendweather
exports = function(city) {
var mongodb = context.services.get("mongodb-atlas");
var UserColl = mongodb.db("StitchDemo").collection("Users");
var twilio = context.services.get("twilio");
var weather = context.services.get("weatherAPI");
var users = UserColl.find({"city": city});
var forecast = weather.get({context.values.get("weatherURL") + city});
var statuses = [];
for(var i in users){
statuses.push(twilio.send(context.values.get("twilioPhone")), users[i].Phone, forecast);
}
return statuses;
}
18. #MDBlocal
• Control DB/Service/Function access
• Fine-grained data access controls
• Define with simple JSON or link to
functions
• Associate with user profile, MongoDB
Data, or external info
Declarative Access Controls
19. #MDBlocal
Atlas
Customer Account Data
{
"owner_id": … ,
"balance": … ,
"transactions": {…},
"user_profile": {….}
}Bank Teller
Analyst
Customer
Roles,Permissions,andSecurity
Application
Reporting Data Mart
User Profile:
“I need to access my account”
Role Based:
“I need to lookup transactions
without seeing personal information”
Aggregate Only:
“I need to understand the bank’s total
cash flow”
24. #MDBlocal
Amazon S3 MongoDB
Atlas
twilio Amazon
Rekognition
2FA Access Control with Stitch
Secure IoT Client
• Bi-directional communication
• Secure com via API key auth
• Device access to DB,
functions and Services
Complex, Scalable Backend
• Deeply integrated services
• Coordination logic via
Functions
• Security through Auth + Rules
• Elastic scale
25. #MDBlocal
MongoDB
Atlas
Twilio
Amazon
Rekognition
{key: “*”}
capture_image()
{match: Drew,
Prob: 99.0%}
{user: “Drew”,
Ph#: 555-1212}
{user: Drew,
OTP: 135}
{user: Drew,
OTP: 135}
Ph#: 555-1212
{Ph#: 555-1212,
OTP: 135}
{OTP: 135}
{OTP: 135}
Amazon S3
process:
1. User requests photo + SMS
entry
2. Stitch asks ElectricImp for
photo
3. EI takes photo, sends to
Stitch
4. Stitch sends the photo to
AWS S3 and Rekognition
5. Recognition sends image
analysis
6. Stitch queries Atlas for User
7. Stitch generates an entry
code, writes log, sends text
via Twilio
8. User enters code with key
pad, ElectricImp sends to
Stitch
9. Stitch checks code against
logs
10. If the code is valid, the Stitch
sends Electric Imp a message
to unlock.
26. #MDBlocal
Pricing
• 25 GB Free per month of data transferred from to Stich to client/services
• $1 USD per GB after
• Data transfer to Atlas is free
28. #MDBlocal
• Try out Stitch – stitch.mongodb.com
• Check out SDKs and examples
• Code at github.com/mongodb/stitch-examples
• Docs at docs.mongodb.com/stitch
• Build the Dashboard or Weather IoT apps in our Tutorials section
• Ask questions or let us know what you’re building through the chat feature
What Now?