SlideShare a Scribd company logo
#MDBlocal
Today’s Pre-Reqs
For today’s workshop you’ll need the following:
● Computer
● NodeJS 6.0+
● Important:
○ Files: https://github.com/mongodb/stitch-examples
■ Under ‘Dashboard’
○ Documentation: https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
#MDBlocal
Agenda for this Workshop:
Intro to Stitch
+ Atlas
What we’ll
work on today
Creating a
simple API
Building a D3
Dashboard
Adding
Authentication
Next steps
with Stitch
01 02 03 04 05 06
#MDBlocal
Today’s Pre-Reqs
For today’s workshop you’ll need the following:
● Computer
● NodeJS 6.0+
● Important:
○ Files: https://github.com/mongodb/stitch-examples
■ Under ‘Dashboard’
○ Documentation: https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
Intro to Stitch
#MDBlocal
MongoDB Query Language + Native DriversIntegrated Rules
Functions 3rd Party Services
Native SDKs (iOS, Android, JS)
Rest-like API
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
Stitch let’s you control the flow of data:
Integrated services and
functions for complex,
multi-stage workflows
Native SDKs for Android,
JS, and iOS clients
Direct Database Access
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
Get Started with
Atlas
#MDBlocal
https://mongodb.com/atlas – Sign up, free.
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
Launch the cluster (Remember your password!)
#MDBlocal
Whitelist your IP
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
What we’ll work on
today
#MDBlocal
Our Data
*Point-of-sale data from a Pizza shop
(But Similar to Point-of-Sale, Log, Telemetry, etc. data you
would see elsewhere)
* Our Goal
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
1. Data enters through Stitch, flows into Atlas
2. Stitch can augment data loading:
a) Grabbing extra data from an external API
b) Taking an action on load (e-mail receipt)
3. Can expose data through API, Web/mobile
app, or Atlas
(Remember: You can also use Stitch with
an existing database too)
Behind the scenes, Stitch connects Everything
Dash +
Auth
MongoDB
Stitch
MongoDB
Atlas
Sales
Data
API Access
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
Getting Started
with Stitch
#MDBlocal
Click ‘Stitch Apps’ in Atlas
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
Create a new App
#MDBlocal
Welcome to Stitch!
#MDBlocal
Let’s start by adding Auth
#MDBlocal
Next, let’s add the Receipts Collection
#MDBlocal
Finally, copy your App ID
#MDBlocal
In Stitch, you opt-in each namespace in your
database separately for access.
1. Go to SalesReporting.Receipts
namespace
2. Delete the default Filter under ‘Filters’
3. Delete the default rules (including Owner
Id field rules)
4. Set the Top-level Document Read/Write
rules to {}
5. This enables Public read/write to this
namespace only
Next, set-up simple Access Rules:
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
Now let’s load data:
1. Open the data_generator.js file
2. Add your App ID (line 10)
3. Run data_generator.js
4. Watch data load into Stitch!
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
Creating a Simple
Public API
#MDBlocal
In Stitch, you can add a number of predefined services
to your app.
Services have predefined actions to ease integration.
We’ll use the HTTP Service to create an API to our data
1. Click ‘Services’
2. Click ‘Add a Service’
3. Click ‘HTTP’ and name your service ‘SalesAPI’
Create a HTTP Service:
#MDBlocal
Create a Webhook:
For the HTTP service, you can create an
incoming webhook that will execute a
function in response to a request.
1. Within AggregateToppings, click ‘New
Webhook’
2. Name your new webhook ‘GetSales’
3. Switch ‘Respond with Result’ ON
4. Click ‘Require Secret as Query Param’
5. Set Secret to ‘SECRET’
#MDBlocal
Get the distribution of toppings for the last 100
pizzas.
1. Function that uses aggregation to:
a) Sort the orders in descending time order
b) Limit the number of orders to 100
c) Group the orders by topping
Add a Function to the Webhook:
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
Now you can access your data via HTTP!
curl -X POST -H [WEBHOOK_URL]?secret=[SECRET] | python -m json.tool
#MDBlocal
Building a
Dashboard
#MDBlocal
Add a Function:
SalesTimeline – Get the sales for a given time
interval
1. Find all the sales in a certain timeframe
a) Projects fields down to just timestamp/total
b) Sorts by timestamp
c) Limits to 100 documents
2. Make sure function is named ‘SalesTimeline’
3. Set ‘Can Evaluate’ to {}
#MDBlocal
Again, copy your App ID
#MDBlocal
1. Open the index.html file
2. Add your App ID (line 18)
3. Go to your app directory
4. Run your app with npm start or
‘http-server &’
a) Note: You may need to install http-
server via npm (install with –g flag)
b) You can also use any other method of
opening the dashboard
Now let’s start the Dashboard:
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
Check out your Dashboard!
#MDBlocal
Adding
Authentication
#MDBlocal
1. Go to ‘Authentication’ in the Stitch UI
2. Edit Email/Password configuration
a) Click the slider to enable
b) Set Email Confirmation URL and
Email Reset URL
c) Click ‘Save’
3. Add our first e-mail/password user
a) Click the ‘Users’ tab
b) Click ‘+ Add User’
c) Enter an email address and
password of your choosing and
click ‘Create’
Add E-mail Auth:
#MDBlocal
1. Next go back to ‘Providers’, find ‘API
Key’ authentication and click ‘edit’
a) Click the slider to enable e-
mail/password authentication
b) Click ‘Create API Key,’ assign your
API Key a name, and click ‘Save’
2. Click ‘Show Key...’ and then copy key
Add an API Key:
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
1. Open the data_generator.js file
2. Comment out line 40, Uncomment line 43
3. Add your API Key (line 43)
4. Re-run data_generator.js
Add Auth to the Loader:
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
CheckAuth – Check the authentication type of a
user for a security rule
1. Take an auth type and see if the given suer
matches it.
2. Name function ‘CheckAuth’
3. Set ‘Can Evalutate’ to {}
Add a Function:
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
1. Go to rules under the rules tab of
‘mongodb-atlas’ in Stitch UI
2. In the ‘SalesReporting.Receipts’, edit the
Top-level Document Read and Write rules
(see README)
3. Add the timestamp/total fields into the
namespace
4. In both of these fields, add a read rule to
check a user’s authentication (see
README)
Set-up secure Access
Rules:
#MDBlocal
1. Open the index.html file
2. Comment out line 10, uncomment line 11
3. Re-run data_generator.js
Add Auth to the Dashboard:
https://docs.mongodb.com/stitch/getting-started/dashboard/
#MDBlocal
Check out your Dashboard (Again)!
#MDBlocal
Next Steps
#MDBlocal
• Build out a more robust public API to access your data by adding
more functions and webhooks
• Add functions and use the data to create more graphs in your
realtime dashboard
• Use one of our integrations to build extra features like e-mail receipts
for customers or a slackbot for placing an order.
• Take the ideas here and building an API or dashboard with your own
data
Have more time?
#MDBlocal
xx
Everywhere
Expand Regional footprint
Available on-premise
Bring any MongoDB
Realtime
Change Streams driven
Event-based Functions
Improve Dev
App Import/Export Tools
User/Log Management
Rules Usability
What’s Next?
#MDBlocal
• Try out Stitch – stitch.mongodb.com
• Check out SDKs and examples
• Code at github.com/MongodbStitch
• 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 Intercom
What Now?
#MDBlocal
THANK YOU
FOR JOINING!

More Related Content

What's hot (20)

PDF
Webinar: Building a Blockchain Database with MongoDB
MongoDB
 
PDF
Mongodb Spring
Norberto Leite
 
PDF
MongoDB .local Chicago 2019: A MongoDB Journey: Moving from a relational data...
MongoDB
 
PPTX
[MongoDB.local Bengaluru 2018] Jumpstart: Introduction to Schema Design
MongoDB
 
PPTX
Jumpstart: Introduction to Schema Design
MongoDB
 
PPTX
Globally Distributed RESTful Object Storage
MongoDB
 
PPTX
Operationalizing the Value of MongoDB: The MetLife Experience
MongoDB
 
PPTX
Architecture blockchain-azure
TonyEsposito19
 
PPTX
Digital Ethics and Privacy in a GDPR World
MongoDB
 
PPTX
Data Analytics: Understanding Your MongoDB Data
MongoDB
 
PPTX
MongoDB Days Silicon Valley: Jumpstart: The Right and Wrong Use Cases for Mon...
MongoDB
 
PDF
Webinar: Introducing the MongoDB Connector for BI 2.0 with Tableau
MongoDB
 
PPTX
Advanced applications with MongoDB
Norberto Leite
 
PPTX
Webinar: Elevate Your Enterprise Architecture with In-Memory Computing
MongoDB
 
PPTX
MongoDB and Azure Data Bricks - Microsoft
MongoDB
 
PPTX
Decentralization of internet of things with blockchain architecture
V C
 
PPTX
Tutorial: Building Your First App with MongoDB Stitch
MongoDB
 
PPTX
Addressing Your Backup Needs Using Ops Manager and Atlas
MongoDB
 
PPTX
Jumpstart: Introduction to MongoDB
MongoDB
 
PDF
MongoDB .local Chicago 2019: Using MongoDB Transactions to Implement Cryptogr...
MongoDB
 
Webinar: Building a Blockchain Database with MongoDB
MongoDB
 
Mongodb Spring
Norberto Leite
 
MongoDB .local Chicago 2019: A MongoDB Journey: Moving from a relational data...
MongoDB
 
[MongoDB.local Bengaluru 2018] Jumpstart: Introduction to Schema Design
MongoDB
 
Jumpstart: Introduction to Schema Design
MongoDB
 
Globally Distributed RESTful Object Storage
MongoDB
 
Operationalizing the Value of MongoDB: The MetLife Experience
MongoDB
 
Architecture blockchain-azure
TonyEsposito19
 
Digital Ethics and Privacy in a GDPR World
MongoDB
 
Data Analytics: Understanding Your MongoDB Data
MongoDB
 
MongoDB Days Silicon Valley: Jumpstart: The Right and Wrong Use Cases for Mon...
MongoDB
 
Webinar: Introducing the MongoDB Connector for BI 2.0 with Tableau
MongoDB
 
Advanced applications with MongoDB
Norberto Leite
 
Webinar: Elevate Your Enterprise Architecture with In-Memory Computing
MongoDB
 
MongoDB and Azure Data Bricks - Microsoft
MongoDB
 
Decentralization of internet of things with blockchain architecture
V C
 
Tutorial: Building Your First App with MongoDB Stitch
MongoDB
 
Addressing Your Backup Needs Using Ops Manager and Atlas
MongoDB
 
Jumpstart: Introduction to MongoDB
MongoDB
 
MongoDB .local Chicago 2019: Using MongoDB Transactions to Implement Cryptogr...
MongoDB
 

Similar to Implementing Your Full Stack App with MongoDB Stitch (Tutorial) (20)

PPTX
SH 2 - SES 1 - Stitch_Workshop_TLV.pptx
MongoDB
 
PPTX
Building Your First App with MongoDB Stitch
MongoDB
 
PPTX
MongoDB Stitch Introduction
MongoDB
 
PPTX
[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch
MongoDB
 
PPTX
Building Your First App with MongoDB Stitch
MongoDB
 
PDF
MongoDB Stitch Introduction
MongoDB
 
PPTX
SH 1 - SES 8 - Stitch_Overview_TLV.pptx
MongoDB
 
PPTX
Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Application to the Next Level...
MongoDB
 
PPTX
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB
 
PDF
Evolving your Data Access with MongoDB Stitch
MongoDB
 
PPTX
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
MongoDB
 
PPTX
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB
 
PDF
Introducing MongoDB Stitch, Backend-as-a-Service from MongoDB
MongoDB
 
PPTX
MongoDB Stich Overview
MongoDB
 
PPTX
MongoDB World 2018: Evolving your Data Access with MongoDB Stitch
MongoDB
 
PPTX
MongDB Mobile: Bringing the Power of MongoDB to Your Device
Matt Lord
 
PPTX
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB
 
PPTX
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
PPTX
MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB
 
PPTX
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
SH 2 - SES 1 - Stitch_Workshop_TLV.pptx
MongoDB
 
Building Your First App with MongoDB Stitch
MongoDB
 
MongoDB Stitch Introduction
MongoDB
 
[MongoDB.local Bengaluru 2018] Introduction to MongoDB Stitch
MongoDB
 
Building Your First App with MongoDB Stitch
MongoDB
 
MongoDB Stitch Introduction
MongoDB
 
SH 1 - SES 8 - Stitch_Overview_TLV.pptx
MongoDB
 
Ch-Ch-Ch-Ch-Changes: Taking Your MongoDB Stitch Application to the Next Level...
MongoDB
 
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB
 
Evolving your Data Access with MongoDB Stitch
MongoDB
 
Evolving your Data Access with MongoDB Stitch - Drew Di Palma
MongoDB
 
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB
 
Introducing MongoDB Stitch, Backend-as-a-Service from MongoDB
MongoDB
 
MongoDB Stich Overview
MongoDB
 
MongoDB World 2018: Evolving your Data Access with MongoDB Stitch
MongoDB
 
MongDB Mobile: Bringing the Power of MongoDB to Your Device
Matt Lord
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB
 
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB
 
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
Ad

More from MongoDB (20)

PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
PDF
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
PDF
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB
 
PDF
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB
 
PDF
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB
 
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 
PDF
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
PDF
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB
 
PDF
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB
 
PDF
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
PDF
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB
 
Ad

Recently uploaded (20)

PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 

Implementing Your Full Stack App with MongoDB Stitch (Tutorial)

  • 1. #MDBlocal Today’s Pre-Reqs For today’s workshop you’ll need the following: ● Computer ● NodeJS 6.0+ ● Important: ○ Files: https://github.com/mongodb/stitch-examples ■ Under ‘Dashboard’ ○ Documentation: https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 3. #MDBlocal Agenda for this Workshop: Intro to Stitch + Atlas What we’ll work on today Creating a simple API Building a D3 Dashboard Adding Authentication Next steps with Stitch 01 02 03 04 05 06
  • 4. #MDBlocal Today’s Pre-Reqs For today’s workshop you’ll need the following: ● Computer ● NodeJS 6.0+ ● Important: ○ Files: https://github.com/mongodb/stitch-examples ■ Under ‘Dashboard’ ○ Documentation: https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 6. #MDBlocal MongoDB Query Language + Native DriversIntegrated Rules Functions 3rd Party Services Native SDKs (iOS, Android, JS) Rest-like API https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 7. #MDBlocal Stitch let’s you control the flow of data: Integrated services and functions for complex, multi-stage workflows Native SDKs for Android, JS, and iOS clients Direct Database Access https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 9. #MDBlocal https://mongodb.com/atlas – Sign up, free. https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 10. #MDBlocal Launch the cluster (Remember your password!)
  • 13. #MDBlocal Our Data *Point-of-sale data from a Pizza shop (But Similar to Point-of-Sale, Log, Telemetry, etc. data you would see elsewhere) * Our Goal https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 14. #MDBlocal 1. Data enters through Stitch, flows into Atlas 2. Stitch can augment data loading: a) Grabbing extra data from an external API b) Taking an action on load (e-mail receipt) 3. Can expose data through API, Web/mobile app, or Atlas (Remember: You can also use Stitch with an existing database too) Behind the scenes, Stitch connects Everything Dash + Auth MongoDB Stitch MongoDB Atlas Sales Data API Access https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 16. #MDBlocal Click ‘Stitch Apps’ in Atlas https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 20. #MDBlocal Next, let’s add the Receipts Collection
  • 22. #MDBlocal In Stitch, you opt-in each namespace in your database separately for access. 1. Go to SalesReporting.Receipts namespace 2. Delete the default Filter under ‘Filters’ 3. Delete the default rules (including Owner Id field rules) 4. Set the Top-level Document Read/Write rules to {} 5. This enables Public read/write to this namespace only Next, set-up simple Access Rules: https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 23. #MDBlocal Now let’s load data: 1. Open the data_generator.js file 2. Add your App ID (line 10) 3. Run data_generator.js 4. Watch data load into Stitch! https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 25. #MDBlocal In Stitch, you can add a number of predefined services to your app. Services have predefined actions to ease integration. We’ll use the HTTP Service to create an API to our data 1. Click ‘Services’ 2. Click ‘Add a Service’ 3. Click ‘HTTP’ and name your service ‘SalesAPI’ Create a HTTP Service:
  • 26. #MDBlocal Create a Webhook: For the HTTP service, you can create an incoming webhook that will execute a function in response to a request. 1. Within AggregateToppings, click ‘New Webhook’ 2. Name your new webhook ‘GetSales’ 3. Switch ‘Respond with Result’ ON 4. Click ‘Require Secret as Query Param’ 5. Set Secret to ‘SECRET’
  • 27. #MDBlocal Get the distribution of toppings for the last 100 pizzas. 1. Function that uses aggregation to: a) Sort the orders in descending time order b) Limit the number of orders to 100 c) Group the orders by topping Add a Function to the Webhook: https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 28. #MDBlocal Now you can access your data via HTTP! curl -X POST -H [WEBHOOK_URL]?secret=[SECRET] | python -m json.tool
  • 30. #MDBlocal Add a Function: SalesTimeline – Get the sales for a given time interval 1. Find all the sales in a certain timeframe a) Projects fields down to just timestamp/total b) Sorts by timestamp c) Limits to 100 documents 2. Make sure function is named ‘SalesTimeline’ 3. Set ‘Can Evaluate’ to {}
  • 32. #MDBlocal 1. Open the index.html file 2. Add your App ID (line 18) 3. Go to your app directory 4. Run your app with npm start or ‘http-server &’ a) Note: You may need to install http- server via npm (install with –g flag) b) You can also use any other method of opening the dashboard Now let’s start the Dashboard: https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 35. #MDBlocal 1. Go to ‘Authentication’ in the Stitch UI 2. Edit Email/Password configuration a) Click the slider to enable b) Set Email Confirmation URL and Email Reset URL c) Click ‘Save’ 3. Add our first e-mail/password user a) Click the ‘Users’ tab b) Click ‘+ Add User’ c) Enter an email address and password of your choosing and click ‘Create’ Add E-mail Auth:
  • 36. #MDBlocal 1. Next go back to ‘Providers’, find ‘API Key’ authentication and click ‘edit’ a) Click the slider to enable e- mail/password authentication b) Click ‘Create API Key,’ assign your API Key a name, and click ‘Save’ 2. Click ‘Show Key...’ and then copy key Add an API Key: https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 37. #MDBlocal 1. Open the data_generator.js file 2. Comment out line 40, Uncomment line 43 3. Add your API Key (line 43) 4. Re-run data_generator.js Add Auth to the Loader: https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 38. #MDBlocal CheckAuth – Check the authentication type of a user for a security rule 1. Take an auth type and see if the given suer matches it. 2. Name function ‘CheckAuth’ 3. Set ‘Can Evalutate’ to {} Add a Function: https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 39. #MDBlocal 1. Go to rules under the rules tab of ‘mongodb-atlas’ in Stitch UI 2. In the ‘SalesReporting.Receipts’, edit the Top-level Document Read and Write rules (see README) 3. Add the timestamp/total fields into the namespace 4. In both of these fields, add a read rule to check a user’s authentication (see README) Set-up secure Access Rules:
  • 40. #MDBlocal 1. Open the index.html file 2. Comment out line 10, uncomment line 11 3. Re-run data_generator.js Add Auth to the Dashboard: https://docs.mongodb.com/stitch/getting-started/dashboard/
  • 41. #MDBlocal Check out your Dashboard (Again)!
  • 43. #MDBlocal • Build out a more robust public API to access your data by adding more functions and webhooks • Add functions and use the data to create more graphs in your realtime dashboard • Use one of our integrations to build extra features like e-mail receipts for customers or a slackbot for placing an order. • Take the ideas here and building an API or dashboard with your own data Have more time?
  • 44. #MDBlocal xx Everywhere Expand Regional footprint Available on-premise Bring any MongoDB Realtime Change Streams driven Event-based Functions Improve Dev App Import/Export Tools User/Log Management Rules Usability What’s Next?
  • 45. #MDBlocal • Try out Stitch – stitch.mongodb.com • Check out SDKs and examples • Code at github.com/MongodbStitch • 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 Intercom What Now?