Skip to content

UML Sequence Diagram

cemsarpkaya edited this page May 15, 2025 · 23 revisions

Sequence Diagrams

Log in*
sequenceDiagram

actor User as Personal User

participant System as AuthenticationSystem

User ->> System : login(username,password)

activate System

System -->> System : h = hashPassword(password)

System ->> Database : query(username, h)

activate Database

Database -->> System : response

deactivate Database

alt response == FOUND

System -->> User : response

else response != FOUND

System -->> User : response

deactivate System
end
Loading
Register*
sequenceDiagram

actor User as Non-Registered User

User ->> NonRegisteredUser : register(username,password,email)

activate NonRegisteredUser


NonRegisteredUser -->> NonRegisteredUser : response = validateEmail(email)

alt response == true

NonRegisteredUser ->> AuthenticationSystem : hashPassword(password)

activate AuthenticationSystem

AuthenticationSystem -->> NonRegisteredUser : h

deactivate AuthenticationSystem

NonRegisteredUser ->>  Database : add(username, h ,email)

activate Database

Database -->> NonRegisteredUser : status

deactivate Database

NonRegisteredUser -->> User : response

else response == false

NonRegisteredUser -->> User : response

deactivate NonRegisteredUser
end
Loading
Rate Health Score of a Recipe*
sequenceDiagram

actor User as Dietitian (User)


User ->> Dietitian : rateRecipeHealthiness(recipe, score)

activate Dietitian

participant R as recipe : Recipe

Dietitian ->> R : updateRating("health", score)
activate R

R ->> Database : update(recipe.id, recipe.healthRating)

activate Database

Database -->> R : status

deactivate Database

R -->> Dietitian : response

deactivate R

Dietitian -->> User : response

deactivate Dietitian
Loading

*: In these diagrams, error/exception handling due to reasons unrelated to the user input are omitted for the sake of simplicity.

Like A Recipe
sequenceDiagram
    actor U as User (logged in)
    participant RU as RegisteredUser
    participant R as Recipe
    participant DB as Database

    Note over RU: RU.likedRecipes: List<Recipe>
    Note over R: R.likes: int

    U->>RU: likeRecipe(R)
    alt R NOT in RU.likedRecipes
        RU->>R: addLike()
        R->>DB: addLike(RU, R)
        DB-->>R: {status}
        alt status = success
            R-->>RU: {status}
            RU->>RU: likedRecipes.add(R)
            RU->>U: show "Recipe liked successfully"
        else status = failure
            R-->>RU: {status}
            RU->>U: show "Failed to like recipe"
        end
    else R in RU.likedRecipes
        RU->>R: removeLike()
        R->>DB: removeLike(RU, R)
        DB-->>R: {status}
        alt status = success
            R-->>RU: {status}
            RU->>RU: likedRecipes.remove(R)
            RU->>U: show "Recipe unliked successfully"
        else status = failure
            R-->>RU: {status}
            RU->>U: show "Failed to unlike recipe"
        end
    end


Loading
Follow A User
sequenceDiagram
    actor U as User (logged in)
    participant RU as RegisteredUser (Follower)
    participant TU as RegisteredUser (Target)
    participant DB as Database

    U->>RU: followUser(TU)
    RU->>DB: followUser(RU, TU)
    DB-->>RU: {status}
    alt status = success
        RU->>RU: followedUsers.add(TU)
        TU->>TU: followerUsers.add(RU)
        RU->>U: show "Successfully followed user"
    else status = failure
        RU->>U: show "Failed to follow user"
    end





Loading
Delete A Recipe Comment
sequenceDiagram
    actor U as User (logged in)
    participant RU as RegisteredUser
    participant RC as RecipeComment
    participant R as Recipe
    participant DB as Database

    U->>RU: deleteRecipeComment(RC)
    RU->>RC: deleteRecipeComment()
    RC->>DB: deleteRecipeComment(RC)
    DB-->>RC: {status}
    alt status = success
        RC-->>RU: {status}
        RU->>R: removeComment(RC)
        RU->>U: show "Comment deleted successfully"
    else status = failure
        RC-->>RU: {status}
        RU->>U: show "Failed to delete comment"
    end


Loading
Post a Question (Ali Gokcek)
sequenceDiagram
    actor U as User
    participant RU as RegisteredUser
    participant Q as Question
    participant DB as Database
    
    Note over RU: RU.askedQuestions : List<Question>
    Note over Q: Q.id, Q.title, Q.content, Q.timestamp, etc.

    U->>RU: askQuestion(title, content)
    alt question is VALID
        RU->>Q: construct Question(title, content, RU)
        Note over Q: sets Q.author = RU<br/>assigns Q.id, Q.timestamp, etc.
        Q->>DB: saveQuestion(Q)
        DB-->>RU: {status}
        alt status = success
            RU->>RU: askedQuestions.add(Q)
            Note over RU: Q added to askedQuestions
            RU-->>U: show "Question successfully added"
        else status = failure
            
            Note over RU: rollback changes
            RU-->>U: show error "Question could not be posted"
        end
    else question is INVALID
        RU-->>U: show error "Invalid question data"
    end

Loading
Rate Taste/Difficulty Score (Ali Gokcek)
sequenceDiagram
    actor U as User
    participant RU as RegisteredUser
    participant R as Recipe
    participant DB as Database

    Note over RU: RU.ratedRecipes : List<Recipe>
    Note over R: R.tasteScore : double<br/>R.difficultyScore : double<br/>R.numberOfRatings : int

    U->>RU: rateRecipe(R, category, rate)
    RU->>R: updateRating(category, rate)
    Note over R: updates aggregate ratings<br/>e.g., R.tasteScore, R.difficultyScore
    R->>DB: updateRecipeRating(R.id, R.tasteScore, R.difficultyScore)
    DB-->>R: {status}
    R-->>RU: {status}
    alt status = success
        alt R NOT in RU
            RU->>RU: ratedRecipes.put(R)
            Note over RU: first time rating stored
        else R ALREADY in RU
            Note over RU: no changes needed on RU
        end
        RU-->>U: show "Rating successfully recorded"
    else status = failure
        Note over RU: rollback changes if needed
        RU-->>U: show error "Rating could not be recorded"
    end



Loading
Filter Recipes (Ali Gokcek)
sequenceDiagram
    actor U as User
    participant RU as RegisteredUser
    participant DB as Database



    U->>RU: filterRecipes(criteria)
    RU->>DB: findRecipesByCriteria(criteria)
    alt Matching recipes found
        DB-->>RU: {result}
        RU->>RU: process/filter/sort results (optional)
        RU-->>U: {result}
    else NO matching recipes found
        DB-->>RU: {empty list}
        RU-->>U: {empty list}
        Note over U: No matching recipes found
    end

Loading

👥 Team Members

📌 Milestone Report

💬 Communication Plan

📋 Meeting Agendas

📅 Meeting Notes

📂 Backend Subgroup Meeting Notes

📂 Frontend Subgroup Meeting Notes

📂 Mobile Subgroup Meeting Notes

📚 Lecture Notes

🛠️ Team Best Practices

✍️ Guidance

❗ Issues

🚀 Project

🧱 Diagrams

👩‍💼 User Scenarios

Click to Expand ⬇️

🗂️ Templates

Clone this wiki locally