Slide 1

Slide 1 text

Scaling server-driven UI with the power of Kotlin LAURA KELLY & NATHANAEL SILVERMAN

Slide 2

Slide 2 text

Laura Kelly Software Engineer Design Language Team Nathanael Silverman Software Engineer Design Language Team

Slide 3

Slide 3 text

Airbnb’s Design System An Evolving Product Server-Driven UI Lona Kotlin Power Agenda

Slide 4

Slide 4 text

Airbnb’s Design System An Evolving Product Server-Driven UI Lona Kotlin Power Agenda

Slide 5

Slide 5 text

Airbnb’s Design System An Evolving Product Server-Driven UI Lona Kotlin Power Agenda

Slide 6

Slide 6 text

Airbnb’s Design System An Evolving Product Server-Driven UI Lona Kotlin Power Agenda

Slide 7

Slide 7 text

Airbnb’s Design System An Evolving Product Server-Driven UI Lona Kotlin Power Agenda

Slide 8

Slide 8 text

Airbnb’s Design System An Evolving Product Server-Driven UI Lona Kotlin Power Agenda

Slide 9

Slide 9 text

A few years ago…

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Homes Experiences Plus

Slide 13

Slide 13 text

Homes Experiences Plus Luxe

Slide 14

Slide 14 text

Many products

Slide 15

Slide 15 text

Many platforms

Slide 16

Slide 16 text

Many engineers product v

Slide 17

Slide 17 text

Infra

Slide 18

Slide 18 text

We needed to enable rapid, complex development

Slide 19

Slide 19 text

Airbnb’s DLS DESIGN LANGUAGE SYSTEM

Slide 20

Slide 20 text

Bélo Color Typeface …

Slide 21

Slide 21 text

Row components

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Speed

Slide 26

Slide 26 text

Consistency

Slide 27

Slide 27 text

Can we do better?

Slide 28

Slide 28 text

Write screens once

Slide 29

Slide 29 text

Deploy instantly

Slide 30

Slide 30 text

Server-Driven UI AN INTRODUCTION

Slide 31

Slide 31 text

API Response (not SDUI) Name: “Sightglass Coffee”, Photos: {…} Website: “www.sightglasscoffee.com”, Location: { address: “123 main street”, city: “San Francisco”, state: “California”, country: “United States" },

Slide 32

Slide 32 text

Action Row Title Row API Response Carousel Map Row

Slide 33

Slide 33 text

Title Row Action Row API Response Carousel Map Row

Slide 34

Slide 34 text

Button Row Title Row API Response Carousel Map Row

Slide 35

Slide 35 text

Client-side implementation

Slide 36

Slide 36 text

REST Client-side implementation Server-driven flexibility

Slide 37

Slide 37 text

REST HTML Client-side implementation Server-driven flexibility

Slide 38

Slide 38 text

REST HTML Component- based SDUI Client-side implementation Server-driven flexibility

Slide 39

Slide 39 text

API Response Carousel Map Row Title Row Action Row

Slide 40

Slide 40 text

The JSON format A MORE SPECIFIC EXAMPLE

Slide 41

Slide 41 text

{ "id": "…", "type": “MyComponent", "content": { "title": "My Title", "subtitle": "…" } } Lona Component JSON

Slide 42

Slide 42 text

{ "id": "…", "type": "MyComponent", "content": { "title": "My Title", "subtitle": "…" } } Lona Component JSON

Slide 43

Slide 43 text

{ "id": "…", "type": "MyComponent", "content": { "title": "My Title", "subtitle": "…" } } Lona Component JSON

Slide 44

Slide 44 text

{ "id": "…", "type": "MyComponent", "content": { "title": "My Title", "subtitle": "…" }, "actions": { "onPress": { "case": "deepLink", "data": { "url": "https://…" } } } } Lona Component JSON

Slide 45

Slide 45 text

{ "id": "…", "type": "MyComponent", "content": { "title": "My Title", "subtitle": "…" }, "actions": { "onPress": { "case": "deepLink", "data": { "url": "https://…" } } } } Lona Component JSON

Slide 46

Slide 46 text

{ "id": "…", "type": "MyComponent", "content": { "title": "My Title", "subtitle": "…" }, "actions": { "onPress": { "case": "deepLink", "data": { "url": "https://…" } } } } Lona Component JSON

Slide 47

Slide 47 text

{ "id": "…", "type": "MyComponent", "content": { "title": "My Title", "subtitle": "…" }, "actions": { "onPress": { "case": "deepLink", "data": { "url": "https://…" } } } } Lona Component JSON

Slide 48

Slide 48 text

{ "id": "…", "type": "MyComponent", "content": { "title": "My Title", "subtitle": "…" }, "actions": { "onPress": { "case": "deepLink", "data": { "url": "https://…" } } } } Lona Component JSON

Slide 49

Slide 49 text

{ "id": "…", "type": "MyComponent", "content": { "title": "My Title", "subtitle": "…" }, "actions": { "onPress": { "case": "deepLink", "data": { "url": "https://…" } } } } Lona Component JSON

Slide 50

Slide 50 text

{ "id": "…", "type": "MyComponent", "content": { "title": "My Title", "subtitle": "…" }, "actions": { "onPress": { "case": "deepLink", "data": { "url": "https://…" } } } } "dismiss" "logout" "asyncRequest" … Lona Component JSON

Slide 51

Slide 51 text

{ "id": "…", "type": "MyComponent", "content": { "title": "My Title", "subtitle": "…" }, "actions": { "onPress": { "case": "deepLink", "data": { "url": "https://…" } } } } Lona Component JSON

Slide 52

Slide 52 text

Lona Component JSON { "id": "…", "type": “MyComponent”, "content": { "title": "My Title", "subtitle": "…" }, "actions": { "onPress": { "case": "deepLink", "data": { "url": "https://…" } } } }

Slide 53

Slide 53 text

Challenges of SDUI

Slide 54

Slide 54 text

Versioning

Slide 55

Slide 55 text

Initial launch Time passes Turn on the API Push changes

Slide 56

Slide 56 text

What’s the problem?

Slide 57

Slide 57 text

Some users never update!

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

API Client

Slide 61

Slide 61 text

V2 V1 V3

Slide 62

Slide 62 text

Keeping clients in sync

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

Scaling

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

It’s hard to scale to different use cases

Slide 67

Slide 67 text

One big system also has downsides…

Slide 68

Slide 68 text

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

Clients should receive only the code that they need

Slide 71

Slide 71 text

Documentation

Slide 72

Slide 72 text

A widely used SDUI system is constantly changing

Slide 73

Slide 73 text

• Versioning • Keeping clients in sync • Scaling • Documentation Challenges of server-driven UI

Slide 74

Slide 74 text

The Lona Spec KOTLIN POWERED

Slide 75

Slide 75 text

iOS Web frontend Backend Android Lona specification

Slide 76

Slide 76 text

?

Slide 77

Slide 77 text

?! est.tabs.TabChooser.onCreate(TabChooser.java:15) 1-21 20:55:47.390: W/System.err(989): at ndroid.app.Activity.performCreate(Activity.java:4465) 1-21 20:55:47.410: W/System.err(989): at ndroid.app.Instrumentation.callActivityOnCreate(Instr mentation.java:1049) 1-21 20:55:47.410: W/System.err(989): at ndroid.app.ActivityThread.performLaunchActivity(Activ tyThread.java:1919) 1-21 20:55:47.420: W/System.err(989): at ndroid.app.ActivityThread.handleLaunchActivity(Activi yThread.java:1980) 1-21 20:55:47.420: W/System.err(989): at ndroid.app.ActivityThread.access$600(ActivityThread.j va:122)

Slide 78

Slide 78 text

- Component properties

Slide 79

Slide 79 text

- Component properties - Versions

Slide 80

Slide 80 text

- Component properties - Versions - Events - Actions

Slide 81

Slide 81 text

- Component properties - Versions - Events - Actions - Logging

Slide 82

Slide 82 text

- Component properties - Versions - Events - Actions - Logging - Styles

Slide 83

Slide 83 text

Me

Slide 84

Slide 84 text

Android team Kotlin

Slide 85

Slide 85 text

Backend team using Java

Slide 86

Slide 86 text

No content

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

Domain-Specific Language Not to be confused with Design Language System.

Slide 89

Slide 89 text

Lona Spec DSL lonaSpec { component("MyHeaderComponent") { } component("MyOtherComponent") { } }

Slide 90

Slide 90 text

Lona Spec DSL component("MyHeaderComponent") { description("Introduces sections of text. …") }

Slide 91

Slide 91 text

Lona Spec DSL component("MyHeaderComponent") { description("Introduces sections of text. …") content("title", Type.String) }

Slide 92

Slide 92 text

Lona Spec DSL component("MyHeaderComponent") { description("Introduces sections of text. …") content("title", Type.String) { description("Documentation about this property.") } }

Slide 93

Slide 93 text

Lona Spec DSL component("MyHeaderComponent") { description("Introduces sections of text. …") content("title", Type.String) { description("Documentation about this property.") example("Title") example("A really long title to test this use case…") } }

Slide 94

Slide 94 text

Lona Spec DSL component("MyHeaderComponent") { description("Introduces sections of text. …") content("title", Type.String) { description("Documentation about this property.") example("Title") example("A really long title to test this use case…") } optionalContent("subtitle", Type.String, nullable = true, default = null) … } }

Slide 95

Slide 95 text

Lona Spec DSL val optionalContentSubtitle: LonaComponent.Builder.() -> Unit = { optionalContent("subtitle", Type.String, true, null) { example("Subtitle") example("A really long subtitle to test wrapping…") } }

Slide 96

Slide 96 text

Lona Spec DSL component("MyHeaderComponent") { description("Introduces sections of text. …") content("title", Type.String) { description("Documentation about this property.") example("Title") example("A really long title to test this use case…") } optionalContentSubtitle() }

Slide 97

Slide 97 text

Lona Spec DSL component("MyHeaderComponent") { description("Introduces sections of text. …") content("title", Type.String) { description("Documentation about this property.") example("Title") example("A really long title to test this use case…") } optionalContentSubtitle() }

Slide 98

Slide 98 text

Versioning v1

Slide 99

Slide 99 text

- Hello components

Slide 100

Slide 100 text

- Hello components - Bye bye components

Slide 101

Slide 101 text

- Hello components - Bye bye components - Did you get a haircut components?

Slide 102

Slide 102 text

Explicit versioning

Slide 103

Slide 103 text

Backward-compatible clients

Slide 104

Slide 104 text

++

Slide 105

Slide 105 text

Lona Spec DSL component("MyHeaderComponent") { description("Introduces sections of text. …") content("title", Type.String) … optionalContent("subtitle", Type.String, nullable = true, default = null) }

Slide 106

Slide 106 text

Lona Spec DSL component("MyHeaderComponent") { description("Introduces sections of text. …") content("title", Type.String) … optionalContent("subtitle", Type.String, nullable = true, default = null) minVersion(2) { } }

Slide 107

Slide 107 text

Lona Spec DSL component("MyHeaderComponent") { description("Introduces sections of text. …") content("title", Type.String) … optionalContent("subtitle", Type.String, nullable = true, default = null) minVersion(2) { optionalContent("showDivider", Type.Boolean, nullable = false, default … } } }

Slide 108

Slide 108 text

Lona Spec DSL component("MyComponent") { … } minVersion(2) { component("MyOtherComponent") { … } }

Slide 109

Slide 109 text

Lona Spec DSL minVersion(2) { component("MyOtherComponent") { … minVersion(3) { optionalContent(…) { … } } minVersion(4) { … } } } minVersion(3) { … }

Slide 110

Slide 110 text

Artifacts

Slide 111

Slide 111 text

Lona specification JSON specs

Slide 112

Slide 112 text

Lona JSON Specs { "components": [ { "type": "MyHeaderComponent", "content": [{ "nullable": false, "name": "title", "type": "String" }] }, … ], "version": 1 }

Slide 113

Slide 113 text

Lona JSON Specs { "components": [ { "type": "MyHeaderComponent", "content": [{ "nullable": false, "name": "title", "type": "String" }] }, … ], "version": 1 }

Slide 114

Slide 114 text

Lona JSON Specs { "components": [ { "type": "MyHeaderComponent", "content": [{ "nullable": false, "name": "title", "type": "String" }] }, … ], "version": 1 }

Slide 115

Slide 115 text

Lona JSON Specs { "components": [ { "type": "MyHeaderComponent", "content": [{ "nullable": false, "name": "title", "type": "String" }] }, … ], "version": 1 }

Slide 116

Slide 116 text

Lona JSON Specs { "components": [ { "type": "MyHeaderComponent", "content": [{ "nullable": false, "name": "title", "type": "String" }] }, … ], "version": 1 }

Slide 117

Slide 117 text

Lona JSON Specs "examples": [ { "id": "0", "type": "MyHeaderComponent", "content": {"title": "Title"} }, { "id": "1", "type": "MyHeaderComponent", "content": {"title": "A really long title to test this use case…"} } ]

Slide 118

Slide 118 text

Lona JSON Specs "examples": [ { "id": "0", "type": "MyHeaderComponent", "content": {"title": "Title"} }, { "id": "1", "type": "MyHeaderComponent", "content": {"title": "A really long title to test this use case…"} } ]

Slide 119

Slide 119 text

Lona JSON Specs "examples": [ { "id": "0", "type": "MyHeaderComponent", "content": {"title": "Title"} }, { "id": "1", "type": "MyHeaderComponent", "content": {"title": "A really long title to test this use case…"} } ]

Slide 120

Slide 120 text

Lona specification JSON specs iOS Web frontend Android

Slide 121

Slide 121 text

Lona specification JSON specs iOS Web frontend Android JSON schemas

Slide 122

Slide 122 text

JSON Schema Draft v4

Slide 123

Slide 123 text

The JSON Schema A component example It’s valid!

Slide 124

Slide 124 text

Backend Lona specification JSON specs iOS Web frontend Android JSON schemas Humans

Slide 125

Slide 125 text

Backend Lona specification JSON specs iOS Web frontend Android JSON schemas Humans Documentation

Slide 126

Slide 126 text

No content

Slide 127

Slide 127 text

Backend Lona specification JSON specs iOS Web frontend Android JSON schemas Humans Documentation Humans

Slide 128

Slide 128 text

Backend Lona specification JSON specs iOS Web frontend Android JSON schemas Humans Documentation Page builder Humans

Slide 129

Slide 129 text

Lona Type-Unsafe Page Builder pageBuilder { componentInstance("MyHeaderComponent") { "title" to "Scaling Server-Driven UI with the Power of Kotlin" "subtitle" to "Bla bla bla" } componentInstance("MyOtherComponent") { … } … }

Slide 130

Slide 130 text

Lona Type-Unsafe Page Builder pageBuilder { componentInstance("MyHeaderComponent") { "title" to "Scaling Server-Driven UI with the Power of Kotlin" "subtitle" to "Bla bla bla" } componentInstance("MyOtherComponent") { … } … }

Slide 131

Slide 131 text

Lona Type-Unsafe Page Builder pageBuilder { componentInstance("MyHeaderComponent") { "title" to "Scaling Server-Driven UI with the Power of Kotlin" "subtitle" to "Bla bla bla" } componentInstance("MyOtherComponent") { … } … }

Slide 132

Slide 132 text

Lona Type-Safe Page Builder componentInstance("MyHeaderComponent") { "title" to "Scaling Server-Driven UI with the Power of Kotlin" "subtitle" to "Bla bla bla" } myHeaderComponent( title = "Scaling Server-Driven UI with the Power of Kotlin", subtitle = "Bla bla bla" }

Slide 133

Slide 133 text

Backend Lona specification JSON specs iOS Web frontend Android JSON schemas Humans Documentation Page builder Humans Backend

Slide 134

Slide 134 text

Backend Lona specification JSON specs iOS Web frontend Android JSON schemas Humans Documentation Page builder Humans Backend

Slide 135

Slide 135 text

Modul arization

Slide 136

Slide 136 text

Lona Spec Modules specModule(name = "plus") { … } specModule(name = "luxe") { … }

Slide 137

Slide 137 text

Lona Spec Modules val myHeaderComponent = reusableComponent("MyHeaderComponent") { … }

Slide 138

Slide 138 text

Lona Spec Modules val myHeaderComponent = reusableComponent("MyHeaderComponent") { … } specModule(name = "plus") { add(myHeaderComponent.version(1)) }

Slide 139

Slide 139 text

• Versioning • Keeping clients in sync • Scaling • Documentation Challenges of server-driven UI

Slide 140

Slide 140 text

• Versioning • Keeping clients in sync • Scaling • Documentation Challenges of server-driven UI Kotlined

Slide 141

Slide 141 text

• Versioning • Keeping clients in sync • Scaling • Documentation Challenges of server-driven UI Kotified?

Slide 142

Slide 142 text

No content

Slide 143

Slide 143 text

No content

Slide 144

Slide 144 text

• Speed of iteration • Build once, deploy anytime • Consistency • Quality Server-driven UI with a Kotlin DSL

Slide 145

Slide 145 text

Thank you and remember to vote! Laura Kelly @heylaurakelly Nathanael Silverman #KotlinConf Credit to vecteezy.com for the finger snap icon

Slide 146

Slide 146 text

FAQ?