Muhammad Talha Paracha bio photo

Muhammad Talha Paracha

Passionate programmer, Tech geek & Design enthusiast.

Email Facebook

Project completion date: September 2015

Total work duration: Weekend in a Hackathon

Language(s) used: Java, PHP, MySQL

Other team members: Asad, Maimoona

My responsibilities: Handling backend data storage and server processing + providing frontend website interface for accessing some stored data.

After winning SEECS Social Hackathon, we set our eyes towards Pakistan Innovation Foundation’s Women Transport Innovation Hackathon. This time the competition was much difficult; teams from all over the country participated and solutions from other categories like business proposals etc. were also accepted. The hackathon was sponsored by UN Women chapter of United Nations along with Toyota. As such the event got major attention on the internet. Well we built SOS based Android app and… won first prize this time too =D More project details given below

The Idea:

After much fighting among ourselves on whether to make another Uber like solution or to go for something simple yet new, we decided to go with the latter. Accordingly we built a tracking app for women’s safety on roads which provided two major features:

1) Number-plate Photosharing: Before entering in a cab, a women through our app can simply take a snapshot of its numberplate and the cab’s ID would be stored in our server along with the GPS info for later retrieval in case of any emergency. Explicitly taking the snapshot of the number-plate serves additional advantage that the cab driver would now be more careful with his attitude since he knows he can be easily held accountable.

2) SOS Tracker: If a women feels unsecure while travelling she can simply start our tracker with the push of button. As soon as the tracking service is enabled, we get the current GPS info of the user and save it on our server. Then after every 5 minutes we ping the user asking her if she’s ok or not. If she’s ok, she can simply notify us by responding to the ping. The GPS info at that point and time gets stored. After 5 minutes we ping the user again and our server continues doing so until the user turns our tracker off. Now in case of some accident if the user doesn’t respond to our ping, we send SMS to their emergency contacts asking them to personally call and check for the safety of the user. And if some catastrophe has happened, all tracking info, with 5 minute intervals, before the user stopped responding would be available on server for immediate access.

But the best part was: our app worked totally offline. As 3G access is very expensive here in our country and no one uses it while travelling, we decided the best model for our app to excel would be with the mobile network. For the SOS feature to work offline, all we needed was an Android smartphone constantly connected with our server. Then the app on user’s smartphone communicated with this smartphone which in turn communicated with our server. And for the Number-plate sharing feature to work offline, we processed each snapshot with Tesseract, extracted the actual cab ID from it and then sent that number to our server via SMS. And as far as GPS is concerned, many people don’t know but GPS in essence does not require any internet connection. But without internet it works well only if the user is outside. As our users would be using the app during travelling, this wasn’t a problem either.

The App:

1) First time users register themselves by specifying a security PIN and choosing their emergency contacts who would be notified in case of any emergency and who would be able to access all their tracking info from the website.

registration

2) Select which feature to use from our app.

features

3) For Number-plate photo sharing simply take a snapshot of cab’s ID and that’s it.

camera

4) For SOS tracking, enable it and relax. We’ll ping you after every 5 minutes and make sure your emergency contacts get informed if you are not responding to us. Here are sample pings:

notifications

5) All the tracking information stored for any user could be access through the website by the user herself or her emergency contacts if they have the PIN specified in first step.

website

The Code:

We initially thought it won’t be possible for us to complete the project in time. To our surprise, in just 24 hours we were able to implement all functionality we promised in the pitch. I started by figuring out a database schema for the project. Most lines of code I wrote were canned database insertion / retrieval transactions which formed an API which the app accessed. But the critical part of my work was the server logic for tacking users who had enabled SOS tracker at any time, pinging them after regular intervals, checking whether they are responding to the pings or not, and sending text messages to their emergency contacts based on that information. Asad suggested me setting Cron jobs for this but I was confident and more interested in making my own quick solution work too. Here is the code I wrote. And yes, I tested it much and it worked absolutely as expected.

(Note that the database provided a separate table listing all those users who had enabled SOS tracker at that particular time. This script got called only once whenever first entry was inserted in that table)