Skip to content

alexandrumeterez/covidtracer

Repository files navigation

CovidTracer

Screenshots

All screens

How it works

After you sign in, you get an OTP token generated using Firebase Phone Auth (currently the phone number is hardcoded for Romanian prefixes, but this is easily changeable). After you login, the application starts a background service that constantly publishes and receives the Firestore Database UIDs, by using the Nearby Messages API from Google. When two devices are in close proximity (approximately 4-5m for Bluetooth + Sonar, didn't test max distance since I can't go any further than my own home due to social distancing), their meetup is registered in Firestore. From the picker in the logged in screen, you can choose your current health status and press the button. This updates your health status in the database. Using Firestore Cloud Messages, there is a JavaScript function that triggers when this update happens and sends a push notification to the users that you have interacted with.

Backend

Create or update your local gradle.properties file with:
The API_KEY for the Nearby Messages API (API_KEY=apikeyexample)
The MAPS_API_KEY for the Google Maps SDK for Android (MAPS_API_KEY=mapsapikeyexample).

Components

  • Nearby Messages API (contact tracing)
  • Firestore (database)
  • Firebase Functions (serverless code)
  • Firebase Authentication (authenticate requests)

JSON schema for Firebase

2 tabels:

  • users

    "users": {
        "user_id1" : {
            "phone" :
        }
        "user_id2" : {
            "phone" :
        }
    }
    
  • users meetings

    "users_meetings" : {
        "user_id1" : {
            "meetings" : {
                "user_id_met1" : {
                    "found_timestamp" : ...
                    "lost_timestamp" : ...
                    "status" : ...
                }
                "user_id_met2" : {
                    "found_timestamp" : ...
                    "lost_timestamp" : ...
                    "status" : ...
                }
            }
        }
        "user_id2" : {
            "meetings" : {
                "user_id_met1" : {
                    "found_timestamp" : ...
                    "lost_timestamp" : ...
                    "status" : ...
                }
                "user_id_met2" : {
                    "found_timestamp" : ...
                    "lost_timestamp" : ...
                    "status" : ...
                }
            }
        }
    }
    

Credits