mobile 1: mobile apps with mongodb

Download Mobile 1: Mobile Apps with MongoDB

If you can't read please download the document

Upload: mongodb

Post on 14-Aug-2015

49 views

Category:

Technology


0 download

TRANSCRIPT

  1. 1. Building a Mobile App! Part 1 { name: Bryan Reinero, title: Developer Advocate, twitter: @blimpyacht, code: github.com/breinero email: [email protected] }
  2. 2. 2 Track Agenda Part 1: Architecture and Application Design Part 2: Geo-Spatial Indexing and Queries Part 3:Deployment Readiness
  3. 3. 3 Mobile Applications Location based data User relevance Context Rich Social Engagement
  4. 4. 4 The Scavenger Hunt App Users create scavenger hunts by pinning waypoints
  5. 5. 5 The Scavenger Hunt App Players search for a scavenger hunt near their current position
  6. 6. 6 The Scavenger Hunt App Basic Requirements
  7. 7. 7 The Scavenger Hunt App Basic Requirements Mark target points
  8. 8. 8 The Scavenger Hunt App Basic Requirements Mark target points Identify our users
  9. 9. 9 The Scavenger Hunt App Basic Requirements Mark target points Identify our users Mark users progress during hunts
  10. 10. Schema Design
  11. 11. 11 The Scavenger Hunt App Users create scavenger hunts by pinning waypoints
  12. 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. 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. 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. 15. 15 Waypoint Mobile Client
  16. 16. 16 Waypoint Application ServerMobile Client RESTful Service scavenger.com/waypoints?lat=40.87&lon=-73.87&max=100 HTTP GET
  17. 17. 17 Waypoint Application Server DatabaseMobile Client RESTful Service scavenger.com/waypoints?lat=40.87&lon=-73.87&max=100 HTTP GET
  18. 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. 19 The Scavenger Hunt App Basic Requirements Mark target points Identify our users Mark users progress during hunts
  20. 20. 20 The Checkpoint Document { _id: ObjectId(), user: UUID, huntId: UUID, timestamp: ISODate(), geometry: { type: "Point", coordinates: [ long, lat ] } }
  21. 21. 21 The Scavenger Hunt App Social Requirements Allow users to follow one another Allow users to exchange messages Send users notifications
  22. 22. 22 Social Interactions Eratosthenes Democritus Hypatia Shemp Euripides
  23. 23. 23 User Collection { _id: UUID, name: Bryan Reinero, email: [email protected], pass: dontyouwishyouknew, description: I am just a guy, followers: [ Achille, Jason, Steffan, Norm ] }
  24. 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. 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. 26 Social Interactions db.followers.find( { follower:Shemp } ); Followers Collection { follower: Shemp, followed: Euripides}, { follower:Shemp, followed: Eratosthenes}, { follower: Eratosthenes, followed: Shemp },
  27. 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. 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. 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. 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. 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. 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. 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. 34. 34 Inbox Buckets Hypatia Message Message Message Hypatia Message Message Message Hypatia Message Message Message
  35. 35. 35 Notifications / Messaging {user: Hypatia, ctime: ISODate(), mtime: ISODate(), count: 10, inbox: [ , , , ] }