Skip to content

Sequence Diagrams

Enestst edited this page Oct 21, 2024 · 16 revisions

1. User Authentication Processes

1.1 Register

sequenceDiagram
    actor U as User
    participant S as System
    participant DB as Database

    %register
    U->>S: register(username, email, password)
    S->>DB: Check if user exists
    DB-->>S: User does not exist
    S->>DB: Create new user
    DB-->>S: User created
    S->>U: Registration successful
Loading

1.2 Login

sequenceDiagram
    actor U as User
    participant S as System
    participant DB as Database

    %login
    U->>S: login(username, password)
    S->>DB: Validate user credentials
    DB-->>S: Credentials valid
    S->>U: Login successful
Loading

1.3 Logout

sequenceDiagram
    actor U as User
    participant S as System
    participant DB as Database

    %logout
    U->>S: logout()
    S->>DB: Update user session
    DB-->>S: Session updated
    S->>U: Logout successful
Loading

1.4 Edit Profile

sequenceDiagram
    actor U as User
    participant S as System
    participant DB as Database

    %edit_profile
    U->>S: editProfile(username, email, password)
    S->>DB: Retrieve user information
    DB-->>S: User information retrieved
    S->>DB: Update user information
    DB-->>S: User information updated
    S->>U: Profile edited successfully
Loading

1.5 Forget Password

sequenceDiagram
    actor U as User
    participant S as System
    participant DB as Database
    participant M as Mail Server

    %forget_password
    U->>S: forgetPassword(email)
    S->>DB: Check if email exists
    DB-->>S: Email found
    S->>M: Send password reset link to email
    M-->>U: Password reset link sent

    Note over U: User clicks on the reset link
    U->>S: resetPassword(newPassword, token)
    S->>DB: Validate reset token
    DB-->>S: Token valid
    S->>DB: Update password
    DB-->>S: Password updated
    S->>U: Password reset successful
Loading

2. Content Interaction

2.1 Creating a post

sequenceDiagram
    actor U as User
    participant S as System
    participant DB as Database

    %create_post
    U->>S: createPost(content, images[], links[], tags[], id, Date)
    S->>DB: Check user privileges
    DB-->>S: Privileges confirmed
    S->>DB: Save post
    DB-->>S: Post saved
    S->>U: Post creation successful


Loading

2.2 Liking a post

sequenceDiagram
    actor U as User
    participant S as System
    participant DB as Database

    %like_post
    U->>S: likePost(postId)
    S->>DB: Check if post exists
    DB-->>S: Post exists
    S->>DB: Check if user has already liked the post
    DB-->>S: User has not liked the post
    S->>DB: Register the like
    DB-->>S: Like registered
    S->>U: Post liked successfully
Loading

2.3 Bookmark Posts

sequenceDiagram
    participant RegisteredUser
    participant BookmarkService
    participant Post

    RegisteredUser->>+BookmarkService: bookmarkPost(postId)
    BookmarkService->>+Post: getPost(postId)
    alt Post exists
        Post-->>-BookmarkService: postDetails
        BookmarkService->>+BookmarkService: addBookmark(userId, postId)
        BookmarkService-->>-RegisteredUser: success
    else Post does not exist
        BookmarkService-->>-RegisteredUser: failure (Post not found)
    end
Loading

3. User Interaction

3.1 Follow User

 sequenceDiagram
    actor U as User
    participant S as System
    participant DB as Database

    %follow_user
    U->>S: followUser(targetUserId)
    S->>DB: Check if target user exists
    DB-->>S: Target user exists
    S->>DB: Check if already following
    DB-->>S: Not following
    S->>DB: Save follow relationship
    DB-->>S: Follow relationship saved
    S->>U: Follow successful
Loading

3.2 Unfollow User

sequenceDiagram
    actor U as User
    participant S as System
    participant DB as Database

    %unfollow_user
    U->>S: unfollowUser(targetUserId)
    S->>DB: Check if target user exists
    DB-->>S: Target user exists
    S->>DB: Check if currently following
    DB-->>S: Following
    S->>DB: Remove follow relationship
    DB-->>S: Follow relationship removed
    S->>U: Unfollow successful
Loading
Clone this wiki locally