Download - Playgrounds: Mobile + Swift = BFF
Swift @ IBM Engineering TeamChris Bailey(@Chris__Bailey)
Feb 23rd, 2017
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
+
@Chris__Bailey | Swift@IBM #playgroundscon
+
@Chris__Bailey | Swift@IBM #playgroundscon
+= BFF
@Chris__Bailey | Swift@IBM #playgroundscon
+= BFF
@Chris__Bailey | Swift@IBM #playgroundscon
+= BFF
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
#playgroundscon@Chris__Bailey | Swift@IBM
#playgroundscon@Chris__Bailey | Swift@IBM
GATEWAY
PUBLIC NETWORK CLOUD NETWORK
#playgroundscon@Chris__Bailey | Swift@IBM
GATEWAY
PUBLIC NETWORK CLOUD NETWORK
Client Devices
#playgroundscon@Chris__Bailey | Swift@IBM
GATEWAY
PUBLIC NETWORK CLOUD NETWORK
Client Devices Hosted Services
#playgroundscon@Chris__Bailey | Swift@IBM
GATEWAY
PUBLIC NETWORK CLOUD NETWORK
Client Devices Backend API Hosted Services
#playgroundscon@Chris__Bailey | Swift@IBM
GATEWAY
PUBLIC NETWORK CLOUD NETWORK
Client Devices Backend API Hosted Services
#playgroundscon@Chris__Bailey | Swift@IBM
GATEWAY
PUBLIC NETWORK CLOUD NETWORK
Client Devices Backend API
ROUTING PROXY
Services Hosted Services
#playgroundscon@Chris__Bailey | Swift@IBM
GATEWAY
PUBLIC NETWORK CLOUD NETWORK
Client Devices Backend API
ROUTING PROXY
Micro-Services Hosted Services
#playgroundscon@Chris__Bailey | Swift@IBM
GATEWAY
PUBLIC NETWORK CLOUD NETWORK
Client Devices Backend API
ROUTING PROXY
Micro-Services Hosted Services
API Team
#playgroundscon@Chris__Bailey | Swift@IBM
GATEWAY
PUBLIC NETWORK CLOUD NETWORK
Client Devices Backend API
ROUTING PROXY
Micro-Services Hosted Services
Web Team
API Team
#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
#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
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
First Paint Time
@Chris__Bailey | Swift@IBM #playgroundscon
Server Side Rendering
First Paint Time
@Chris__Bailey | Swift@IBM #playgroundscon
Server Side Rendering
First Paint Time
Search Engine Optimisation
@Chris__Bailey | Swift@IBM #playgroundscon
Server Side Rendering
First Paint Time
Search Engine Optimisation
Network Payload Size
Request Frequency
@Chris__Bailey | Swift@IBM #playgroundscon
Server Side Rendering
First Paint Time
Search Engine Optimisation
Network Payload Size
CPU Usage
Request Frequency
Battery UsageMemory Usage
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
http://todolist.mybluemix.net/api/todos/{id}
@Chris__Bailey | Swift@IBM #playgroundscon
{ “title”: “Write the presentation” “priority”: 1 “completed”: true }
http://todolist.mybluemix.net/api/todos/{id}
@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/
@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/
@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/
@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/
@Chris__Bailey | Swift@IBM #playgroundscon
SWAPIThe Star Wars API GraphQL
@Chris__Bailey | Swift@IBM #playgroundscon
{ person(personID: 1) { name, height, mass, hairColor, eyeColor, imageURL, starShipConnection { edges { node { name } } } } }
SWAPIThe Star Wars API GraphQL
@Chris__Bailey | Swift@IBM #playgroundscon
SWAPIThe Star Wars API Backend for Frontend (BFF)
@Chris__Bailey | Swift@IBM #playgroundscon
http://swapibackend.mybluemix.net/person/1/
SWAPIThe Star Wars API Backend for Frontend (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
#playgroundscon@Chris__Bailey | Swift@IBM
GATEWAY
PUBLIC NETWORK CLOUD NETWORK
Client Devices
ROUTING PROXY
Micro-Services Hosted Services
iOS Team
Android Team
Web Team
#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
@Chris__Bailey | Swift@IBM #playgroundscon
MARS
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
20241998 Mars Climate ORbiteR
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
DeC 11: Launch from Cape Canaveral1998 Mars Climate ORbiteR
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
1998 Mars Climate ORbiteR DeC 11: Launch from Cape Canaveral
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
1998 Mars Climate ORbiteR
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
1999 Mars Climate ORbiteR Sept 23rd: Lost Radio Contact
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
1999 Mars Climate ORbiteR Sept 25th: Mission Declared a LOSS
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
PLANNED TRAJECTORY
@Chris__Bailey | Swift@IBM #playgroundscon
PLANNED TRAJECTORY
TCM-4
@Chris__Bailey | Swift@IBM #playgroundscon
PLANNED TRAJECTORY
TCM-4
@Chris__Bailey | Swift@IBM #playgroundscon
PLANNED TRAJECTORY
TCM-4
226 KM
@Chris__Bailey | Swift@IBM #playgroundscon
PLANNED TRAJECTORY
TCM-4
ACTUAL TRAJECTORY
226 KM
@Chris__Bailey | Swift@IBM #playgroundscon
PLANNED TRAJECTORY
TCM-4
ACTUAL TRAJECTORY
226 KM
TCM-4
@Chris__Bailey | Swift@IBM #playgroundscon
PLANNED TRAJECTORY
TCM-4
TCM-4 ACTUAL TRAJECTORY
226 KM
@Chris__Bailey | Swift@IBM #playgroundscon
PLANNED TRAJECTORY
TCM-4
ACTUAL TRAJECTORY
226 KM
57 KM
TCM-4
@Chris__Bailey | Swift@IBM #playgroundscon@Chris__Bailey | Swift@IBM #playgroundscon
@Chris__Bailey | Swift@IBM #playgroundscon
Lockheed MartinGround SoftwareNasa Jet Propulsion Laboratory
Trajectory Calculation Software
@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
#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
#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
#playgroundscon@Chris__Bailey | Swift@IBM
GATEWAY
PUBLIC NETWORK CLOUD NETWORK
Client Devices
ROUTING PROXY
Micro-Services Hosted ServicesBFF API
#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
#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
#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
#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
@Chris__Bailey | Swift@IBM #playgroundscon
Building a 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) ])
@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()
@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
@Chris__Bailey | Swift@IBM #playgroundscon
Demo
@Chris__Bailey | Swift@IBM #playgroundscon
Become a SwiftStack Developer Today
kitura.iogithub.com/ibm-swift swift-at-ibm-slack.mybluemix.net