Sequence Diagram (Sezin Doğan) - bounswe/bounswe2026group4 GitHub Wiki

This is the sequence diagram for commenting on a story and removing one's comment from a story. Note that the sequence diagram for liking a story and removing. one's like from a story would be a simpler version of this.

seq_diag
Code
@startuml
title Sequence Diagram — Comment on Story / Remove Own Comment
actor "u:User" as User
participant ":StoryUI" as StoryUI
participant "c:Comment" as Comment
participant "s:Story" as Story
participant "n:Notification" as Notification
database "db:Database" as Database

== Comment on Story ==

User -> StoryUI : write comment text\nclick "Post Comment"
activate StoryUI
StoryUI -> Comment : createComment(storyId, userId, text)
activate Comment
Comment -> Comment : validateComment(text)

alt "invalid comment"
    Comment --> StoryUI : showError("Invalid comment")
else "valid comment"
    Comment -> Story : verifyStoryExists(storyId)
    activate Story
    Story -> Database : queryStory(storyId)
    activate Database
    Database --> Story : storyResult
    deactivate Database
    alt "story not found"
        Story --> Comment : storyNotFound
        deactivate Story
        Comment --> StoryUI : showError("Story not found")
    else "story exists"
        Story --> Comment : storyValid
        deactivate Story
        Comment -> Database : insertComment(storyId, userId, text)
        activate Database
        Database --> Comment : commentId
        deactivate Database
        Comment -> Story : updateCommentCount(storyId)
        activate Story
        Story -> Database : incrementCommentCount(storyId)
        activate Database
        Database --> Story : OK
        deactivate Database
        Story --> Comment : OK
        deactivate Story
        Comment -> Notification : notifyStoryOwner(commentId)
        activate Notification
        Notification --> Comment : OK
        deactivate Notification
        Comment --> StoryUI : displayNewComment(commentId)
        deactivate Comment
        deactivate StoryUI
    end
end


== Remove Own Comment ==

User -> StoryUI : click "Delete Comment"
activate StoryUI
StoryUI -> Comment : deleteComment(commentId, userId)
activate Comment
Comment -> Database : getComment(commentId)
activate Database
Database --> Comment : commentRecord
deactivate Database

alt "user not owner"
    Comment --> StoryUI : showError("Not authorized")
else "user is owner"
    Comment -> Database : deleteComment(commentId)
    activate Database
    Database --> Comment : OK
    deactivate Database
    Comment -> Story : updateCommentCount(storyId)
    activate Story
    Story -> Database : decrementCommentCount(storyId)
    activate Database
    Database --> Story : OK
    deactivate Database
    Story --> Comment : OK
    deactivate Story
    Comment --> StoryUI : removeCommentFromUI(commentId)
deactivate Comment
deactivate StoryUI
end
@enduml
⚠️ **GitHub.com Fallback** ⚠️