Slide 1

Slide 1 text

Electron,  React,  and  Haskell—Oh  My! A  look  under  the  hood  at  Wagon Mike  Craig   @mkscrg Co-­‐Founder  and  CTO  at  Wagon

Slide 2

Slide 2 text

A  better  way  for  analysts  and  engineers  to   write  queries,  visualize  results,  and  share  data  &  charts. Wagon  is  a  modern  SQL  editor

Slide 3

Slide 3 text

Desktop  Application Web  Application

Slide 4

Slide 4 text

Architecture Electron Wagon  AWS Backend JS  SPA JS  SPA DB  Connector User’s Database Web  application Desktop  application

Slide 5

Slide 5 text

We’re  building  a  desktop  app? • Secure,  direct  connection  to  databases • Utilize  the  local  computing  environment • Native  experience:  dock,  ⌘ +  Tab,  alerts …  it  just  feels  right! • We   building  UX  with  web  technologies – React,  Bootstrap,  Chrome  Dev  Tools,  etc. Electron  makes  it  possible!

Slide 6

Slide 6 text

We’re  building  a  desktop  app! Electron Wagon  AWS Backend JS  SPA JS  SPA DB  Connector User’s Database Web  application Desktop  application

Slide 7

Slide 7 text

Utilizing  the  local  environment • Connect  directly  to  the  user’s  database • Parse  and  execute  DB  queries • Cache  query  results  on  disk • Compute  stats  and  aggregations  for  charts

Slide 8

Slide 8 text

DB  Connector:  Haskell  +  Electron Electron Wagon  AWS Backend JS  SPA JS  SPA User’s Database Web  application Desktop  application DB  Connector

Slide 9

Slide 9 text

DB  Connector:  Haskell  +  Electron • Statically  compiled  Haskell  executable • Shipped  in  Electron  app  bundle • main.js in  Electron  spawns  the  subprocess • Executable  creates  a  localhost  HTTP  server • JS  talks  to  Haskell  over  AJAX

Slide 10

Slide 10 text

Wagon  is  a  web  app,  too! • Single  JS  codebase  for  desktop  and  web Electron Wagon  AWS Backend User’s Database Desktop  application DB  Connector JS  SPA JS  SPA Web  application

Slide 11

Slide 11 text

Wagon  is  a  web  app,  too! • Serve  JS  and  assets  live,  even  for  Electron • Use  , swap  with  static  content:

Slide 12

Slide 12 text

Wagon  is  a  web  app,  too! • Avoid  mixing  Electron  and  browser  APIs • Sandbox  Electron  calls  in  their  own  module:

Slide 13

Slide 13 text

Fun  setup,  tricky  deployment • Sometimes  we  break  the  API between  JS  and  Haskell Electron Desktop  application DB  Connector JS  SPA

Slide 14

Slide 14 text

Fun  setup,  tricky  deployment • Pin  versions  between  desktop  and  JS  apps Electron DB  Connector JS  SPA 420 408 2611 ⋮ 2600 ⋮ Version  Map ⋮ ⋮ 2585

Slide 15

Slide 15 text

Fun  setup,  tricky  deployment • Desktop  version  in  index.html requests

Slide 16

Slide 16 text

Fun  setup,  tricky  deployment • Compute  correct  version  on  AWS  server • Get  versioned  JS  through  CloudFront

Slide 17

Slide 17 text

⛵️ Ship  it!   • Check  out  our  blog:    wagonhq.com/blog • Need  a  better SQL  editor? • We’re  hiring! • Thanks  for  coming!

Slide 18

Slide 18 text

Mike  Craig   @mkscrg Co-­‐Founder  and  CTO  at  Wagon [email protected] Questions?