Skip to content

Sequence Diagrams

Süleyman Emir Taşan edited this page Apr 30, 2024 · 32 revisions

1. Follow-Unfollow User

sequenceDiagram
    actor R as Registered User
    alt follow
        R->>+ Profile: followUser(user)
        Profile->>+ Database: insert_user_follow(registered_user, user)
        alt insertion is successful
            Database-->>Profile: success
            Profile-->>R: success
        else 
            Database-->>-Profile: failure
            Profile-->>-R: failure
        end
    else unfollow
        R->>+ Profile: unfollowUser(user)
        Profile->>+ Database: delete_user_follow(registered_user, user)
        alt deletion is successful
            Database-->>Profile: success
            Profile-->>R: success
        else 
            Database-->>-Profile: failure
            Profile-->>-R: failure
        end
    end
Loading

2. Create Post

sequenceDiagram
    actor R as Registered User
        R->>+ Post: createPost(post)
        Post->>+ Database: create_post(registered_user, post)
        alt insertion is successful
            Database-->>Post: success
            Post-->>R: success
        else 
            Database-->>-Post: failure
            Post-->>-R: failure
        end
Loading

3. Filter Songs

sequenceDiagram
    actor R as User
    create participant Filter
    R->> Filter: initiate(Map<K,V>)
    destroy Filter
    Filter-->> R: filter:Filter
    R->>+ SearchEngine: searchSongs(filter: Filter)
    SearchEngine->>+ Database: get_appropriate_songs(Map<K, V>)
    alt searching is successful
        Database-->>SearchEngine: List<Song>
        SearchEngine-->>R: List<Song>
    else searching is not successful
        Database-->>-SearchEngine: noSongFound
        SearchEngine-->>-R: noSongFound
    end
Loading

4. Filter User Profiles

sequenceDiagram
    actor R as User
    create participant Filter
    R->> Filter: initiate(Map<K,V>)
    destroy Filter
    Filter-->> R: filter:Filter
    R->>+ SearchEngine: searchUsers(filter: Filter)
    SearchEngine->>+ Database: get_appropriate_user_profiles(Map<K, V>)
    alt searching is successful
        Database-->>SearchEngine: List<Profile>
        SearchEngine-->>R: List<Profile>
    else searching is not successful
        Database-->>-SearchEngine: noProfileFound
        SearchEngine-->>-R: noProfileFound
    end
Loading

5. Change Profile Details

sequenceDiagram
    actor User
    participant Profile
    participant Database
    User->>+Profile: setBio(bio: String)
    Profile->>+Database: update_bio(String)
    alt update is successful
        Database-->>Profile: success
        Profile-->>User: true
    else
        Database-->>-Profile: failure
        Profile-->>-User: false
    end
Loading

6. Login

sequenceDiagram
    actor User
    participant UserController
    participant Database
    User->>+UserController: login(username: String, password: String)
    UserController->>+Database: check_credentials(username: String, password: String)
    alt credentials are valid
        Database-->>UserController: success
        UserController-->>User: Logged in successfully
    else
        Database-->>-UserController: failure (Invalid credentials)
        UserController-->>-User: Login failed: Invalid username or password
    end
Loading

7. Register

sequenceDiagram
    actor GuestUser
    participant UserController
    participant Database
    GuestUser->>+UserController: register(Map<K, V>)
    UserController->>+Database: add_user(Map<K, V>)
    alt No existing user with same username
        Database-->>UserController: success
        UserController-->>GuestUser: Registered successfully
    else
        Database-->>-UserController: failure (User exists)
        UserController-->>-GuestUser: Registration failed: Username already exists
    end
Loading

8. Load Feed Page

sequenceDiagram
    actor R as User
    create participant SwitchToFeed
    R->> SwitchToFeed: switch to the FeedPage
    destroy SwitchToFeed
    SwitchToFeed-->> R: switch:FeedPage
    R->>+ FeedPage: loadFeed(switch: SwitchToFeed)
    FeedPage->>+ Database: get_recommended_posts(user_id)
        alt Success
        Database-->>FeedPage: List<Posts>
        FeedPage-->>R: listPosts(post_ids, sorting_criteria) 
    else Failure
        Database-->>-FeedPage: <ERR_CODE>
        FeedPage-->>-R: displayError(ERR_CODE, 'Post could not be found')
    end
Loading

9. Like a Post

sequenceDiagram
    actor R as User

    R->>+FeedPage: likePost(post_id)
    FeedPage->>+ Database: addLikedUser(user: User)
    alt Success
        Database-->>FeedPage: <Liked the Post>
        FeedPage-->>R: Post has been liked
    else Failure
        Database-->>-FeedPage: <ERR_CODE>
        FeedPage-->>-R: displayError(ERR_CODE, 'Post could not be liked')
    end
Loading

10. Comment to a Post

sequenceDiagram
    actor R as User
    create participant CreateAComment
    R->> CreateAComment: write a Comment
    destroy CreateAComment
    CreateAComment-->> R: switch:FeedPage
    R->>+FeedPage: commentToAPost(post_id, comment)
    FeedPage->>+ Database: addComment(comment: Comment)
    alt Success
        Database-->>FeedPage: <Comment added to Post>
        FeedPage-->>R: Comment has been added to Post
    else Failure
        Database-->>-FeedPage: <ERR_CODE>
        FeedPage-->>-R: displayError(ERR_CODE, 'Comment could not be added')
    end
Loading

11. See Search History

sequenceDiagram
    actor R as Registered User
    R->>+ Profile: getSearchHistory()
    Profile ->>+ Database: getSearchHistory(username: string)
    alt search history found
        Database-->> Profile: search_history
        Profile --> R : search_history
    else 
        Database-->>- Profile: failure
        Profile-->>- R: failure
    end
Loading

12. Refresh Page

sequenceDiagram
actor R as User
    alt Logged in
        R->> Database: getProfilePicture()
        Database-->> R: String
        create participant SwitchToFeed
        R->> SwitchToFeed: switch to the FeedPage
        destroy SwitchToFeed
        SwitchToFeed-->> R: switch:FeedPage
        R->>+ FeedPage: loadFeed(switch: SwitchToFeed)
        FeedPage->>+ Database: get_recommended_posts(user_id)
        alt Success
            Database-->>FeedPage: List<Posts>
            FeedPage-->>R: listPosts(post_ids, sorting_criteria) 
        else Failure
            Database-->>-FeedPage: <ERR_CODE>
            FeedPage-->>-R: displayError(ERR_CODE, 'Post could not be found')
        end
    else Not logged in
        R->>+ LoginPage: Go to login page
        LoginPage -->>R: switch:LoginPage
    end

Loading

13. Filter Posts

sequenceDiagram
    actor R as User
    create participant Filter
    R->> Filter: initiate(Map<K,V>)
    destroy Filter
    Filter-->> R: filter:Filter
    R->>+ SearchEngine: searchPosts(filter: Filter)
    SearchEngine->>+ Database: get_appropriate_Posts(Map<K, V>)
    alt searching is successful
        Database-->>SearchEngine: List<Post>
        SearchEngine-->>R: List<Post>
    else searching is not successful
        Database-->>-SearchEngine: noPostFound
        SearchEngine-->>-R: noPostFound
    end
Loading

14. Filter Events

sequenceDiagram
    actor R as User
    create participant Filter
    R->> Filter: initiate(Map<K,V>)
    destroy Filter
    Filter-->> R: filter:Filter
    R->>+ SearchEngine: searchEvents(filter: Filter)
    SearchEngine->>+ Database: get_appropriate_Events(Map<K, V>)
    alt searching is successful
        Database-->>SearchEngine: List<Event>
        SearchEngine-->>R: List<Event>
    else searching is not successful
        Database-->>-SearchEngine: noEventFound
        SearchEngine-->>-R: noEventFound
    end
Loading

Authors

Deniz, Ebrar, Ramazan, Semih, Süleyman, Utku, Arınç, Abdullah Umut, Güney

🏠 Home

🗃️ All Project Files

💻 Lab Reports

📝 Meeting Notes

Lab Meeting Notes
Team Meeting Notes
🧑🏻‍💻 About Us
🗂️ Templates
CmpE 352

🚀 Important Project Files

🗃️ All Project Files
📝 352 Meeting Notes
📜 Research & Resources
Clone this wiki locally