7. #MDBlocal
How requests work…
1. Application request is made
2. Stitch parses and applies rules
3. Stitch orchestrates DB + Services
3
3
8. #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
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
5. Client receives results 5
16. client.executeFunction('sendWeather', ’Sydney');
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;
}
17. #MDBlocal
• Control DB/Service/Function access
• Fine-grained data access controls
• Define with simple JSON or link to
functions
• Associate with user profile, MDB Data,
or external info
Declarative Access Controls
18. #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”
23. #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
24. #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.
25. #MDBlocal
Add Features
• Take your app to a
new platform
• Build a better
permissions
system or a
separate admin
portal
• Add additional
authentication
providers
Expose Data
• Provide an API for
safe, internal data
access
• Build a precise
permissions
system
• Create a realtime
dashboard with
authentication and
security built-in
Integrate Services
• Integrate with any
service or API with
minimal code
• Consume/action on
data in realtime
with webhooks
• Communicate with
data using text,
e-mail, slack, etc.
Complete
Backend
• Build faster without
boilerplate code
• Easily span multiple
platforms
• Scale at a moments
notice
• Single, simplified
point to manage
infrastructure/logic
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?