SlideShare a Scribd company logo
1 of 45
Building a Mobile App!
Part 1
{ name: ‘Bryan Reinero’,
title: ‘Developer Advocate’,
twitter: ‘@blimpyacht’,
code: ‘github.com/breinero’
email: ‘bryan@mongdb.com’ }
2
Track Agenda
• Part 1: Architecture and Application Design
• Part 2: Geo-Spatial Indexing and Queries
• Part 3:Deployment Readiness
3
Mobile Applications
• Location based data
• User relevance
• Context Rich
• Social Engagement
4
The Scavenger Hunt App
Users create
scavenger hunts by
“pinning” waypoints
5
The Scavenger Hunt App
Players search for a
scavenger hunt
near their current
position
6
The Scavenger Hunt App
Basic Requirements
7
The Scavenger Hunt App
Basic Requirements
• Mark target points
8
The Scavenger Hunt App
Basic Requirements
• Mark target points
• Identify our users
9
The Scavenger Hunt App
Basic Requirements
• Mark target points
• Identify our users
• Mark users’ progress
during hunts
Schema Design
11
The Scavenger Hunt App
Users create
scavenger hunts by
“pinning” waypoints
12
Waypoint
{ _id: ObjectId(),
user: UUID,
tour: UUDI
name: "Doug's Dogs",
desc: "The best hot-dog",
clues: [
"Hungry for a Coney Island?",
"Ask for Dr. Frankenfurter",
"Look for the hot dog stand"
],
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1] }
};
13
Waypoint
{ _id: ObjectId(),
user: UUID,
tour: UUDI
name: "Doug's Dogs",
desc: "The best hot-dog",
clues: [
"Hungry for a Coney Island?",
"Ask for Dr. Frankenfurter",
"Look for the hot dog stand"
],
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1] }
};
14
Waypoint
{ _id: ObjectId(),
user: UUID,
tour: UUDI
name: "Doug's Dogs",
desc: "The best hot-dog",
clues: [
"Hungry for a Coney Island?",
"Ask for Dr. Frankenfurter",
"Look for the hot dog stand"
],
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1] }
};
Geospacial Index:
ensureIndex(
{ geometry: “2dsphere” }
)
15
Waypoint
Mobile Client
16
Waypoint
Application ServerMobile Client
RESTful Service
scavenger.com/waypoints?lat=40.87&lon=-73.87&max=100
HTTP GET
17
Waypoint
Application Server DatabaseMobile Client
RESTful Service
scavenger.com/waypoints?lat=40.87&lon=-73.87&max=100
HTTP GET
18
Waypoint
Application Server DatabaseMobile Client
RESTful Service
scavenger.com/waypoints?lat=40.87&lon=-73.87&max=100
HTTP GET
Query
{ ‘$geoNear’: {
‘$geometry’: {
type: "Point",
coordinates: [ -174.9559, 40.6544 ]
},
‘maxDistance’: 100
}
19
The Scavenger Hunt App
Basic Requirements
• Mark target points
• Identify our users
• Mark users’ progress
during hunts
20
The Checkpoint Document
{
_id: ObjectId(),
user: UUID,
huntId: UUID,
timestamp: ISODate(),
geometry: {
type: "Point",
coordinates: [ long, lat ]
}
}
21
The Scavenger Hunt App
Social Requirements
• Allow users to follow one
another
• Allow users to exchange
messages
• Send users notifications
22
Social Interactions
Eratosthenes
Democritus
Hypatia
Shemp
Euripides
23
User Collection
{
_id: UUID,
name: “Bryan Reinero’,
email: “bryan@mongodb.com”,
pass: “dontyouwishyouknew”,
description: “I am just a guy”,
followers: [
“Achille”,
“Jason”,
“Steffan”,
“Norm”
]
}
24
Social Interactions
Followers Collection
{ follower: ‘Shemp’, followed: ‘Euripides’},
{ follower:‘Shemp’, followed: ’Eratosthenes”},
{ follower: “Eratosthenes’, followed: ‘Shemp’ },
…
Eratosthenes
Democritus
Hypatia
Shemp
Euripides
25
Social Interactions
Eratosthenes
Democritus
Hypatia
Shemp
Euripides
Followers Collection
{ follower: ‘Shemp’, followed: ‘Euripides’},
{ follower:‘Shemp’, followed: ’Eratosthenes”},
{ follower: “Eratosthenes’, followed: ‘Shemp’ },
…
! (Euripides -> Shemp )
26
Social Interactions
db.followers.find( { follower:‘Shemp’ } );
Followers Collection
{ follower: ‘Shemp’, followed: ‘Euripides’},
{ follower:‘Shemp’, followed: ’Eratosthenes”},
{ follower: “Eratosthenes’, followed: ‘Shemp’ },
…
27
Notifications / Messaging
Message
{
sender: “Hypatia”,
recipients: [
“Democritus”,
“Euripides”,
“Eratosthenes”
]
date: ISODate(),
message: “truth is a point of view, and
so is changeable”
}
28
Notifications / Messaging
Message
{
sender: “Hypatia”,
recipients: [
“Democritus”,
“Euripides”,
“Eratosthenes”
]
date: ISODate(),
message: “truth is a point of view, and
so is changeable”
}
db.messages.find(
{ recipients: “Democritus”}
);
29
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
Notifications / Messaging
db.messages.find( ‘outbox.user’: ‘Hypatia’ );
db.messages.find( ‘outbox.user’: ‘Euripides’);
db.messages.find( ‘outbox.user’: ‘Democritus’);
db.messages.find( ‘outbox.user’: ‘Shemp’);
Read
30
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
Notifications / Messaging
db.messages.find( ‘outbox.user’: ‘Hypatia’ );
db.messages.find( ‘outbox.user’: ‘Euripides’);
db.messages.find( ‘outbox.user’: ‘Democritus’);
db.messages.find( ‘outbox.user’: ‘Shemp’);
Read
31
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
Notifications / Messaging
db.messages.find( ‘outbox.user’: ‘Hypatia’ );
db.messages.find( ‘outbox.user’: ‘Euripides’);
db.messages.find( ‘outbox.user’: ‘Democritus’);
db.messages.find( ‘outbox.user’: ‘Shemp’);
Read
32
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
OUTBOX
Notifications / Messaging
db.messages.find( ‘outbox.user’: ‘Hypatia’ );
db.messages.find( ‘outbox.user’: ‘Euripides’);
db.messages.find( ‘outbox.user’: ‘Democritus’);
db.messages.find( ‘outbox.user’: ‘Shemp’);
Read
33
One Document per Message per Recipient
{
sender: “Hypatia”,
recipient: “Democritus”,
date: ISODate(),
message: “truth is a point of view, and so is changeable”
}
{
sender: “Hypatia”,
recipient: “Euripides”,
date: ISODate(),
message: “truth is a point of view, and so is changeable”
}
{
sender: “Hypatia”,
recipient: “Eratosthenes”,
date: ISODate(),
message: “truth is a point of view, and so is changeable”
}
34
Inbox Buckets
Hypatia
Message
Message
Message
Hypatia
Message
Message
Message
Hypatia
Message
Message
Message
…
35
Notifications / Messaging
{user: “Hypatia”,
ctime: ISODate(),
mtime: ISODate(),
count: 10,
inbox: [
<message>,
<message>,
<message>,
…
]
}
36
Write to Bucket
function addToBucket( user, item,bucketSize )
{
var query = {
user: user,
count: { $lt: bucketSize }
};
db.notifications.update(
query,
{
$push: { messages: item },
$set: { mtime: ISODate() },
$inc: { count: 1 },
$setOnInsert: {
startDate: ISODate() }
},
{ upsert: true }
);
}
37
Write to Bucket
Parameters
• user bucket owner
• item notification message
• bucketSize limits number of messages / document
function addToBucket( user, item, bucketSize )
{
var query = {
user: user,
count: { $lt: bucketSize }
};
db.notifications.update(
query,
{
$push: { messages: item },
$set: { mtime: ISODate() },
$inc: { count: 1 },
$setOnInsert: {
startDate: ISODate() }
},
{ upsert: true }
);
}
38
Write to Bucket
Parameters
• user bucket owner
• item notification message
• bucketSize limits number of messages / document
Query
Don’t update full bucket
function addToBucket( user, item,bucketSize )
{
var query = {
user: user,
count: { $lt: bucketSize }
};
db.notifications.update(
query,
{
$push: { messages: item },
$set: { mtime: ISODate() },
$inc: { count: 1 },
$setOnInsert: {
startDate: ISODate() }
},
{ upsert: true }
);
}
39
Write to Bucket
Parameters
• user bucket owner
• item notification message
• bucketSize limits number of messages / document
Query
Don’t update full bucket
Update
• Append item to message array,
• Update the mtime with current timestamp
• Increment the size of the bucket
function addToBucket( user, item,bucketSize )
{
var query = {
user: user,
count: { $lt: bucketSize }
};
db.notifications.update(
query,
{
$push: { messages: item },
$set: { mtime: ISODate() },
$inc: { count: 1 },
$setOnInsert: {
startDate: ISODate() }
},
{ upsert: true }
);
}
40
Write to Bucket
Parameters
• user bucket owner
• item notification message
• bucketSize limits number of messages / document
Query
Don’t update full bucket
Update
• Append item to message array,
• Update the mtime with current timestamp
• Increment the size of the bucket
Upsert
Create a new bucket
function addToBucket( user, item,bucketSize )
{
var query = {
user: user,
count: { $lt: bucketSize }
};
db.notifications.update(
query,
{
$push: { messages: item },
$set: { mtime: ISODate() },
$inc: { count: 1 },
$setOnInsert: {
startDate: ISODate() }
},
{ upsert: true }
);
}
41
Personal Timeline / Hotlist
{
_id: UUID,
user: ”Democritus",
hotList" : [
{
message: "New scavenger hunt tomorrow!",
url: "http://bit.ly/1hKn9ff",
date" : ISODate()
},
{
message: "Get 50% off at Toga City",
url: "http://bit.ly/1KnlFHQ",
date: ISODate()
}
],
atime: ISODate("20150313T04:38:43.606Z")
}
42
Personal Timeline / Hotlist
Notifications of highest
user relevance
{
_id: UUID,
user: ”Democritus",
hotList" : [
{
message: "New scavenger hunt tomorrow!",
url: "http://bit.ly/1hKn9ff",
date" : ISODate()
},
{
message: "Get 50% off at Toga City",
url: "http://bit.ly/1KnlFHQ",
date: ISODate()
}
],
atime: ISODate("20150313T04:38:43.606Z")
}
43
Personal Timeline / Hotlist
db.user.update(
{"user" : "Democritus"},
{$push : { ”hotList” : {
$each : [ { <MESSAGE> } ],
$slice : -50 }
}},
false, false)
44
Production Ready Architecture
Application Servers Replica SetMobile Client
L.B.
Thanks!
{ name: ‘Bryan Reinero’,
title: ‘Developer Advocate’,
twitter: ‘@blimpyacht’,
code: ‘github.com/breinero’
email: ‘bryan@mongdb.com’ }

More Related Content

Similar to Building Mobile App Architecture

Systems of engagement
Systems of engagementSystems of engagement
Systems of engagementBryan Reinero
 
Context Information Management in IoT enabled smart systems - the basics
Context Information Management in IoT enabled smart systems - the basicsContext Information Management in IoT enabled smart systems - the basics
Context Information Management in IoT enabled smart systems - the basicsFernando Lopez Aguilar
 
User Data Management with MongoDB
User Data Management with MongoDB User Data Management with MongoDB
User Data Management with MongoDB MongoDB
 
Montreal Elasticsearch Meetup
Montreal Elasticsearch MeetupMontreal Elasticsearch Meetup
Montreal Elasticsearch MeetupLoïc Bertron
 
Practical MongoDB
Practical MongoDBPractical MongoDB
Practical MongoDBWill Button
 
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"South Tyrol Free Software Conference
 
Redis data modeling examples
Redis data modeling examplesRedis data modeling examples
Redis data modeling examplesTerry Cho
 
Building a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and JavaBuilding a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and Javaantoinegirbal
 
API-Entwicklung bei XING
API-Entwicklung bei XINGAPI-Entwicklung bei XING
API-Entwicklung bei XINGMark Schmidt
 
Marc s01 e02-crud-database
Marc s01 e02-crud-databaseMarc s01 e02-crud-database
Marc s01 e02-crud-databaseMongoDB
 
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...MongoDB
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responsesdarrelmiller71
 
Operational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB WebinarOperational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB WebinarMongoDB
 
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.GeeksLab Odessa
 
Extensible RESTful Applications with Apache TinkerPop
Extensible RESTful Applications with Apache TinkerPopExtensible RESTful Applications with Apache TinkerPop
Extensible RESTful Applications with Apache TinkerPopVarun Ganesh
 
How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6Maxime Beugnet
 
Schema design
Schema designSchema design
Schema designchristkv
 
Orion Context Broker
Orion Context Broker Orion Context Broker
Orion Context Broker TIDChile
 
S01 e01 schema-design
S01 e01 schema-designS01 e01 schema-design
S01 e01 schema-designMongoDB
 

Similar to Building Mobile App Architecture (20)

Systems of engagement
Systems of engagementSystems of engagement
Systems of engagement
 
Internet of things
Internet of thingsInternet of things
Internet of things
 
Context Information Management in IoT enabled smart systems - the basics
Context Information Management in IoT enabled smart systems - the basicsContext Information Management in IoT enabled smart systems - the basics
Context Information Management in IoT enabled smart systems - the basics
 
User Data Management with MongoDB
User Data Management with MongoDB User Data Management with MongoDB
User Data Management with MongoDB
 
Montreal Elasticsearch Meetup
Montreal Elasticsearch MeetupMontreal Elasticsearch Meetup
Montreal Elasticsearch Meetup
 
Practical MongoDB
Practical MongoDBPractical MongoDB
Practical MongoDB
 
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
 
Redis data modeling examples
Redis data modeling examplesRedis data modeling examples
Redis data modeling examples
 
Building a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and JavaBuilding a Scalable Inbox System with MongoDB and Java
Building a Scalable Inbox System with MongoDB and Java
 
API-Entwicklung bei XING
API-Entwicklung bei XINGAPI-Entwicklung bei XING
API-Entwicklung bei XING
 
Marc s01 e02-crud-database
Marc s01 e02-crud-databaseMarc s01 e02-crud-database
Marc s01 e02-crud-database
 
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responses
 
Operational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB WebinarOperational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB Webinar
 
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
Java/Scala Lab: Борис Трофимов - Обжигающая Big Data.
 
Extensible RESTful Applications with Apache TinkerPop
Extensible RESTful Applications with Apache TinkerPopExtensible RESTful Applications with Apache TinkerPop
Extensible RESTful Applications with Apache TinkerPop
 
How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6
 
Schema design
Schema designSchema design
Schema design
 
Orion Context Broker
Orion Context Broker Orion Context Broker
Orion Context Broker
 
S01 e01 schema-design
S01 e01 schema-designS01 e01 schema-design
S01 e01 schema-design
 

More from MongoDB

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
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 SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump StartMongoDB
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
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 .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
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 .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
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 .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
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 .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB
 
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDBMongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDBMongoDB
 

More from MongoDB (20)

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

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Recently uploaded (20)

Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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...
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

Building Mobile App Architecture

  • 1. Building a Mobile App! Part 1 { name: ‘Bryan Reinero’, title: ‘Developer Advocate’, twitter: ‘@blimpyacht’, code: ‘github.com/breinero’ email: ‘bryan@mongdb.com’ }
  • 2. 2 Track Agenda • Part 1: Architecture and Application Design • Part 2: Geo-Spatial Indexing and Queries • Part 3:Deployment Readiness
  • 3. 3 Mobile Applications • Location based data • User relevance • Context Rich • Social Engagement
  • 4. 4 The Scavenger Hunt App Users create scavenger hunts by “pinning” waypoints
  • 5. 5 The Scavenger Hunt App Players search for a scavenger hunt near their current position
  • 6. 6 The Scavenger Hunt App Basic Requirements
  • 7. 7 The Scavenger Hunt App Basic Requirements • Mark target points
  • 8. 8 The Scavenger Hunt App Basic Requirements • Mark target points • Identify our users
  • 9. 9 The Scavenger Hunt App Basic Requirements • Mark target points • Identify our users • Mark users’ progress during hunts
  • 11. 11 The Scavenger Hunt App Users create scavenger hunts by “pinning” waypoints
  • 12. 12 Waypoint { _id: ObjectId(), user: UUID, tour: UUDI name: "Doug's Dogs", desc: "The best hot-dog", clues: [ "Hungry for a Coney Island?", "Ask for Dr. Frankenfurter", "Look for the hot dog stand" ], "geometry": { "type": "Point", "coordinates": [125.6, 10.1] } };
  • 13. 13 Waypoint { _id: ObjectId(), user: UUID, tour: UUDI name: "Doug's Dogs", desc: "The best hot-dog", clues: [ "Hungry for a Coney Island?", "Ask for Dr. Frankenfurter", "Look for the hot dog stand" ], "geometry": { "type": "Point", "coordinates": [125.6, 10.1] } };
  • 14. 14 Waypoint { _id: ObjectId(), user: UUID, tour: UUDI name: "Doug's Dogs", desc: "The best hot-dog", clues: [ "Hungry for a Coney Island?", "Ask for Dr. Frankenfurter", "Look for the hot dog stand" ], "geometry": { "type": "Point", "coordinates": [125.6, 10.1] } }; Geospacial Index: ensureIndex( { geometry: “2dsphere” } )
  • 16. 16 Waypoint Application ServerMobile Client RESTful Service scavenger.com/waypoints?lat=40.87&lon=-73.87&max=100 HTTP GET
  • 17. 17 Waypoint Application Server DatabaseMobile Client RESTful Service scavenger.com/waypoints?lat=40.87&lon=-73.87&max=100 HTTP GET
  • 18. 18 Waypoint Application Server DatabaseMobile Client RESTful Service scavenger.com/waypoints?lat=40.87&lon=-73.87&max=100 HTTP GET Query { ‘$geoNear’: { ‘$geometry’: { type: "Point", coordinates: [ -174.9559, 40.6544 ] }, ‘maxDistance’: 100 }
  • 19. 19 The Scavenger Hunt App Basic Requirements • Mark target points • Identify our users • Mark users’ progress during hunts
  • 20. 20 The Checkpoint Document { _id: ObjectId(), user: UUID, huntId: UUID, timestamp: ISODate(), geometry: { type: "Point", coordinates: [ long, lat ] } }
  • 21. 21 The Scavenger Hunt App Social Requirements • Allow users to follow one another • Allow users to exchange messages • Send users notifications
  • 23. 23 User Collection { _id: UUID, name: “Bryan Reinero’, email: “bryan@mongodb.com”, pass: “dontyouwishyouknew”, description: “I am just a guy”, followers: [ “Achille”, “Jason”, “Steffan”, “Norm” ] }
  • 24. 24 Social Interactions Followers Collection { follower: ‘Shemp’, followed: ‘Euripides’}, { follower:‘Shemp’, followed: ’Eratosthenes”}, { follower: “Eratosthenes’, followed: ‘Shemp’ }, … Eratosthenes Democritus Hypatia Shemp Euripides
  • 25. 25 Social Interactions Eratosthenes Democritus Hypatia Shemp Euripides Followers Collection { follower: ‘Shemp’, followed: ‘Euripides’}, { follower:‘Shemp’, followed: ’Eratosthenes”}, { follower: “Eratosthenes’, followed: ‘Shemp’ }, … ! (Euripides -> Shemp )
  • 26. 26 Social Interactions db.followers.find( { follower:‘Shemp’ } ); Followers Collection { follower: ‘Shemp’, followed: ‘Euripides’}, { follower:‘Shemp’, followed: ’Eratosthenes”}, { follower: “Eratosthenes’, followed: ‘Shemp’ }, …
  • 27. 27 Notifications / Messaging Message { sender: “Hypatia”, recipients: [ “Democritus”, “Euripides”, “Eratosthenes” ] date: ISODate(), message: “truth is a point of view, and so is changeable” }
  • 28. 28 Notifications / Messaging Message { sender: “Hypatia”, recipients: [ “Democritus”, “Euripides”, “Eratosthenes” ] date: ISODate(), message: “truth is a point of view, and so is changeable” } db.messages.find( { recipients: “Democritus”} );
  • 29. 29 OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX Notifications / Messaging db.messages.find( ‘outbox.user’: ‘Hypatia’ ); db.messages.find( ‘outbox.user’: ‘Euripides’); db.messages.find( ‘outbox.user’: ‘Democritus’); db.messages.find( ‘outbox.user’: ‘Shemp’); Read
  • 30. 30 OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX Notifications / Messaging db.messages.find( ‘outbox.user’: ‘Hypatia’ ); db.messages.find( ‘outbox.user’: ‘Euripides’); db.messages.find( ‘outbox.user’: ‘Democritus’); db.messages.find( ‘outbox.user’: ‘Shemp’); Read
  • 31. 31 OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX Notifications / Messaging db.messages.find( ‘outbox.user’: ‘Hypatia’ ); db.messages.find( ‘outbox.user’: ‘Euripides’); db.messages.find( ‘outbox.user’: ‘Democritus’); db.messages.find( ‘outbox.user’: ‘Shemp’); Read
  • 32. 32 OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX OUTBOX Notifications / Messaging db.messages.find( ‘outbox.user’: ‘Hypatia’ ); db.messages.find( ‘outbox.user’: ‘Euripides’); db.messages.find( ‘outbox.user’: ‘Democritus’); db.messages.find( ‘outbox.user’: ‘Shemp’); Read
  • 33. 33 One Document per Message per Recipient { sender: “Hypatia”, recipient: “Democritus”, date: ISODate(), message: “truth is a point of view, and so is changeable” } { sender: “Hypatia”, recipient: “Euripides”, date: ISODate(), message: “truth is a point of view, and so is changeable” } { sender: “Hypatia”, recipient: “Eratosthenes”, date: ISODate(), message: “truth is a point of view, and so is changeable” }
  • 35. 35 Notifications / Messaging {user: “Hypatia”, ctime: ISODate(), mtime: ISODate(), count: 10, inbox: [ <message>, <message>, <message>, … ] }
  • 36. 36 Write to Bucket function addToBucket( user, item,bucketSize ) { var query = { user: user, count: { $lt: bucketSize } }; db.notifications.update( query, { $push: { messages: item }, $set: { mtime: ISODate() }, $inc: { count: 1 }, $setOnInsert: { startDate: ISODate() } }, { upsert: true } ); }
  • 37. 37 Write to Bucket Parameters • user bucket owner • item notification message • bucketSize limits number of messages / document function addToBucket( user, item, bucketSize ) { var query = { user: user, count: { $lt: bucketSize } }; db.notifications.update( query, { $push: { messages: item }, $set: { mtime: ISODate() }, $inc: { count: 1 }, $setOnInsert: { startDate: ISODate() } }, { upsert: true } ); }
  • 38. 38 Write to Bucket Parameters • user bucket owner • item notification message • bucketSize limits number of messages / document Query Don’t update full bucket function addToBucket( user, item,bucketSize ) { var query = { user: user, count: { $lt: bucketSize } }; db.notifications.update( query, { $push: { messages: item }, $set: { mtime: ISODate() }, $inc: { count: 1 }, $setOnInsert: { startDate: ISODate() } }, { upsert: true } ); }
  • 39. 39 Write to Bucket Parameters • user bucket owner • item notification message • bucketSize limits number of messages / document Query Don’t update full bucket Update • Append item to message array, • Update the mtime with current timestamp • Increment the size of the bucket function addToBucket( user, item,bucketSize ) { var query = { user: user, count: { $lt: bucketSize } }; db.notifications.update( query, { $push: { messages: item }, $set: { mtime: ISODate() }, $inc: { count: 1 }, $setOnInsert: { startDate: ISODate() } }, { upsert: true } ); }
  • 40. 40 Write to Bucket Parameters • user bucket owner • item notification message • bucketSize limits number of messages / document Query Don’t update full bucket Update • Append item to message array, • Update the mtime with current timestamp • Increment the size of the bucket Upsert Create a new bucket function addToBucket( user, item,bucketSize ) { var query = { user: user, count: { $lt: bucketSize } }; db.notifications.update( query, { $push: { messages: item }, $set: { mtime: ISODate() }, $inc: { count: 1 }, $setOnInsert: { startDate: ISODate() } }, { upsert: true } ); }
  • 41. 41 Personal Timeline / Hotlist { _id: UUID, user: ”Democritus", hotList" : [ { message: "New scavenger hunt tomorrow!", url: "http://bit.ly/1hKn9ff", date" : ISODate() }, { message: "Get 50% off at Toga City", url: "http://bit.ly/1KnlFHQ", date: ISODate() } ], atime: ISODate("20150313T04:38:43.606Z") }
  • 42. 42 Personal Timeline / Hotlist Notifications of highest user relevance { _id: UUID, user: ”Democritus", hotList" : [ { message: "New scavenger hunt tomorrow!", url: "http://bit.ly/1hKn9ff", date" : ISODate() }, { message: "Get 50% off at Toga City", url: "http://bit.ly/1KnlFHQ", date: ISODate() } ], atime: ISODate("20150313T04:38:43.606Z") }
  • 43. 43 Personal Timeline / Hotlist db.user.update( {"user" : "Democritus"}, {$push : { ”hotList” : { $each : [ { <MESSAGE> } ], $slice : -50 } }}, false, false)
  • 44. 44 Production Ready Architecture Application Servers Replica SetMobile Client L.B.
  • 45. Thanks! { name: ‘Bryan Reinero’, title: ‘Developer Advocate’, twitter: ‘@blimpyacht’, code: ‘github.com/breinero’ email: ‘bryan@mongdb.com’ }