Skip to content

1. Model and Engine

Ibrahim Kosgi edited this page Apr 19, 2022 · 21 revisions

Story Map

Story Map

Engine Architecture

Engine Architecture

Views

There are two main views: the 2D map view that is more akin to a standard map UI and the AR view in which nearby posts will be visible as if they were a part of the real world.

The 2D map view will be generated using Mapbox SDK for Android by providing it the GPS location of the device along with the locations of the nearest pins. The user's location is needed so the map view can zoom in to the right area of the world while the nearest pin locations are need to appear as pins on the map UI.

The AR view is facilitated by Google’s ARCore, which takes ImageViews created by pulling images from the backend based on the user’s location and displays them in AR space. Whenever the user moves a given distance away from their original location, the AR view automatically repeats the call to the backend and updates the displayed images at the new location. Finally, the AR view sets an OnTapListener that listens for when the user taps on a photo in AR and sends it to the 2D comment view from our main view if the user taps on the photo.

Pins Service

This service can primarily be split into two categories: posting pins and getting pins.

Posting pins requires the user ID and the image but also the location as latitude and longitude.

The main difficulty in getting pins is in determining which pins are nearby. The posts being indexed by city helps to heavily reduce the amount of posts that this service needs to look through to determine the distance to the user. The distance to the user is calculated using the GeoPy API. Once a set of nearby posts are determined, they are returned for the Mapbox view or the ARCore-Location view to show in the frontend.

Friend Service

This service is simply to deal with friends and friend requests. It allows users to view a list of their friends as well as incoming and outgoing friend requests. As a natural complement of this, it also allows users to send friend requests to other users and accept or reject incoming friend requests.

Firestore

Firestore will be where we store all of our server-side data. It is a NoSQL document oriented database that organizes data using collections and documents. We have two main collections: pins and users. Within each user document, we have three possible collections: friends, incoming_requests, and outgoing_requests. Within each pin document, there is one possible collection: comments. Full details follow below:

users: {
    [docid]: {
        friends: {
            [docid]: {
                username: string
            }
        },
        Incoming_requests: {
            [docid]: {
                username: string
            }
        },
        Outgoing_requests: {
            [docid]: {
                username: string
            }
        },
        Username: string,
        Password: string (hashed)
        Token: string
    }
},
pins: {
    [docid]: {
        comments: {
            owner_id: string,
            text: string,
            timestamp: Firestore timestamp
        },
        is_public: boolean,
        location: array (length of 2: latitude and longitude),
        media_url: string,
        owner_id: string,
        pin_id: string,
        timestamp: Firestore timestamp
    }
}

Clone this wiki locally