DreamScore: What are your COVID-19 dreams trying to tell you?
Tags: twiliohackathon, react, beginners, rails
Published: 2020-04-30 15:30:48

## What I built
DreamScore is your personal dream journal that allows you to track your mood by recording your daily dreams. 
#### Category Submission: Interesting Integrations

The application reminds you via SMS to write down your dream each morning and then feeds what you wrote into Google’s Natural Language API, which uses machine learning to determine the emotional attitude of a text. Your entry is given a score (-1 as negative and +1 as positive) which shows your mood. 

Over the last few weeks, COVID dreams (and nightmares) have been a common topic of conversation as many people have started sharing their dreams on social media and in the press—and how dreaming has grown in frequency and vividness. Whether because of increased stress and anxiety, a response to a lack of stimuli during social isolation, or a just that people are sleeping more hours than normal, COVID-19 dreams can help give us clues into the state of our subconscious.

## Demo Link
http://www.mydreamscores.co

Youtube demo: https://www.youtube.com/watch?feature=player_embedded&v=trBBewI8dcg

## Link to Code
Frontend Repo: https://github.com/annacarey/mydreamscores-frontend
Backend Repo: https://github.com/annacarey/mydreamscores-backend


## How I built it 
This application was built in React (frontend) and Ruby on Rails (backend) and uses Google's Natural Language Processing API and Geocoding API. The application uses the Twilio API to send SMS reminders via chron jobs / Heroku Scheduler. (I am a brand new developer and this is my first project!)

Authenticating the APIs, restricting API keys to certain referrers, and safely securing the private information when deploying to Github and Heroku were some of the most challenging aspects of this project. For example, Google provides authentication secrets in a file and then requests that they be referenced in the application as a file path instead of individual environment variables. Heroku uses secrets in environment variables, so I had to find a workaround when deploying. Also, in order to stay within the free tiers of these APIs, I had to optimize my code to make as few API calls as few as possible. Twilio was a little bit easier to work with, but I had some trouble switching from chron jobs in Rails from my development environment to Heroku Scheduler when I hosted the application.

## Additional Resources

#### Resources about Dreams and COVID:
* [CNBC] (https://www.cnbc.com/2020/04/03/why-youre-having-pandemic-related-nightmares-and-how-to-sleep-better.html)
* [Vox] (https://www.vox.com/the-goods/2020/4/9/21215312/quarantine-vivid-dreams-psychologist-q-and-a)
* [Smithsonian Magazine] (https://www.smithsonianmag.com/smart-news/insomnia-and-vivid-dreams-rise-pandemic-anxiety-180974726/)
* [Psychology Today] (https://www.psychologytoday.com/us/blog/dreaming-in-the-digital-age/201705/keeping-dream-journal)

#### Resources about Dream Journaling:
* [Psychology Today] (https://www.psychologytoday.com/us/blog/dreaming-in-the-digital-age/201705/keeping-dream-journal)
* [Thrive Global] (https://thriveglobal.com/stories/5-reasons-why-you-should-keep-a-dream-journal/)
* [Masterclass] (https://www.masterclass.com/articles/how-to-keep-a-dream-journal#how-to-keep-a-dream-journal)

## Features

1. Sign up by entering your zipcode first or login. (Zipcode is fed into Google's geocoding API to get your region.)

![Homepage Screenshot](https://github.com/annacarey/mydreamscores-frontend/raw/master/public/images/screenshots/Home.png "Homepage")

2. Share the details of your dream in a digital journal.

![Journal](https://github.com/annacarey/mydreamscores-frontend/raw/master/public/images/screenshots/Journal.png "Journal") 

3. When you press save, the text is fed into Google's Natural Language Processing API to get the "mood score." The signup page is found here (unless you are already logged in.)

![Mood View](https://github.com/annacarey/mydreamscores-frontend/raw/master/public/images/screenshots/Mood.png "Mood View")

4. Once you have signed up or logged in, you will see the dashboard with your most recent mood score, weekly and all-time averages as well as averages globally and by your region.

![Dashboard](https://github.com/annacarey/mydreamscores-frontend/raw/master/public/images/screenshots/Dashboard.png "Dashboard")

5. You can access your full history and see all past dream journal entries.

![History](https://github.com/annacarey/mydreamscores-frontend/raw/master/public/images/screenshots/History.png "History")