One of the projects we delivered at LeanCode was building an application for Healthcare Industry - Quittercheck. Here you can check out the Case Study of the Quittercheck. This app uses modern media such as video - recorded by the user - to help them quit smoking. Users must record themselves while performing a nicotine test before the camera during a specific day and then upload it to the app. It's simple for the user, although this case hasn't been that simple from the backend perspective of the app. Why? The video needed to be uploaded on a specific day in the user's time zone and limited to that day while the Quittercheck's system serves several time zones. So the problem to solve was how to limit a video upload to a specific time frame.
By reading this article, you will find our tailored solution to limiting a video upload to a specific time frame.
As mentioned earlier, during the test day, the user must record themself performing a nicotine test shipped to them before starting their quitting plan. The test day is chosen randomly and is unknown to the user beforehand to prevent users from cheating. Moreover, the user cannot select the video of them taking a test from their video gallery to ensure the video was recorded on the expected day.
This feature is quite complex and requires considering some key problems the solution must take into account:
1. Different time zones
The feature requires the user to upload a test video on a given day, starting at 12:00 am and ending at 12:00 am on the next day. This may seem simple to achieve from the user's perspective, but for the system, it is not.
At first, the system needs to know in what timezone the user is. Midnight in London is not the same point in time as midnight in Beijing or New York.
Another issue is daylight saving time. Many countries use different times in summer than in winter. This results in two days in a year that doesn’t last twenty-four hours. We should consider how we want to handle those two days.
Since user plans take up to seven months of weekly testing, we need to be prepared that users may travel, and as a result, they may change their timezone. The system needs to somehow allow users to change their time zone for such cases on the one hand, but on another, it should not allow the change to affect the current test day so that users do not receive any extra time or accidentally shorten their time to perform a test.
2. Large file size
The testing process is time-consuming. It takes from 10 up to 20 minutes. In the case of videos that take that long, we need to consider the final file size, which will vary from a few hundred megabytes up to a couple of gigabytes. The exact file size isn’t easily predictable because it depends on the camera resolution and number of FPS, which may vary between devices.
That said, we need to be cautious about the empty space on the device before the user starts their test. In the case of older devices, users may not have enough free space to save a video. It is crucial to make sure that we will be able to save the video before starting a test since users need to perform the whole test as one recording (so that we are sure that nothing shady was done to the test kit).
3. The upload of a video
After the user performs the recording, they must upload their nicotine-test video to the server for verification. In the case of large files, this may take a couple of seconds up to a few minutes, depending on the user’s internet connection.
At the time of the upload, we shouldn’t block users from using their device since we already did so for the time of taking a test. Even though the feature we need to implement is quite complex, we should make it as simple and foolproof as possible for the end-users.
Another thing that we need to remember is that we should expect the internet connection to be unstable. Mobile devices use wi-fi or mobile internet connection, which may be lost, reconnected, or changed. In those cases, we should allow the upload to continue from where it was stopped.
4. Ensuring that the user did not corrupt the video
We must remember that we want to ensure that the user doesn’t cheat by tampering with a recorded video. At all times, we shouldn’t allow users to manipulate a recorded file, and we must prevent users from uploading a video that was not recorded by the app.
5. Video validation
After the test is performed and uploaded to the system, there needs to be an option for the administrators to verify that the test was performed correctly and no nicotine was detected during the test.
To complete the uploading of a nicotine-test video feature, we prepared a system that collects users' timezone, generates random test days, and sends push notifications on the day the test needs to be performed. Push notifications redirect the user directly to the mobile application, where the user can see the instructions of a test and start the recording.
The video is stored in the application data, which is unavailable to the user, so they cannot corrupt the video. After the recording user may rewatch the video and submit it to the verification. Then, the video is submitted in the background to the Azure Blob Storage, and the user is redirected to the application's home screen. The progress of the upload is displayed on the home screen, and in case of any problems with the upload, gets notified about that and can take action to resume the upload.
When a video is uploaded, it is ready for review by an administrator that checks if the test is passed or failed. After verification, the user is notified by a push notification about the result of the video review.
During the development of the system, we faced some unexpected issues. The first one was connectivity issues during file upload on Samsung devices using a wi-fi connection. These devices were causing socket exceptions during video upload. The solution to this problem was retrying the upload.
When interacting with the video file, we cannot load and process the whole video at once due to the device's RAM limitations. If your app needs to interact with large files, always remember to process them sequentially.
Another issue we faced was partially uploaded files. This can happen if the user starts the upload but loses the connection before the upload is finished. To solve this issue, we notify users by push notifications that they didn’t submit their test yet, and we prepared an option of retest that can be allowed by an administrator if they decide that the user deserves a second chance to upload a video.
This article describes the tailored approach to the challenge we faced while developing the Quittercheck app. We devised a solution that satisfied business requirements and mitigated technical limitations. It required refining the test process and flexible administration tools to satisfy clients when they experienced unexpected problems. We hope it can help you solve similar issues. If you need a team to build a complex application, reach out to LeanCode.
5.00 / 5 Based on 6 reviews