0

This my first UML diagram for user registration flow.

After double checking the diagram I feel that I have a crowded diagram compared to what I can found in Google search.

My questions:

Are my alt and else branches usage correct?

Is it valid to include error responses in the sequence diagrams?

Is it valid to include the notes I have included?

Here is my Sequence Diagram design:

enter image description here

And here is my Sequence Diagram code:

@startuml

actor Client
participant Controller
participant UserRepository
participant UserProfileRepository
database MongoDB

Client -> Controller ++ : Registration Request
note left
Http Method: POST
Token Type: CREDENTIALS
Token: EMAIL:PASSWORD
end note

Controller -> Controller : Validate token type,\nemail, password\nand email not already\nused

alt if all are valid
Controller -> UserRepository ++ : Create new user
UserRepository -> MongoDB : Save created\nuser in DB
UserRepository -> Controller -- : Return created user

Controller -> UserProfileRepository ++ : Create new user profile
UserProfileRepository -> MongoDB : Save created user\nprofile in DB
UserProfileRepository -> Controller -- : Return created user profile

Controller -> Client : Return user id
note left
Http Status : 201 Created
User id returned in Header
Location: /users/USER_ID,/usersProfiles/USER_ID
end note
else if invalid token
Controller -> Client : invalid request
note left
Http Status : 400 Bad Request
end note
else if invalid email
Controller -> Client : invalid email
note left
Http Status : 400 Bad Request
end note
else if invalid password
Controller -> Client : invalid invalid password
note left
Http Status : 400 Bad Request
end note
else if email already used
Controller -> Client -- : user already exist
note left
Http Status : 409 Conflict
end note
end

@enduml
1
  • StartUML has a couple of flaws. One of them are arrows (in general). Above is a mixture of a/synch. They are half open/filled. Sync is a filled triangle, asynch an open arrow.
    – user188153
    May 15, 2020 at 10:24

1 Answer 1

2

You forgot to ask the most important thing: can my diagram be understood?
Fortunately, the answer to that is: Yes, it is perfectly well understandable.

For the questions you did ask, the answer is also to all of them that it is correct.

There are some things that I would have done differently or not entirely correct in the diagram, but I am not sure in how far that is due to a limitation in the tool you use.

  • The return arrows from a function call should be dashed arrows with an open arrowhead, like this - ->. They are typically only given a label when the return value is not obvious from how the call is made.
  • Personally, I would have used the HTTP status code as label on the corresponding arrow, rather than mentioning it in a separate note. The fact that you are using HTTP is already clear from the note on the initial request message.
1
  • 1
    return arrows from a function call should be dashed no. It's must.
    – user188153
    May 15, 2020 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.