@startuml uc12
title "Use Case #12: Lookup User"

'Styling goes here
hide footbox
skinparam stereotypePosition bottom
skinparam sequenceMessageAlign direction
skinparam sequence {
	LifeLineBorderColor #Silver
	LifeLineBackgroundColor #Gainsboro
}

'Add a legend plus styling
skinparam legend {
	backgroundColor #GhostWhite
	entrySeparator #GhostWhite
}

legend top
	<#GhostWhite,#GhostWhite>|	|= __Legend__ |
	|<#red> | Clientside|
	|<#silver> | Serverside|
endlegend

'Setup the objects involved here
actor User as u <<Actor>> #red
boundary App as a <<Boundary>> #red
boundary LookupUserScreen as lus <<Boundary>> #red
control LookupUsersRoute as lur <<Control>> #silver
control DatabaseManager as dbm <<Control>> #silver

'Setup persistent objects here
activate u
activate a
activate lur
activate dbm

'--- FLOW OF CONTROL STARTS HERE ---
'User sends UUID or username to server.
u -> a: opens screen to lookup a user
a -> lus: show()
activate lus
lus -> u: prompt for username or UUID
u -> lus: provides valid username or\n UUID; Clicks "Submit" button

'Server responds with user’s public key, username, and UUID.
lus -> lur: POST /api/users/lookup json::{query}
lur -> dbm: QUERY(UUID|username)

group record exists

	dbm --> lur: return: user info
	lur --> lus: RESP json::{success, user_info}
	lus -> u: shows user info for request

end
group no record found

	dbm --> lur: return: error_no_record_found
	lur --> lus: RESP json::{error, no_record_found}
	lus -> u: shows error stating \nuser info wasn't found

end

'Cleanup
u -> lus: clicks "Ok"
deactivate lus
'--- FLOW OF CONTROL ENDS HERE   ---

@enduml
