Single Page Applications Serverless

Aug 20, 2019 | Publisher: Jack Zheng | Category: Technology & Engineering |  | Collection: Mobile and Web Lecture Notes | Views: 3078 | Likes: 2

SPA, Web API, Serverless the change of web app architectures IT 4203 Advanced Web Development Jack G. Zheng Fall 2019 Overview 2  This lecture notes provides a high level overview of single page applications in the context of web application architecture changes  The context: web application architectures  What is SPA  Key principles and concepts  Enabling technologies The Context 3  Rise of JavaScript/HTML5  JavaScript/HTML5 handle the user interface and interaction functionalities  Changing of web application architectures  Backend and frontend is even more loosely coupled. Rise of JavaScript 4  #1 in GitHub since 2014   #1 in StackOverflow since 2013   Most in demand and salaries, 2015  2015  you-can-find-a-developer-job/  Other rankings  #1 The RedMonk Programming Language Rankings since 2015  #2 in student programmers in hackathon (#1 is HTML/CSS)  #2 in Developer Economics survey  SharePoint/WordPress is moving to JavaScript    Change of Web App Architecture 5  Wave 1: multi-layer/tier systems  Rich (multiple) servers  Wave 2: service oriented  Further separation of server side and client side  Services are more among servers  Wave 3: growing focus on the client side and widely use of AJAX  Rich client development, SPA  More open service model; clients consume services  Wave 4: consuming services from the cloud (third parties)  BaaS and serverless; the client is not tied to its own initiating server Multi-Tier Web Architectures 6  Two tier  Three tier (web app)  Four tier web app In the first wave of architecture change, there was no significant change on the client side Changes were more focused on the server side Service Oriented Architecture 7 The service layer effectively makes clients more like an independent and autonomous service consumer, and less owned by its server part – making things “loosely coupled”. Data can also be services Presentation layer can flexibly moved to the client side. Changing of C/S Interaction 8 UI and data logic move to the client Server provides service Can also be called the AJAX service model Placement of Logic 9 member/wiki/images/8/89 /NexawebAjaxCharacteris tics.pdf Not all business logic is appropriate to move to the client side. Transfer of UI Logic 10  UI logic moves to the client side, which can include  Layout  User interaction  Dynamic effects  Animation  Content presentation update/refresh  These functionalities are handled by HTML5/JavaScript rendering-via-javascript-a-good-idea  The server’s diminished role  The server maintains no UI state.  The server, however, does provide resources to the client. Those resources start out with the initial HTML for the web page (the shell) and may in response to client HTTP requests for data in the form of HTML fragments, JSON data, or on- demand JavaScript/CSS. AJAX + (RESTful) Services 11 This can be any server from any domain BaaS and Serverless 12  The term serverless application has two distinct but related meanings ( us/azure/architecture/reference-architectures/serverless/web- app):  Backend as a service (BaaS). Backend cloud services, such as databases and storage, provide APIs that enable client applications to connect directly to these services.  Functions as a service (FaaS). In this model, a "function" is a piece of code that is deployed to the cloud and runs inside a hosting environment that completely abstracts the servers that run the code.  Both definitions have in common the idea that developers and DevOps personnel don't need to deploy, configure, or manage servers.  Serverless applications are event-driven cloud-based systems where application development rely solely on a combination of third-party services, client-side logic and cloud-hosted remote procedure calls (Functions as a Service). Is it good? 13  See some discussion here  tions/140036/is-it-a-good-idea-to-do-ui-100-in- javascript-and-provide-data-through-an-api What is SPA 14  A single-page application (SPA) is a web application or web site (the whole application or site) that fits on a single web page with the goal of providing a more fluid user experience similar to a desktop application.  The page does not reload at any point in the process, nor does control transfer to another page.  The application or the page involves dynamic communications with the server behind the scenes.  It’s an extreme version of rich client focused web application architecture SPA Key Principles and Concepts 15  Page/shell  View  Data/resource Page/Shell 16  The “page” in SPA is the single web page that the server sends to the browser when the application starts. It’s the server rendered HTML that gets everything started. No more, no less.  Initial page acted as a holder for content, UI, style, and other logic.  The shell is the layout and structure of your app. The visual parts that rarely change.  The shell is generally loaded on the initial page load from the server and serves as the placeholder for all of your views. It can also be dynamically loaded progressively.  The page/shell does not reload at any point in the process, nor does control transfer to another page. View 17  The Views are HTML (UI) fragments that make up what the users commonly call screens or pages.  A particular “sub-page” “partial page” within the shell.  Could be the complete page, a section (div) of the page, or just certain areas all round the page.  Different views can be presented at the same time and do not interfere each other (multi-view, multi-doc interface)  Transition (navigation) between views  URL routing by simulating HTTP request User Interactions 18  All user interactions and actions happen within the page.  All results (view changes) due to these actions are presented directly in the page.  Multiple actions/interactions are possible and should not interfere one other (multi-tasking). Data/Resources 19  SPA makes requests for resources from the server on-demand  Those resources may be JSON data, HTML fragments, JavaScript or CSS  The server provides resources/data, not pages (except for the initial page) Applications 20  SPA is good for many applications that try to replicate desktop app experience where user interactions are more intensive  Examples  Many email apps  Google Gmail, Outlook Web  Office/editing apps  Office 365  Google Docs   SPA is not (Exactly) Single Page Website 21  Single or one page web site is a website designed in one (physical) web page  Rooted from the web design community as a UI design style.  Focus on content and the flow of content; does not focus on interactions between server and client  Definitions did have changed to accommodate trends; and more recently came across SPA   Typical examples    More examples:, Technical Approaches 22  AJAX – the focus of this course  WebSocket  Browser Plugin Driving Technologies 23  Key elements (this course will focus on bare- bone SPA without frameworks)  JavaScript  AJAX  Standard data transfer format especially JSON  RESTful web services (APIs)  More (a research project?)  HTML 5 (web storage, web sockets, history)  Data model/storage  Frameworks  Browser plugin Three Key Parts 24  Server side: services, APIs  A server provides data or functionalities through standard service APIs (RESTful service APIs)  Communication: AJAX  Client communicates with service providers via AJAX  AJAX provides dynamic and continuous user experience  Client side: JavaScript (jQuery)  handles communication and consumes services  controls logic (UI, data, business) and events Web API Overview 25  Web APIs are interfaces exposed based on web technologies  development--net-22368  Server side: similar as web services, interface exposed through HTTP methods   Major API techniques  SOAP web services  RESTful web services  JavaScript  Major data/message format  XML and XML-based: RSS/Atom (feeds)  JSON  Directory of web APIs   RESTful Web Services 26  The RESTful Web Service is an approach for using REST as a communication technology to build SOA  In other words, services are exposed using REST style interfaces  RESTful web services = REST + Web Services  Key principles and practices  Expose directory structure-like URIs.  Use HTTP methods explicitly.  Use multiple representations (XML, JSON, or both)  Be stateless.  More   tutorial/240169069 RESTful web services URI 27  General format  Examples  http://MyService/Persons/1    Parameters  Parameters are used for options to serve the representation, like  http://MyService/Persons/1?format=xml&encoding=UTF8  NOT for part of the resource  http://MyService/Persons?id=1 Protocol://ServiceName/ResourceType/ResourceID JSON 28  JSON (JavaScript Object Notation) is a lightweight data-interchange format.  It is easy for humans to read and write.  It is easy for machines to parse and generate.  It is based on a subset of the JavaScript Programming Language.  JSON is built on two structures:  A collection of name/value pairs.  An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.  Detailed definition at AJAX 29  AJAX (Asynchronous JavaScript and XML) is a group of interrelated web development techniques used on the client-side to create interactive web applications.  Despite the name, the use of XML is not actually required, nor do the requests need to be asynchronous.  AJAX incorporates:  standards-based presentation using HTML and CSS;  dynamic display and interaction using the Document Object Model;  data interchange and manipulation using XML, JSON, or preformatted HTML;  asynchronous operations and communications using XMLHttpRequest;  JavaScript binding everything together. Ajax Model  With Ajax, web applications can communicate with servers in the background without a complete page loading after every request/response cycle. 30 The server prepares partial pages or just data without markups. JavaScript/jQuery 31  JavaScript unified everything together  AJAX is handled by JavaScript and the browser  JSON is a native JavaScript object and can be directly parsed and read by JavaScript once it is returned from the server  UI (views) is managed by JavaScript through DOM manipulation (dynamic HTML)  Actions/events are handled by JavaScript  JavaScript consumes services  A Simple Complete Cycle 32 Server Browser Service providers (can be same or another server) 1. Initial request 2. Initial response to load the shell 3. Load the shell 5. Ajax call for a service 6. Service response provided as JSON 4. User action to do something 7. JS parse the returned JSON and update page views (partial page update) Benefits 33  Dynamic and interactive  Loads quickly, smooth transition between views  Client based processing, highly responsive  See some discussion here  -page-application-advantages-and-disadvantages Challenges and More Issues 34  Navigation, browser history  Client data model/storage  Session/state control - on the server or client?  Two way communication (duplex)? (Web socket, push)  Data binding methods  Frameworks  Web analytics of SPA  SEO, not search friendly Good Resources 35  Core readings  JavaScript’s role:  The new Web application architectures and their impacts for enterprises    Client centered web app architecture:  An introduction to single page applications: - SPA will be our focus of the course (project) throughout the semester. Get some initial conceptual understanding first. Read the comments as well.  What is Serverless Architecture?  JavaScript’s role:    The new Web application architectures and their impacts for enterprises     Client centered web app architecture:  Single page app      Serverless  

An introduction of Single Page Applications and the change of web app architectures in the first class of IT 4203 Advanced Web Development at Kennesaw State University.

About Jack Zheng

Associate Professor at


You must log in to comment


Modal Header

Modal body