Search code examples
diagramplantuml

PlantUML - Component diagram with component with inner component in center


I want to have a component diagram with one component with an inner component (nested component) at the center and one component on each side (top, right, down, left) pointing to the center component.

This is what I've tried:

@startuml

' Definition der Akteure (Benutzer)
node Browser as Browser1
actor Benutzer as user

' Definition der Fremdsysteme
node "Fremdsystem (Open Source)" as ExternalSystem1
node "Fremdsystem (zugekauft)" as ExternalSystem2
node "Fremdsystem (zugekauft)" as ExternalSystem3

' Definition des zentralen Systems
rectangle "<size:10>      <<system>></size> \n\n  Hauptsystem" as HS {

}


' Interaktionen zwischen Benutzern und dem System
user -right-> Browser1 : " nutzt"
Browser1 -down-> HS : " HTTPS"

' Interaktionen zwischen Fremdsystemen und dem System
ExternalSystem1 <-right- HS : " HTTPS"
ExternalSystem2 <-left- HS : " HTTPS"
ExternalSystem3 <-up- HS : " SMTP"

@enduml

Without Inner Component

But when I'm inserting the inner component (Forum) to the rectangle like this:

@startuml

' Definition der Akteure (Benutzer)
node Browser as Browser1
actor Benutzer as user

' Definition der Fremdsysteme
node "Fremdsystem (Open Source)" as ExternalSystem1
node "Fremdsystem (zugekauft)" as ExternalSystem2
node "Fremdsystem (zugekauft)" as ExternalSystem3

' Definition des zentralen Systems
rectangle "<size:10>      <<system>></size> \n\n  Hauptsystem" as HS {
   [Forum]
}


' Interaktionen zwischen Benutzern und dem System
user -right-> Browser1 : " nutzt"
Browser1 -down-> HS : " HTTPS"

' Interaktionen zwischen Fremdsystemen und dem System
ExternalSystem1 <-right- HS : " HTTPS"
ExternalSystem2 <-left- HS : " HTTPS"
ExternalSystem3 <-up- HS : " SMTP"

@enduml

With inner component

It's totally screwed.


Solution

  • I got something closer to what you want, but I can't tell you exactly why it works or precisely how I got there. Here is more or less what I did:

    • The system is now a node.
    • Links go to the component ([Forum] as HS) which is not really what you had from the original (system is the HS), but I suspect this is OK for you.
    • I played around with the order of the HS associations to the left and right until I found something that works. It's easiest to do this in an editor that gives immediate rendering (see the link when you click the image below)
    @startuml
    ' Definition der Akteure (Benutzer)
    node Browser as Browser1
    actor Benutzer as user
    
    ' Definition der Fremdsysteme
    node "Fremdsystem (Open Source)" as ExternalSystem1
    node "Fremdsystem (zugekauft)" as ExternalSystem2
    node "Fremdsystem (zugekauft)" as ExternalSystem3
    
    ' Definition des zentralen Systems
    node "Hauptsystem" <<system>> {
       [Forum] as HS
    }
    
    
    ' Interaktionen zwischen Benutzern und dem System
    user -right-> Browser1 : " nutzt"
    Browser1 -down-> HS : " HTTPS"
    
    ' Interaktionen zwischen Fremdsystemen und dem System
    HS -left-> ExternalSystem1 :  "HTTPS              "
    HS -right-> ExternalSystem2 : "              HTTPS"
    ExternalSystem3 <-up- HS : " SMTP"
    @enduml
    

    PlantUML image