I am writing a small application that utilises AWS serverless architexture and a React native Expo front end.
The question is slightly abstract in nature as i dont require a specific answer but more a nudge in the right direction on implementation and architecture.
I have architected the application to send an image to AWS S3 via API GW (authorised via cognito), when the image lands in s3 a backend process is triggered spinning up AWS textract and once successful SNS topic updates a second lambda to process the text in the image landing the final result in a second bucket - all this is fine and i can manually hit the bucket through Postman and everything works happily!
The question comes when integrating the front-end, in the React native app, i snap a picture and on save i can call the API GW endpoint to upload the image (all fine again), its just that im unsure how to query/ get the notification of the success of textract. and then navigate the user to the viewText screen.
I have a couple of ideas but they feel flakey at best:
- Use an intermediate screen to grab some more info about the image uploaded, the time the user takes to upload info would (hopefully) allow the backend processes to complete and then submitting that extra info to the api could return the success response with image text.
- Have the app listen out for SNS success which could undisable a btn in the UI to view text on the next screen
- On image submit have a loading screen display for an arbitary amount of time (~2/3seconds) and then navigate to the text screen, and use the
useEffecthook to call api gw looking for the successful recognised text - could delay further withsetTimeout()if this is not long enough? Also on navigate show some sort of skeleton component as if loading data.
Thanks in advance for any advice.