SlideShare a Scribd company logo
Refactoring to a
Single Page Application
Marcello Teodori
ROME 18-19 MARCH 2016
Agenda
● a few definitions
● my experience in Workshare
● some take aways
● current state and future
● what’s your experience?
Your traditional web application built
on server side technology, whether
MVC or component based...
A definition for a “Multi Page Application”
“A single-page application (SPA) is a web application or
web site that fits on a single web page with the goal of
providing a more fluent user experience similar to a
desktop application.
In a SPA, either all necessary code – HTML, JavaScript,
and CSS – is retrieved with a single page load.”
Single Page Application on WikiPedia
“Code refactoring is the process of
restructuring existing computer code –
changing the factoring – without changing
its external behavior.
Refactoring improves nonfunctional
attributes of the software.”
(Code) Refactoring on WikiPedia
A refactoring tale: Workshare
1999
Workshare
Doc Comparison and
Metadata Cleaning
Desktop Products
Apr 2012
SkyDox acquisition
Document Sharing SaaS
Ruby monolith #1
aka Cirrus
Nov 2012
IdeaPlane acquisition
Enterprise Social
Network
Java monolith
aka Social
Dec 2014
Dealroom acquisition
Legal Transaction WFE
Ruby monolith #2
aka Transact
now
Scaling
microservices on BE
SPA on FE
Cirrus
● Typical Rails
Application
● Does a Lot :)
○ including REST API!
● Does Too Much :(
● “Leverages”
ActiveRecord!
● You know the end of
the story...
Baaang!
The Masterplan!
● a spike on a SPA
○ called “supernova-ui”
○ validate we can do JavaScript
● phasing out all server side tech
producing front-end code
● migrate backend to microservices
○ Cirrus already provides JSON API
○ Social doesn’t and becomes first
microservice: Groups API
Let’s start!
Moving backend to microservices
Wally
Users Search
Groups
Social
Cards
Homepage Cards
Cirrus
Sign On
Users
Users Search
Activities
Storage
Files & Folders
Figitus
ADAPT BUILD
EXTRACT
...and embrace JavaScript!
And for the frontend
TAKE #1:
setup a front-end build
Node allows front-end developers to take control
● pick your favourite javascript build
template
○ ex. a yeoman generator
● launch a development server
○ ex. via grunt-contrib-connect
● proxy your current web app or API
○ ex. via grunt-connect-proxy
● overlay your changes
JavaScript dependency management FTW!
chimera core-ui
files-ui groups-ui dealroom-ui
new-ui
Chimera, the myth of a style guide
TAKE #2:
build a client-side
application layout
Define your main application layout, client-side
● you will need some basic API
○ user API
○ account API
● application layout
○ topbar
○ sidebar
○ user menu
○ content
● a good candidate for offline
The Workshare Application Layout
topbar
contentsidebar
user
menu
TAKE #3:
leave login where it is
Authentication is complex, you don’t want to break it!
● typical web form login
● CSRF protection
● authentication via cookie
● support auth cookie on API
● single-sign on flows
● vanity domains
TAKE #4:
integrate pages via iframe
iframe are ugly but can be useful...
● content access when on same origin
● native API to communicate
○ window.postMessage
● easy to detect
○ window === window.parent
● listen to URL/hash changes
is a backend dev available? cool!
● create a custom page format
○ (ex. nova)
● serve a naked version of your page
with just the main content
○ in Rails :layout => false
● in your url_helper modify your href to
send a message via javascript to
your parent application
isn’t a backend dev available? oh no!
● load iframe as hidden
● hide application chrome and anything
which is not your main content
● patch CSS if necessary
● patch links to route on SPA
● repeat on URL/hash change
TAKE #5:
reuse your test suite
No refactoring without a proper test suite!
● Robot Framework
○ API tests
○ FE tests via WebDriver
● BDD style test definitions
● Re-use with minimal changes
○ if element selector don’t change!
○ adapt custom keywords
■ Navigate To (new URLs)
■ Locate Element (switch to iframe)
TAKE #6:
Apache (or nginx)
is your friend
● map existing URLs you want to keep
● define your strategy to serve your SPA
○ on a subcontext /new-ui
○ on the root
■ via a custom header x-new-ui=true
■ on a different server
● proxy APIs and iframe pages
○ keep same origin
○ no need for CORS headers
It’s deployment time! From Node to Apache/nginx
TAKE #7:
manage new development
Evolve existing multi page URLs to single
● inject CSS from parent window
● build views in your SPA
● instantiate in multi page
● inject in parent DOM
● it’s really hard but a temporary
workaround until APIs are
available!
Now or Never:
current state and future
3 years later and 42 microservices after...
● refactoring well is a long and
sloooow process...
● ...but we release weekly!
● the SPA approach allows iterating
much faster
● also designers with front-end skills
can easily build prototypes!
What didn’t work so well
● login pages must be fast!
● FOUC (flash of unstyled content)
● existing “SPAlets” taking full
control of the page (we had some
GWT ones) are hard to integrate
● IE9 and hash URLs
● bundle JavaScript in chunks
Disclaimer! Problems we didn’t have to solve
● it’s a web application, not a website
● URLs are forever
● SEO
○ googlebot crawls #! URLs
○ what about the others?
● browsers with JavaScript disabled
● IE less than 9
● first render speed
● should we go isomorphic?
TAKE #8:
build an amazing team!
Frontend and Backend teams working together
the Web Squad builds
the web frontend user
interface...
…but the Cirrus Squad
provides the API our
features build upon!
A Futurama Halloween!
Thanks!
ROME 18-19 MARCH 2016
contacts
marcello.teodori@gmail.com
@magomarcelo
All pictures belong
to their respective authors

More Related Content

What's hot

Amsterdam.js talk: node webkit
Amsterdam.js talk: node webkitAmsterdam.js talk: node webkit
Amsterdam.js talk: node webkit
Fabian Jakobs
 

What's hot (20)

10 Useful Front End Development Tools for Web Apps | 2020
10 Useful Front End Development Tools for Web Apps | 202010 Useful Front End Development Tools for Web Apps | 2020
10 Useful Front End Development Tools for Web Apps | 2020
 
Js frameworks
Js frameworksJs frameworks
Js frameworks
 
Pavel Prischepa. Wodby
Pavel Prischepa. WodbyPavel Prischepa. Wodby
Pavel Prischepa. Wodby
 
The Saga of JavaScript and TypeScript: Part 1
The Saga of JavaScript and TypeScript: Part 1The Saga of JavaScript and TypeScript: Part 1
The Saga of JavaScript and TypeScript: Part 1
 
Headless Drupal: A modern approach to (micro)services and APIs
Headless Drupal: A modern approach to (micro)services and APIsHeadless Drupal: A modern approach to (micro)services and APIs
Headless Drupal: A modern approach to (micro)services and APIs
 
WebMatrix
WebMatrixWebMatrix
WebMatrix
 
.Net Core
.Net Core.Net Core
.Net Core
 
React Native
React NativeReact Native
React Native
 
Micro Frontends Architecture - Jitendra kumawat (Guavus)
Micro Frontends Architecture - Jitendra kumawat (Guavus)Micro Frontends Architecture - Jitendra kumawat (Guavus)
Micro Frontends Architecture - Jitendra kumawat (Guavus)
 
Performance optimization of vue.js apps with modern js
Performance optimization of vue.js apps with modern jsPerformance optimization of vue.js apps with modern js
Performance optimization of vue.js apps with modern js
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
 
MongoDB Jump Start
MongoDB Jump StartMongoDB Jump Start
MongoDB Jump Start
 
The Full Stack Web Development
The Full Stack Web DevelopmentThe Full Stack Web Development
The Full Stack Web Development
 
PWA basics for developers
PWA basics for developersPWA basics for developers
PWA basics for developers
 
Open source day in .NET
Open source day in .NETOpen source day in .NET
Open source day in .NET
 
Amsterdam.js talk: node webkit
Amsterdam.js talk: node webkitAmsterdam.js talk: node webkit
Amsterdam.js talk: node webkit
 
Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start)
 
Agriya services
Agriya servicesAgriya services
Agriya services
 
Convert your Full Trust Solutions to the SharePoint Framework (SPFx)
Convert your Full Trust Solutions to the SharePoint Framework (SPFx)Convert your Full Trust Solutions to the SharePoint Framework (SPFx)
Convert your Full Trust Solutions to the SharePoint Framework (SPFx)
 
Devoxx France - Web Components, Polymer et Material Design
Devoxx France -  Web Components, Polymer et Material DesignDevoxx France -  Web Components, Polymer et Material Design
Devoxx France - Web Components, Polymer et Material Design
 

Viewers also liked

taula de formats Marina Uguet A1
taula de formats Marina Uguet A1taula de formats Marina Uguet A1
taula de formats Marina Uguet A1
Uguet
 
Compromiso por la nueva evangelizacion del mundo de hoy
Compromiso por la nueva evangelizacion del mundo de hoyCompromiso por la nueva evangelizacion del mundo de hoy
Compromiso por la nueva evangelizacion del mundo de hoy
0104257746
 
New Laser Brocher
New Laser BrocherNew Laser Brocher
New Laser Brocher
George Tank
 
Rocket piano advanced v1.2
Rocket piano advanced v1.2Rocket piano advanced v1.2
Rocket piano advanced v1.2
Jenny Pham
 

Viewers also liked (19)

taula de formats Marina Uguet A1
taula de formats Marina Uguet A1taula de formats Marina Uguet A1
taula de formats Marina Uguet A1
 
Compromiso por la nueva evangelizacion del mundo de hoy
Compromiso por la nueva evangelizacion del mundo de hoyCompromiso por la nueva evangelizacion del mundo de hoy
Compromiso por la nueva evangelizacion del mundo de hoy
 
API seeks LTRs
API seeks LTRsAPI seeks LTRs
API seeks LTRs
 
Clase demostrativa pancho
Clase demostrativa panchoClase demostrativa pancho
Clase demostrativa pancho
 
Fitokarantena brecl 93
Fitokarantena brecl 93Fitokarantena brecl 93
Fitokarantena brecl 93
 
Social Media in Action
Social Media in ActionSocial Media in Action
Social Media in Action
 
Infografia Claves para construir los programas de trabajo en un SPA
Infografia Claves para construir los programas de trabajo en un SPAInfografia Claves para construir los programas de trabajo en un SPA
Infografia Claves para construir los programas de trabajo en un SPA
 
Of cult... blady jeff
Of cult... blady jeffOf cult... blady jeff
Of cult... blady jeff
 
Presentación en la Audiencia Pública 2009 - Desarrollo Economico
Presentación en la Audiencia Pública 2009 - Desarrollo EconomicoPresentación en la Audiencia Pública 2009 - Desarrollo Economico
Presentación en la Audiencia Pública 2009 - Desarrollo Economico
 
Infografia Acuerdos de colaboracion entre SPAs (vigilancia de la salud)
Infografia Acuerdos de colaboracion entre SPAs (vigilancia de la salud)Infografia Acuerdos de colaboracion entre SPAs (vigilancia de la salud)
Infografia Acuerdos de colaboracion entre SPAs (vigilancia de la salud)
 
New Laser Brocher
New Laser BrocherNew Laser Brocher
New Laser Brocher
 
Apeim nse-2003-2004-lima
Apeim nse-2003-2004-limaApeim nse-2003-2004-lima
Apeim nse-2003-2004-lima
 
New american-stramline-destinations-glossary-part-a
New american-stramline-destinations-glossary-part-aNew american-stramline-destinations-glossary-part-a
New american-stramline-destinations-glossary-part-a
 
Rocket piano advanced v1.2
Rocket piano advanced v1.2Rocket piano advanced v1.2
Rocket piano advanced v1.2
 
Humming earthquakes incident - حادثة الطنين من الزلازل والاهتزاز وتصدع الأبن...
 Humming earthquakes incident - حادثة الطنين من الزلازل والاهتزاز وتصدع الأبن... Humming earthquakes incident - حادثة الطنين من الزلازل والاهتزاز وتصدع الأبن...
Humming earthquakes incident - حادثة الطنين من الزلازل والاهتزاز وتصدع الأبن...
 
Dual Systems Design Shear wall-Frame InterAction تصميم الجملة القصية الثنائية...
Dual Systems Design Shear wall-Frame InterAction تصميم الجملة القصية الثنائية...Dual Systems Design Shear wall-Frame InterAction تصميم الجملة القصية الثنائية...
Dual Systems Design Shear wall-Frame InterAction تصميم الجملة القصية الثنائية...
 
Taller De Circulo Magico
Taller De Circulo MagicoTaller De Circulo Magico
Taller De Circulo Magico
 
+654354
+654354+654354
+654354
 
Sp loc-o7-04-jesus ensenadelasactitudes
Sp loc-o7-04-jesus ensenadelasactitudesSp loc-o7-04-jesus ensenadelasactitudes
Sp loc-o7-04-jesus ensenadelasactitudes
 

Similar to Refactoring to a SPA

Similar to Refactoring to a SPA (20)

APIs for mobile
APIs for mobileAPIs for mobile
APIs for mobile
 
Web summit.pptx
Web summit.pptxWeb summit.pptx
Web summit.pptx
 
Decoupled Architecture and WordPress
Decoupled Architecture and WordPressDecoupled Architecture and WordPress
Decoupled Architecture and WordPress
 
Exploring pwa for shopware
Exploring pwa for shopwareExploring pwa for shopware
Exploring pwa for shopware
 
Industrial Training.pptx
Industrial Training.pptxIndustrial Training.pptx
Industrial Training.pptx
 
Design Summit - Technology Vision - Oleg Barenboim and Jason Frey
Design Summit - Technology Vision - Oleg Barenboim and Jason FreyDesign Summit - Technology Vision - Oleg Barenboim and Jason Frey
Design Summit - Technology Vision - Oleg Barenboim and Jason Frey
 
Sp sat philly2019
Sp sat philly2019Sp sat philly2019
Sp sat philly2019
 
5 Powerful Backend Frameworks for Web App Development in 2022
5 Powerful Backend Frameworks for Web App Development in 20225 Powerful Backend Frameworks for Web App Development in 2022
5 Powerful Backend Frameworks for Web App Development in 2022
 
WordPress as a Headless CMS - Bronson Quick
WordPress as a Headless CMS - Bronson QuickWordPress as a Headless CMS - Bronson Quick
WordPress as a Headless CMS - Bronson Quick
 
Progressive web applications
Progressive web applicationsProgressive web applications
Progressive web applications
 
Going from Classic to Modern. 10 Things you must know before you commit
Going from Classic to Modern. 10 Things you must know before you commitGoing from Classic to Modern. 10 Things you must know before you commit
Going from Classic to Modern. 10 Things you must know before you commit
 
Spsat nyc19 190621150118
Spsat nyc19 190621150118Spsat nyc19 190621150118
Spsat nyc19 190621150118
 
List of Web Technologies used in Web Development
List of Web Technologies used in Web DevelopmentList of Web Technologies used in Web Development
List of Web Technologies used in Web Development
 
Always on! ... or not?
Always on! ... or not?Always on! ... or not?
Always on! ... or not?
 
Top Node.JS Frameworks to Look at in 2020
Top Node.JS Frameworks to Look at in 2020Top Node.JS Frameworks to Look at in 2020
Top Node.JS Frameworks to Look at in 2020
 
Important Backend Frameworks To Remember For Businesses In 2023
Important Backend Frameworks To Remember For Businesses In 2023Important Backend Frameworks To Remember For Businesses In 2023
Important Backend Frameworks To Remember For Businesses In 2023
 
Angular webinar - Credo Systemz
Angular webinar - Credo SystemzAngular webinar - Credo Systemz
Angular webinar - Credo Systemz
 
Introduction to Web Frameworks
Introduction to Web FrameworksIntroduction to Web Frameworks
Introduction to Web Frameworks
 
AFTAB AHMED.pptx
AFTAB AHMED.pptxAFTAB AHMED.pptx
AFTAB AHMED.pptx
 
Webdevelopment
WebdevelopmentWebdevelopment
Webdevelopment
 

More from Marcello Teodori

More from Marcello Teodori (13)

Anatomy of an APS 2 appication
Anatomy of an APS 2 appicationAnatomy of an APS 2 appication
Anatomy of an APS 2 appication
 
Wicket from Designer to Developer
Wicket from Designer to DeveloperWicket from Designer to Developer
Wicket from Designer to Developer
 
Software Factory in a Box
Software Factory in a BoxSoftware Factory in a Box
Software Factory in a Box
 
Groovy & Grails
Groovy & GrailsGroovy & Grails
Groovy & Grails
 
m2eclipse: integrazione maven2 in eclipse IDE
m2eclipse: integrazione maven2 in eclipse IDEm2eclipse: integrazione maven2 in eclipse IDE
m2eclipse: integrazione maven2 in eclipse IDE
 
JBoss Seam, un framework per Java EE 5
JBoss Seam, un framework per Java EE 5JBoss Seam, un framework per Java EE 5
JBoss Seam, un framework per Java EE 5
 
Rich Internet Application
Rich Internet ApplicationRich Internet Application
Rich Internet Application
 
Struttin' on, novità in casa Struts
Struttin' on, novità in casa StrutsStruttin' on, novità in casa Struts
Struttin' on, novità in casa Struts
 
Java sul tuo Mac
Java sul tuo MacJava sul tuo Mac
Java sul tuo Mac
 
Sviluppare su OpenOffice.org con Java
Sviluppare su OpenOffice.org con JavaSviluppare su OpenOffice.org con Java
Sviluppare su OpenOffice.org con Java
 
Un backend per tutte le stagioni con Spring
Un backend per tutte le stagioni con SpringUn backend per tutte le stagioni con Spring
Un backend per tutte le stagioni con Spring
 
Streaming in Java e Flex con Red5
Streaming in Java e Flex con Red5Streaming in Java e Flex con Red5
Streaming in Java e Flex con Red5
 
Spring e Flex
Spring e FlexSpring e Flex
Spring e Flex
 

Recently uploaded

Recently uploaded (20)

Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 

Refactoring to a SPA

  • 1. Refactoring to a Single Page Application Marcello Teodori ROME 18-19 MARCH 2016
  • 2. Agenda ● a few definitions ● my experience in Workshare ● some take aways ● current state and future ● what’s your experience?
  • 3. Your traditional web application built on server side technology, whether MVC or component based... A definition for a “Multi Page Application”
  • 4. “A single-page application (SPA) is a web application or web site that fits on a single web page with the goal of providing a more fluent user experience similar to a desktop application. In a SPA, either all necessary code – HTML, JavaScript, and CSS – is retrieved with a single page load.” Single Page Application on WikiPedia
  • 5. “Code refactoring is the process of restructuring existing computer code – changing the factoring – without changing its external behavior. Refactoring improves nonfunctional attributes of the software.” (Code) Refactoring on WikiPedia
  • 6. A refactoring tale: Workshare 1999 Workshare Doc Comparison and Metadata Cleaning Desktop Products Apr 2012 SkyDox acquisition Document Sharing SaaS Ruby monolith #1 aka Cirrus Nov 2012 IdeaPlane acquisition Enterprise Social Network Java monolith aka Social Dec 2014 Dealroom acquisition Legal Transaction WFE Ruby monolith #2 aka Transact now Scaling microservices on BE SPA on FE
  • 7. Cirrus ● Typical Rails Application ● Does a Lot :) ○ including REST API! ● Does Too Much :( ● “Leverages” ActiveRecord! ● You know the end of the story...
  • 9. The Masterplan! ● a spike on a SPA ○ called “supernova-ui” ○ validate we can do JavaScript ● phasing out all server side tech producing front-end code ● migrate backend to microservices ○ Cirrus already provides JSON API ○ Social doesn’t and becomes first microservice: Groups API
  • 11. Moving backend to microservices Wally Users Search Groups Social Cards Homepage Cards Cirrus Sign On Users Users Search Activities Storage Files & Folders Figitus ADAPT BUILD EXTRACT
  • 12. ...and embrace JavaScript! And for the frontend
  • 13. TAKE #1: setup a front-end build
  • 14. Node allows front-end developers to take control ● pick your favourite javascript build template ○ ex. a yeoman generator ● launch a development server ○ ex. via grunt-contrib-connect ● proxy your current web app or API ○ ex. via grunt-connect-proxy ● overlay your changes
  • 15. JavaScript dependency management FTW! chimera core-ui files-ui groups-ui dealroom-ui new-ui
  • 16. Chimera, the myth of a style guide
  • 17. TAKE #2: build a client-side application layout
  • 18. Define your main application layout, client-side ● you will need some basic API ○ user API ○ account API ● application layout ○ topbar ○ sidebar ○ user menu ○ content ● a good candidate for offline
  • 19. The Workshare Application Layout topbar contentsidebar user menu
  • 20. TAKE #3: leave login where it is
  • 21. Authentication is complex, you don’t want to break it! ● typical web form login ● CSRF protection ● authentication via cookie ● support auth cookie on API ● single-sign on flows ● vanity domains
  • 23. iframe are ugly but can be useful... ● content access when on same origin ● native API to communicate ○ window.postMessage ● easy to detect ○ window === window.parent ● listen to URL/hash changes
  • 24. is a backend dev available? cool! ● create a custom page format ○ (ex. nova) ● serve a naked version of your page with just the main content ○ in Rails :layout => false ● in your url_helper modify your href to send a message via javascript to your parent application
  • 25. isn’t a backend dev available? oh no! ● load iframe as hidden ● hide application chrome and anything which is not your main content ● patch CSS if necessary ● patch links to route on SPA ● repeat on URL/hash change
  • 26. TAKE #5: reuse your test suite
  • 27. No refactoring without a proper test suite! ● Robot Framework ○ API tests ○ FE tests via WebDriver ● BDD style test definitions ● Re-use with minimal changes ○ if element selector don’t change! ○ adapt custom keywords ■ Navigate To (new URLs) ■ Locate Element (switch to iframe)
  • 28. TAKE #6: Apache (or nginx) is your friend
  • 29. ● map existing URLs you want to keep ● define your strategy to serve your SPA ○ on a subcontext /new-ui ○ on the root ■ via a custom header x-new-ui=true ■ on a different server ● proxy APIs and iframe pages ○ keep same origin ○ no need for CORS headers It’s deployment time! From Node to Apache/nginx
  • 30. TAKE #7: manage new development
  • 31. Evolve existing multi page URLs to single ● inject CSS from parent window ● build views in your SPA ● instantiate in multi page ● inject in parent DOM ● it’s really hard but a temporary workaround until APIs are available!
  • 32. Now or Never: current state and future
  • 33. 3 years later and 42 microservices after... ● refactoring well is a long and sloooow process... ● ...but we release weekly! ● the SPA approach allows iterating much faster ● also designers with front-end skills can easily build prototypes!
  • 34. What didn’t work so well ● login pages must be fast! ● FOUC (flash of unstyled content) ● existing “SPAlets” taking full control of the page (we had some GWT ones) are hard to integrate ● IE9 and hash URLs ● bundle JavaScript in chunks
  • 35. Disclaimer! Problems we didn’t have to solve ● it’s a web application, not a website ● URLs are forever ● SEO ○ googlebot crawls #! URLs ○ what about the others? ● browsers with JavaScript disabled ● IE less than 9 ● first render speed ● should we go isomorphic?
  • 36. TAKE #8: build an amazing team!
  • 37. Frontend and Backend teams working together the Web Squad builds the web frontend user interface... …but the Cirrus Squad provides the API our features build upon!
  • 39. Thanks! ROME 18-19 MARCH 2016 contacts marcello.teodori@gmail.com @magomarcelo All pictures belong to their respective authors