Implementing the GPSTest Database: A Serverless Architecture

Requirements

Allowing users to contribute their Android device GNSS features to a central database obviously required some software infrastructure beyond the Android app itself — a first for any feature in GPSTest.

Traditional architecture for sending information from a mobile device to a database server
  • Don’t require a stand-alone web server
  • Don’t require a stand-alone database server
  • Write as little server code as possible — including no custom web application to view the data
  • Write server code in a standard programming language (vs. custom scripts for proprietary environments)

Implementation

Here’s an overview of the architecture I decided to use for the GPSTest Database:

GPSTest sends the device info to a Google App Script, which stores it in a Google Sheet
Google App Script code in the doGet() method receives data from the mobile app and stores it in the Google Sheet
Google Sheets serves as a user-interface to the GPSTest Database for Sort, Find, and more operations

Avoiding duplicate uploads

First, a client-side optimization to prevent duplicate records — after successfully sending the data, the GPSTest app stores a hash of the data. When you tap “Upload” again, it will only submit new information if something changed (i.e., the hash is different) and will tell the user if nothing has changed. This cuts down on duplicate submissions that need to be cleaned up (see below), and also makes it easier for you to track if something changed on your device.

Adding device name

Strangely, Android doesn’t include an API for retrieving the device name — it only offers the device manufacturer and model, like “Samsung SM-G955U”. But that’s not very human-readable. So where does the Name column in the database come from?

Removing (near) duplicate submissions

There are obviously a lot of devices out there running GPSTest that are the same make and model. When crowdsourcing data, how do we deal with a large number of submissions that may be identical, or close to identical?

  • Manufacturer
  • Model
  • GNSS hardware year
  • GNSS hardware model name

Closing thoughts

This particular implementation met my goals, but it certainly isn’t the only way to architect this type of system. Do you have suggestions for improvements, or alternate ideas of how to approach it? Let me know in the comments below!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sean Barbeau

Sean Barbeau

Improving the world, one byte at a time. @sjbarbeau, https://github.com/barbeau, https://www.linkedin.com/in/seanbarbeau/. I work @CUTRUSF. Posts are my own.