Sequence Diagrams Examples
Here we provide some examples of UML sequence diagrams:
- Online Bookshop
- Submit Comments to Pluck using DWR, AJAX, JSON
- Facebook User Authentication in a Web Application
- Spring and Hibernate transaction management
Spring application development framework for enterprise Java™ integrates Hibernate transaction management. Here we provide an example of UML sequence diagram which illustrates transaction management in relation to exception handling.
An example of high level sequence diagram for Online Bookshop. Online customer can search book catalog, view description of a selected book, add book to shopping cart, do checkout.
An example of sequence diagram for Online Bookshop.
Submit Comments to Pluck
An example of sequence diagram which shows how user comments on some article are submitted to Pluck using various AJAX technologies. (See example of interaction overview diagram with similar semantics at Submit Comments to Pluck using DWR, AJAX, JSON.)
Comments that look Ok are submitted to Pluck server hosting all comments to all articles. AJAX technology is also used in this case both to submit the new comment as well as to get back the list of all recent comments (including the new one). JSON is used to get comments back.
This diagram also shows some duration constraints. (Disclaimer: constraints shown are fictitious and not describing any real communication.) For example, according to the diagram callback waiting time for posted comment varies from 1 to 4 seconds. At the same time, requesting all posted comments takes only up to 100 msec.
Sequence diagram example - submit comments to Pluck using DWR, AJAX, JSON.
Facebook User Authentication in a Web Application
An example of sequence diagram which shows how Facebook (FB) user could be authenticated in a web application to allow access to his/her FB resources. Facebook uses OAuth 2.0 protocol framework which enables web application (called "client"), which is usually not the FB resource owner but is acting on the FB user's behalf, to request access to resources controlled by the FB user and hosted by the FB server. Instead of using the FB user credentials to access protected resources, the web application obtains an access token.
Web application should be registered by Facebook to have an application ID (client_id) and secret (client_secret). When request to some protected Facebook resources is received, web browser ("user agent") is redirected to Facebook's authorization server with application ID and the URL the user should be redirected back to after the authorization process.
User receives back Request for Permission form. If the user authorizes the application to get his/her data, Facebook authorization server redirects back to the URI that was specified before together with authorization code ("verification string"). The authorization code can be exchanged by web application for an OAuth access token.
Sequence diagram example - Facebook User Authentication in a Web Application.
If web application obtains the access token for a FB user, it can perform authorized requests on behalf of that FB user by including the access token in the Facebook Graph API requests. If the user did not authorize web application, Facebook issues redirect request to the URI specified before, and adds the error_reason parameter to notify the web application that authorization request was denied.