@startuml
skin rose
skinparam backgroundColor #EEEBDC
hide empty description

[*] --> Registration

state Registration {
  Registration --> Email_Validation 
  Registration --> Google_Authentication 

  Email_Validation : register()
  Email_Validation : send_confirmation_email()
  Email_Validation : validate_email()

  Google_Authentication : login_with_google()
  Google_Authentication : validate_google_token()

  Email_Validation --> User_Registered 
  Google_Authentication --> User_Registered 
}

User_Registered --> Login

state Login {
  Login --> Credentials_Validation 
  Login --> Google_Authentication_Login 

  Credentials_Validation : validate_login()
  Credentials_Validation : validate_password()

  Google_Authentication_Login : login_via_google()

  Credentials_Validation --> User_LoggedIn 
  Google_Authentication_Login --> User_LoggedIn 
}

state User_LoggedIn {
  state Main_Menu {
    Main_Menu --> Task 
    Main_Menu --> Task_Group 
  }
  
  Main_Menu : view_tasks()
  Main_Menu : view_task_groups()
  Main_Menu : search_tasks(keyword)
  Main_Menu : filter_tasks_by_access(access_type)

  state Task {
    Task --> Create_Task
    Task --> View_Task
    Task --> Edit_Task
    Task --> Delete_Task
  }

  Task : create(title, description)
  Task : edit(task_id, new_title, new_description)
  Task : delete(task_id)
  Task : view(task_id)
  Task : set_access(task_id, access_type)
  Task : add_attachment(task_id, file)
  Task : download_attachment(task_id, file_id)
  Task : get_attachment_list(task_id)
  Task : view_history(task_id)
  Task : remove_attachment(task_id, file_id)

  Create_Task --> Set_Task_Access 
  Edit_Task --> Set_Task_Access 

  state Set_Task_Access {
    Set_Task_Access --> Public_Access
    Set_Task_Access --> Private_Access
    Set_Task_Access --> Paid_Access
  }

  Public_Access : access = public
  Private_Access : access = private
  Paid_Access : access = paid

  state Task_Group {
    Task_Group --> Create_Group
    Task_Group --> View_Group
    Task_Group --> Edit_Group
    Task_Group --> Delete_Group
  }

  Task_Group : create_group(name)
  Task_Group : add_task_to_group(task_id)
  Task_Group : remove_task_from_group(task_id)
  Task_Group : delete_group(group_id)
  Task_Group : rename_group(group_id, new_name)
  Task_Group : view_group(group_id)
}

User_LoggedIn --> [*]
@enduml
