Slide 1

Slide 1 text

Building Native apps with MongoDB & Kotlin Multiplatform Mohit Sharma Developer Advocate, MongoDB codeWithMohit MongoDB

Slide 2

Slide 2 text

Hi, I’m Mohit 👋 MongoDB, Dublin Developer Advocate Dubizzle (Olx), Dubai Mobile Evangelist and few more.. codeWithMohit

Slide 3

Slide 3 text

Agenda ● Why KMM ? ● What is Data layer ? ● How does MongoDB fit in? ● Coding ● Q & A @codeWithMohit

Slide 4

Slide 4 text

KMM ? @codeWithMohit

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Another perspective UI Logic Data Layer Feature

Slide 7

Slide 7 text

60% - Logic + Data* 40% UI UI Data Layer Logic Feature UI

Slide 8

Slide 8 text

What is the data layer ? @codeWithMohit

Slide 9

Slide 9 text

Views ViewModels / Presenter XML/Storyboard Compose/SwiftUI etc Datasource Logic layer (optional) High Level Architecture Local Cloud @codeWithMohit

Slide 10

Slide 10 text

Repo Pattern Repo Cache Database Network API 1 API 2 @codeWithMohit

Slide 11

Slide 11 text

Evolution Evilution Repo Cache Database Network API 3.1 API 3.2 API 2.1 API 2.2 API 1.1 API 1.2 API xx API xx API xx API xx API xx API xx API xx API xx @codeWithMohit

Slide 12

Slide 12 text

Query Quest! @codeWithMohit

Slide 13

Slide 13 text

Data synchronization JSON NATIVE OBJECT MSG QUEUE BACKEND OBJECT REST CALL TO API PUSH SERVICE PUSH NOTIFICATION COMPLEX CONFLICT RESOLUTION, RETRY & ERROR HANDLING POTENTIAL APP CRASH OFFLINE? INVALID DATA? SERVER ERROR? TIMED OUT? Backend database Mobile devices with local data Data Layer is a hard & complex problem !! WRITE CONFLICTS? @codeWithMohit

Slide 14

Slide 14 text

App dataflow with MongoDB Out-of-the-box device-cloud synchronization Mobile-optimized database Ultra-lightweight and fast Object-oriented No ORM or DAO required Advanced security and permissions Built-in conflict resolution The leading developer data platform on the cloud Functions Triggers GraphQL DataAPI Data Access Control Atlas Realm KMM SDK Atlas Device Sync Search Charts Time Series @codeWithMohit

Slide 15

Slide 15 text

Realm Reactive Notifications Built-in Encryption Offline-First, Background Sync Object Schema & Relationships Simple to Learn & Master Idiomatic Query Language

Slide 16

Slide 16 text

Realm By MongoDB ● Free and Open Source Database ● Founded 2011. First release in 2014 ● C++ with Language SDK’s on top ● Part of MongoDB since 2019

Slide 17

Slide 17 text

Realm By MongoDB

Slide 18

Slide 18 text

Realm Query Language ● alwaysFalse ● alwaysTrue ● and ● beginGroup ● beginsWith ● between ● contains ● distinct ● endsWith ● endGroup ● equalTo ● greaterThan ● greaterThanOrEqual ● in ● isEmpty ● isNotEmpty ● isNotNull ● isNull ● lessThan ● lessThanOrEqual ● like ● limit ● maximumDate ● minimumDate ● not ● notEqualTo ● or ● sort ● average ● count ● sum ● max ● min @codeWithMohit

Slide 19

Slide 19 text

Realm Query langua ge Realm Query language @codeWithMohit

Slide 20

Slide 20 text

Atlas Device Sync Local and offline data access with fast, efficient device to cloud sync @codeWithMohit

Slide 21

Slide 21 text

Atlas App Services Triggers Functions Data API User Authorization HTTPS Endpoints GraphQL @codeWithMohit

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Show me the code !! @codeWithMohit

Slide 24

Slide 24 text

Realm MongoDB Atlas Recap Atlas Device Sync SDK writes transaction The Realm SDK writes the transaction, commiting the object to disk, and sends the changes to the server Insert into collection MongoDB document inserted into the Atlas collection User makes change User logs into the app and makes an edit Change Detected Document changed by another user is picked up by changeStreams and forwarded to Atlas Device Sync Object Conversion Atlas Device Sync automatically translates MongoDB documents to Realm objects and syncs down to the device Object Conversion Atlas Device Sync automatically converts the Realm object to a MongoDB document Notification Realm commits the change to disk. A notification is fired and the UI is updated displaying the new change to the user

Slide 25

Slide 25 text

Leading innovators leverage MongoDB’s mobile & device solution

Slide 26

Slide 26 text

Thank you for your time. codeWithMohit