DEV Community

Richard Kovacs
Richard Kovacs

Posted on • Edited on

Sequence diagrams are so powerful

In this post, I would like to highlight the importance of sequence diagrams. As a tech lead, I'm involved in many projects in different teams. The team has an idea, they organize some brainstorming and they create some kind of documentation about what they would like to achieve with the shiny new stuff. Usually, that is the point where they ask me to make some design decision or just simply review what they have. In my experience, those initial design docs don't cover everything. This is the natural way of evolving a project but those blind spots don't help technical decisions. The devil lives in the details, you know (or would know). So usually I need a tool to find the missing part, which saves time for me and helps intelligibility of problems for the team at the same time. I'm not a visual person, I hate drawing or selecting the right colors for boxes. On the other hand, I also don't prefer non-reproducible, binary formats or hardly editable SVGs. I like to put the end result into version control, so I'm looking for a wooden wedge simply solution like sequence diagrams.

Please allow me to advise https://sequencediagram.org/.

Image description

This looks good enough, team members should understand easily what is happening and helps investigate what is missing to make proper design decisions. It is shareable and finally, it is just simple code:

title Sample project

actor User
participantgroup #pink **Cluster**
    participantgroup #lightgreen **  Fancy\nfrontend**
        fontawesome5regular f0f8 Frontend
    end
    participantgroup #lightblue **  Fancy\nbackend**
        control Backend
        database Database
    end
    entity #grey:1 Third party
end

group #2f2e7b Some user action #white
    abox over Third party:We haven't choose an implementation
    User->Frontend:Change something
    Frontend->Backend:Validate
    activate Backend
    Backend->Backend:Validate
    Backend->Database:Persist
    deactivate Backend
    Backend<--Database:Watch persisted
    activate Backend
    Backend<->Database:Fetch something
    Backend->Backend:Validate everything
    alt In some case
        Backend->Frontend:Send notification to user
        Frontend-->>User:Send notification
    else Other case
        Backend->Frontend:Create a job
        create Job
        Backend->Job:Create
        Job->Third party:Interact with third party
        destroysilent Job
        Backend->Frontend:Send notification to user
        Frontend-->>User:Send notification
        deactivate Backend
    end
end

Enter fullscreen mode Exit fullscreen mode

Top comments (0)