Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Technical documentation

David Vavra edited this page Apr 11, 2020 · 6 revisions

This is the main documentation for eRouška project.

Terminology

FUID

Firebase User ID, unique for each phone number, generated by Firebase Authentication after sign-in, 28 chars or more.

BUID

Broadcasted user ID, unique for each registration, generated by Firebase function after registration, 10 bytes

TUID

Transmitted user ID, actually transmitted over Bluetooth, each BUID gets about 100 TUIDs after registration, client picks a different one every hour or so, privacy measure to prevent tracking individual device/user, 10 bytes

Data format

Firebase Firestore

Firestore is not readable or writable to user, only Functions.

Collection users

  • Key: FUID

Attributes:

  • phoneNumber (international format)
  • createdAt (timestamp of creation)
  • registrationCount (number of BUIDs)

Collection registrations

  • Key: BUID

Attributes

  • fuid
  • platform (android/ ios)
  • platformVersion (system version, e.g. 10.0.4)
  • manufacturer (phone manufacturer, e.g. Samsung)
  • model (phone model, e.g. Galaxy S7)
  • locale (phone language, e.g. cs_CZ)
  • createdAt (timestamp of creation)
  • pushRegistrationToken (push token from Firebase Cloud Messaging)

Collection tuids

  • Key: TUID

Attributes

  • fuid
  • buid
  • createdAt (timestamp of creation)

Firebase Storage

User can only upload data about his FUID, can't read other data.

Collection proximity

  • Key: FUID/BUID
  • Filename: $timestamp.csv

Metadata

  • version (version of CSV model, current 4)

CSV columns

  • tuid
  • timestampStart (millis)
  • timestampEnd (millis)
  • avgRssi (average signal strength)
  • medRssi (median signal strength)

Firebase Functions

Main API for the app and other parts of the system, scales automatically, region: europe-west3

Input and output are dictionaries. Functions doesn't return anything, unless specified here (but can throw error).

registerBuid

Creates a new registration after authentication.

Input

  • platform: string (android/ ios)
  • platformVersion: string (system version, e.g. 10.0.4)
  • manufacturer: string (phone manufacturer, e.g. Samsung)
  • model: string (phone model, e.g. Galaxy S7)
  • locale: string (phone language, e.g. cs_CZ)
  • pushRegistrationToken: string (push token from Firebase Cloud Messaging)

Output

  • buid: string (created BUID)
  • tuids: string[] (list of TUIDs)

deleteUploads

Deletes all CSVs for one BUID.

Input

  • buid: string

deleteBuid

Deletes all data related to BUID.

Input

  • buid: string

deleteUser

Deletes all data related to FUID, including phone number in Firebase Authentication.

changePushToken

Changes push token for BUID.

Input

  • buid: string
  • pushRegistrationToken: string

isBuidActive

Checks if FUID and BUID still exists

Input:

  • buid: string Output:
  • boolean (active/inactive)

Firebase Remote Config

Contains constants which we can changed later without updating the app.

Default values

Clone this wiki locally