Combine two sequence diagrams into one

0 votes
asked Nov 8, 2018 in Question / help by vagvaz (160 points)

I am creating a sequence diagram that shows the interaction between various components. I would like to be able to split the sequence diagram into two and be able to combine them, so I get the same effect as having developed only one. This is useful for maintainability, because one of the two diagrams can be used by more diagrams.
Example let's say that there is a frontend and backend component with the following interactions. Ideally, I would like to have two UMLs with FE and BE and being able to generate one unified, so whenever I change the BE internal processes the unified can be updated (after a regeneration of course)

Is there any way to do this with puml ?


title Dummy

box "FE"

participant "FE UI" as FE.UI

participant "FE Core" as FE.Core

end box

box "BE"

participant "BE ReqHandler" as BE.ReqHandler

participant "BE UserAuth" as BE.UserAuth

participant "BE Bussiness Logic" as BE.BL

participant "BE DB" as BE.DB

end box


FE.UI -> FE.Core : receive_request(a)

FE.Core -> BE.ReqHandler: validate(a)

BE.ReqHandler -> BE.UserAuth: validate_user(a.user)

BE.UserAuth -> BE.DB : get_user(a.user)

alt user does not exist

BE.DB -> FE.UI : error(unknown_user)


BE.UserAuth -> BE.ReqHandler : user_authenticated()


BE.ReqHandler -> BE.BL : process_request(a)

BE.BL -> BE.DB : read_data()

BE.BL -> BE.BL : process_data()

alt invalid request

BE.BL -> FE.UI : error(invalid_request)


BE.BL -> BE.ReqHandler: response(a)


BE.ReqHandler -> FE.Core: request_processed(a)

FE.Core -> FE.UI: show_response(a)


commented Nov 9, 2018 by albert (3,130 points)
I didn't try but did you have a look at the include statement?
commented Nov 9, 2018 by anonymous
Thanks for the answer.
!include does not solve my problem is that include merges UMLs sequentially so the end result would not be the correct sequence diagram although all the steps will be depicted.

Another way of doing this  is to actually have two UML diagrams and not combine them, but reference certain elements on the other UMLs, but I haven't been able to make it work.
I can add a hyperlink to the other UML diagram, but I cannot find a way to create an anchor (or something similar) so I can reference it i.e have two UML diagrams FE and BE
and in the FE have something like [[BE.svg#ENTRY_POINT]]

1 Answer

0 votes
answered Nov 12, 2018 by mgrol (2,740 points)


not if you want to intertwine two independent sequences with parallel processes. 

I do something similar. I write these sequences as macros to symolize some kind of services see here for the example below:

which looks like this  .

This will, however, not exacly duplicate your picture as the error arrow would never go directly to the Fe GUI as it would in my eample just go to the Fe Core and from there you would need to draw a separate arrow to the Fe GUI as it probably happens in your real-life sequence too. Just take a look into macros in general and you will find them quite usefull.

When including files I can adjust the visibility of certain services. Some (SIMPLE) will be displayed as ref-boxes and some (default case) just as text and some (TECHNICAL/DETAILED) will display a lot of technical details. I currently have a repository of over hundred files that provide "service calls" and I can use them as I would call a real service in an application. It is like object oriented implementation. Write your services self-sustained such that they don't need to know what you need inside a macro/service.

If you need a working example, please send me your email address and I try to provide an example to you via email.

Here you can find the way I write my sequences:



@startuml Service1_ServiceDomain
' generated on 2018-11-09T15:18:49.803
'!define TECHNICAL
'!define SIMPLE
'Definition of participants in a common file
'!include ../../common/common.iuml
!ifndef SIMPLE

        ' this macro is defined in common.iuml as e.g. participant "Service 1" as service1
'!include service macro here
' Define soap method here
!definelong Service1_ServiceDomain_method1(CALLER="consumerMethod1",REQ_PARAM="")
    !ifdef SIMPLE
        'Technical view
        !ifdef TECHNICAL
            CALLER -> service1 ++ : Todo with REQ_PARAM

            CALLER <-- service1 : Todo
            !ifdef SHOW_EXCEPTION
                note over service1
                    Possible errors for Service1_ServiceDomain_method1
                    not yet defined
                end note
            deactivate service1
        'Business view
            CALLER -> service1 ++ : Todo business request

            CALLER <-- service1 --: Todo business response

commented Nov 13, 2018 by vagvaz (160 points)
Thanks for your answer.

This is an interesting approach, I have knew macros, but I haven't gone that far in my thinking to use them as you do. I will be interested in a working example, will send you a private msg.
Using macros might provide an acceptable solution in my usecase.