```mermaid
sequenceDiagram
autonumber
participant mb as Mobile Client
participant hasura as Harura
participant storage as Google Storage Bucket
participant image_resizer as Image Resizer
participant saveImageInfoFn as SaveImageInfo Firebase Function
participant lst as Local Storage
link hasura: GetSession query @ https://wiki.nodeart.app/display/LIV/User+profile#Userprofile-Userlogingraphqlmutation
link mb: SetAvatar mutation @ https://wiki.nodeart.app/display/LIV/User+Gallery#UserGallery-SetAvatargqlrequest
link mb: GetPhotoUploadUrl @ https://wiki.nodeart.app/display/LIV/User+Gallery#UserGallery-Uploadingimages
Note over mb: get desired image size for device
activate mb
mb ->> hasura: call GetSessionByClientToken query
hasura ->> mb: reply with desired device image size
mb ->> lst: store the device image size in local storage
mb ->> hasura: call GetPhotoUploadUrl query
hasura ->> mb: returns the signed url to upload the image
Note right of mb: prepare the image for uploading (set mime type, etc)
activate mb
mb ->> storage: upload the image to cloud storage
deactivate mb
activate image_resizer
loop Image processing loop
image_resizer ->> storage: Resize image accroding to image resizer settings for a while
storage ->> saveImageInfoFn: storage object added event trigger SaveImageInfo Firebase Function
saveImageInfoFn ->> hasura: adds image url to hasura database
end
loop Fetch images loop
activate mb
Note left of hasura: "call GetImagesByFileName query in order to fetch new resized images by Image Resizer"
Note left of hasura: get image from local storage and use in the next query to hasura
mb ->> hasura: call GetImagesByFileName gql query
hasura ->> mb: reply with new image records with desired image size and filenames
end
mb ->> hasura: call SetAvatar mutation
hasura ->> mb: profile avatar is set
```