playgrounds: mobile + swift = bff

78
Swift @ IBM Engineering Team Chris Bailey(@Chris__Bailey) Feb 23rd, 2017

Upload: chris-bailey

Post on 12-Apr-2017

225 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Playgrounds: Mobile + Swift = BFF

Swift @ IBM Engineering TeamChris Bailey(@Chris__Bailey)

Feb 23rd, 2017

Page 2: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Page 3: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

+

Page 4: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

+

Page 5: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

+= BFF

Page 6: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

+= BFF

Page 7: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

+= BFF

Page 8: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Page 9: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Page 10: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Page 11: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Page 12: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Page 13: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Page 14: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

Page 15: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Page 16: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices

Page 17: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices Hosted Services

Page 18: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices Backend API Hosted Services

Page 19: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices Backend API Hosted Services

Page 20: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices Backend API

ROUTING PROXY

Services Hosted Services

Page 21: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices Backend API

ROUTING PROXY

Micro-Services Hosted Services

Page 22: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices Backend API

ROUTING PROXY

Micro-Services Hosted Services

API Team

Page 23: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices Backend API

ROUTING PROXY

Micro-Services Hosted Services

Web Team

API Team

Page 24: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices Backend API

ROUTING PROXY

Micro-Services Hosted Services

Android Team

Web Team

API Team

Page 25: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices Backend API

ROUTING PROXY

Micro-Services Hosted Services

iOS Team

Android Team

Web Team

API Team

Page 26: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Page 27: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

First Paint Time

Page 28: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Server Side Rendering

First Paint Time

Page 29: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Server Side Rendering

First Paint Time

Search Engine Optimisation

Page 30: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Server Side Rendering

First Paint Time

Search Engine Optimisation

Network Payload Size

Request Frequency

Page 31: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Server Side Rendering

First Paint Time

Search Engine Optimisation

Network Payload Size

CPU Usage

Request Frequency

Battery UsageMemory Usage

Page 32: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Page 33: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Page 34: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

http://todolist.mybluemix.net/api/todos/{id}

Page 35: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

{ “title”: “Write the presentation” “priority”: 1 “completed”: true }

http://todolist.mybluemix.net/api/todos/{id}

Page 36: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

{ "name": "Luke Skywalker", "height": "1.72 m", "mass": "77 Kg", "hair_color": "Blond", "skin_color": "Caucasian", "eye_color": "Blue", "birth_year": "19 BBY", "gender": "Male", "homeworld": "http://swapi.co/api/planets/1/", "films": [ "http://swapi.co/api/films/1/", "http://swapi.co/api/films/2/", "http://swapi.co/api/films/3/" ], "species": [ "http://swapi.co/api/species/1/" ], "vehicles": [ "http://swapi.co/api/vehicles/14/", "http://swapi.co/api/vehicles/30/" ], "starships": [ "http://swapi.co/api/starships/12/", "http://swapi.co/api/starships/22/" ], "created": "2014-12-09T13:50:51.644000Z", "edited": "2014-12-10T13:52:43.172000Z", "url": "http://swapi.co/api/people/1/" }

SWAPIThe Star Wars API

http://swapi.co/api/people/1/

Page 37: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

{ "name": "Luke Skywalker", "height": "1.72 m", "mass": "77 Kg", "hair_color": "Blond", "skin_color": "Caucasian", "eye_color": "Blue", "birth_year": "19 BBY", "gender": "Male", "homeworld": "http://swapi.co/api/planets/1/", "films": [ "http://swapi.co/api/films/1/", "http://swapi.co/api/films/2/", "http://swapi.co/api/films/3/" ], "species": [ "http://swapi.co/api/species/1/" ], "vehicles": [ "http://swapi.co/api/vehicles/14/", "http://swapi.co/api/vehicles/30/" ], "starships": [ "http://swapi.co/api/starships/12/", "http://swapi.co/api/starships/22/" ], "created": "2014-12-09T13:50:51.644000Z", "edited": "2014-12-10T13:52:43.172000Z", "url": "http://swapi.co/api/people/1/" }

SWAPIThe Star Wars API

"http://swapi.co/api/starships/12/", "http://swapi.co/api/starships/22/"

http://swapi.co/api/people/1/

Page 38: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

{ "name": "X-wing", "model": "T-65 X-wing", "manufacturer": "Incom Corporation", "cost_in_credits": "149999", "length": "12.5", "max_atmosphering_speed": "1050", "crew": "1", "passengers": "0", "cargo_capacity": "110", "consumables": "1 week", "hyperdrive_rating": "1.0", "MGLT": "100", "starship_class": "Starfighter", "pilots": [ "http://swapi.co/api/people/1/", "http://swapi.co/api/people/9/", "http://swapi.co/api/people/18/", "http://swapi.co/api/people/19/" ], "films": [ "http://swapi.co/api/films/3/", "http://swapi.co/api/films/2/", "http://swapi.co/api/films/1/" ], "created": "2014-12-12T11:19:05.340000Z", "edited": "2014-12-22T17:35:44.491233Z", "url": "http://swapi.co/api/starships/12/" }

SWAPIThe Star Wars API

http://swapi.co/api/starships/12/

Page 39: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

{ "name": "Imperial shuttle", "model": "Lambda-class T-4a shuttle", "manufacturer": "Sienar Fleet Systems", "cost_in_credits": "240000", "length": "20", "max_atmosphering_speed": "850", "crew": "6", "passengers": "20", "cargo_capacity": "80000", "consumables": "2 months", "hyperdrive_rating": "1.0", "MGLT": "50", "starship_class": "Armed government transport", "pilots": [ "http://swapi.co/api/people/1/", "http://swapi.co/api/people/13/", "http://swapi.co/api/people/14/" ], "films": [ "http://swapi.co/api/films/3/", "http://swapi.co/api/films/2/" ], "created": "2014-12-15T13:04:47.235000Z", "edited": "2014-12-22T17:35:44.795405Z", "url": "http://swapi.co/api/starships/22/" }

SWAPIThe Star Wars API

http://swapi.co/api/starship/22/

Page 40: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

SWAPIThe Star Wars API GraphQL

Page 41: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

{ person(personID: 1) { name, height, mass, hairColor, eyeColor, imageURL, starShipConnection { edges { node { name } } } } }

SWAPIThe Star Wars API GraphQL

Page 42: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

SWAPIThe Star Wars API Backend for Frontend (BFF)

Page 43: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

http://swapibackend.mybluemix.net/person/1/

SWAPIThe Star Wars API Backend for Frontend (BFF)

Page 44: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices Backend API

ROUTING PROXY

Micro-Services Hosted Services

iOS Team

Android Team

Web Team

API Team

Page 45: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices

ROUTING PROXY

Micro-Services Hosted Services

iOS Team

Android Team

Web Team

Page 46: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices BFF API

ROUTING PROXY

Micro-Services Hosted Services

iOS Team

Android Team

Web Team

API Team

Page 47: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

MARS

@Chris__Bailey | Swift@IBM #playgroundscon

Page 48: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

20241998 Mars Climate ORbiteR

@Chris__Bailey | Swift@IBM #playgroundscon

Page 49: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

DeC 11: Launch from Cape Canaveral1998 Mars Climate ORbiteR

@Chris__Bailey | Swift@IBM #playgroundscon

Page 50: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

1998 Mars Climate ORbiteR DeC 11: Launch from Cape Canaveral

@Chris__Bailey | Swift@IBM #playgroundscon

Page 51: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

1998 Mars Climate ORbiteR

@Chris__Bailey | Swift@IBM #playgroundscon

Page 52: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

1999 Mars Climate ORbiteR Sept 23rd: Lost Radio Contact

@Chris__Bailey | Swift@IBM #playgroundscon

Page 53: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

1999 Mars Climate ORbiteR Sept 25th: Mission Declared a LOSS

@Chris__Bailey | Swift@IBM #playgroundscon

Page 54: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Page 55: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

PLANNED TRAJECTORY

Page 56: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

PLANNED TRAJECTORY

TCM-4

Page 57: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

PLANNED TRAJECTORY

TCM-4

Page 58: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

PLANNED TRAJECTORY

TCM-4

226 KM

Page 59: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

PLANNED TRAJECTORY

TCM-4

ACTUAL TRAJECTORY

226 KM

Page 60: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

PLANNED TRAJECTORY

TCM-4

ACTUAL TRAJECTORY

226 KM

TCM-4

Page 61: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

PLANNED TRAJECTORY

TCM-4

TCM-4 ACTUAL TRAJECTORY

226 KM

Page 62: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

PLANNED TRAJECTORY

TCM-4

ACTUAL TRAJECTORY

226 KM

57 KM

TCM-4

Page 63: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon@Chris__Bailey | Swift@IBM #playgroundscon

Page 64: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Lockheed MartinGround SoftwareNasa Jet Propulsion Laboratory

Trajectory Calculation Software

Page 65: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Lockheed MartinGround SoftwareNasa Jet Propulsion Laboratory

Trajectory Calculation Software

Lockheed MartinGround Software

Nasa Jet Propulsion Laboratory Trajectory Calculation Software

SIS(Software Interface Specification)

Total Impulse

pounds-seconds (United States Customary Unit)

newton-seconds (International System of Units)

11.488

Page 66: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices

ROUTING PROXY

Micro-Services Hosted Services

iOS Team

Android Team

Web Team

API Team

BFF API

Page 67: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices

ROUTING PROXY

Micro-Services Hosted Services

iOS Team

Android Team

Web Team

BFF API

Page 68: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices

ROUTING PROXY

Micro-Services Hosted ServicesBFF API

Page 69: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices

ROUTING PROXY

Micro-Services Hosted Services

iOS Team

Android Team

Web Team

BFF API

Page 70: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices

ROUTING PROXY

Micro-Services Hosted Services

iOS Team

Android Team

Web Team

BFF API

Page 71: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices

ROUTING PROXY

Micro-Services Hosted Services

iOS Team

Android Team

Web Team

BFF API

Page 72: Playgrounds: Mobile + Swift = BFF

#playgroundscon@Chris__Bailey | Swift@IBM

GATEWAY

PUBLIC NETWORK CLOUD NETWORK

Client Devices

ROUTING PROXY

Micro-Services Hosted Services

iOS Team

Android Team

Web Team

BFF API

Page 73: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Building a BFF

Page 74: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Create an ApplicationFirst, create a new project directory:$ mkdir myFirstProject

Next, create a new Swift project using the Swift Package Manager.$ cd myFirstProject$ swift package init —-type executable

In Package.swift, add Kitura as a dependency for your project.import PackageDescription

let package = Package( name: "myFirstProject", dependencies: [ .Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 0) ])

Page 75: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Create an ApplicationIn Sources/main.swift, add the following code.import Kitura

// Create a new router let router = Router()

// Handle HTTP GET requests to / router.get("/") { request, response, next in response.send("Hello, World!") next() }

// Add an HTTP server and connect it to the router Kitura.addHTTPServer(onPort: 8090, with: router)

// Start the Kitura runloop (this call never returns) Kitura.run()

Page 76: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Deploy an Application

Open your browser at http://localhost:8090

Compile and run your application:$ swift build$ .build/debug/myFirstProject

Page 77: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Demo

Page 78: Playgrounds: Mobile + Swift = BFF

@Chris__Bailey | Swift@IBM #playgroundscon

Become a SwiftStack Developer Today

kitura.iogithub.com/ibm-swift swift-at-ibm-slack.mybluemix.net