/tag-it-stdlib

Server component for NWHacks 2018 project. Client App: https://github.com/jopika/tag-it

Primary LanguageJavaScript

μzm backend

(mu-zee-em)

devpost - nwhacks 2018

Let's face it: Museums, parks, and exhibits need some work in this digital era. Why lean over to read a small plaque when you can get a summary and details by tagging exhibits with a portable device? There is a solution for this of course: NFC tags are a fun modern technology, and they could be used to help people appreciate both modern and historic masterpieces. If you're a nwHacks attendee, there's one on your badge right now!

Backend overview

stdlib handles API calls from the Android client application. Node.js is used to pull information from a MongoDB database and send it back to the user. Slack is used to present a real-time feed of user interactions with tags.

Files

Each module in the functions folder represents an API route on stdlib. Tags are represented as a string of random characters, which are stored in mongoDB when the user first registers.

The scripts folder contains scripts that are run locally. The setup_db script loads data from the exhibit.json file into the exhibit collection in the database.

Routes

__main__

Alias for tagged

add_exhibits

Insert an exhibit into the database. We ended up not using this for the hackathon, instead using scripts/setup_db to directly insert items into the database.

create_user

Insert or overwrite a user in the database. Their NFC tag data, tag, must be provided along with a display name like "Bill".

debug

A dirty hack route we used to print out the entire database. If the wipe argument is provided, the corresponding collection will have its contents wiped.

get_bulk_info

Retrive info about some exhibits, based on the array of ids you pass. IDs correspond to the exhibit's key property in the database. Returns a map of keys to exhibit objects.

get_info

Like get_bulk_info, but for a single exhibit. Returns the exhibit directy rather than inside a map.

get_inventory

Returns an array of strings, where each string is the display name of an item in the user's inventory. Pass the user's tag in the user_id parameter.

log_transaction

Adds a interaction between the user (receiver) and some tag (target). Also takes in the exhibit object the user tapped and the collectible they received from the exhibit. Optionally the current time can be passed (date) as milliseconds since epoch time, but will default to the current time.

This route also calls our Slack bot to add to the real-time feed.

tagged

Called when the user (userTag) taps an exhibit (targetTag), and transfers a random collectible from the corresponding exhibit to the user.