Skip to content

Help improve your sleep quality - Jisc IoT Hackathon

Notifications You must be signed in to change notification settings

DMeechan/sleepyhead

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sleepyhead

We built Sleepyhead to help improve your sleep quality.

Sleepyhead measures how your bedroom affects your sleep (via light, noise, air quality, and temperature) and gives suggestions on how you can change your environment to get better sleep

Our team of 4 created Sleepyhead in 12 hours for Jisc IoT Hackathon in Glasgow and won.

What does it look like?

Here's some screenshots from the web app:

Light quality on Friday: light

This Week: week

Tuesday summary: tuesday

Login: login

Getting Started

This project is split into two sections:

  • server - a server which stores and serves data through a RESTful API
  • web - a web app which fetches sleep data from the API server then displays it in a beautiful interface with graphs and sleep suggestions

Here's how to get a copy of the project up and running on your local machine for development and testing purposes.

See deployment for notes on how to deploy the project on a live system.

Prerequisites

What things you need to install the software and how to install them

  • Install Git

  • Install Node.js (Node 12 LTS is recommended)

  • Have a Postgres database running locally or in the cloud (you'll need the credentials for it)

  • Prerequisites for embedded devices... (TODO)

Installing

First off, download this repository to your machine by running this command in a Terminal window:

git clone https://github.com/DMeechan/Sleepyhead.git

Then enter the repository:

cd Sleepyhead

Running the backend server

Open the server folder:

cd server

Create a .env file:

cp .env.example .env

Open up the .env file and edit the database URL to point to your own Postgres database

Next, install depencencies:

npm install

Start a local development server:

npm run dev

Now visit http://localhost:3000 to check that your API server works!

Running the web frontend

In a new Terminal window (to keep your local backend running), open up the repository folder and then enter the web folder:

cd web

Install depencencies:

npm install

Start a local development server:

npm run start

Running the embedded device

TODO

Deployment

We recommend deploying the backend to any cloud provider which supports Node.js applications and Postgres (like Render or Heroku).

And we recommend deploying the frontend to a cloud provider which supports static sites (like Render or Netlify).

Deploying the backend server

Set up a Postgres database and then set up a Node.js application with the following settings:

Build command:

cd server && npm i

Start command:

cd server && npm start

Health check path (used by Render):

/health

Don't forget to set the DATABASE_URL environment variable to point to your database in the cloud.

Deploying the frontend

You can deploy the React web app as a static site for free with providers like Netlify and Render. To do so, use these settings:

Build command:

cd web && npm i && npm run build

Start command:

./web/build

Built With

  • Node.js - Used to run the backend API server
  • TypeScript - Used to write the backend server
  • React.js - Used to build the web app
  • PostgreSQL - The database used by the backend server to store data

Authors

About

Help improve your sleep quality - Jisc IoT Hackathon

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •