Behavior Change Framework (study human behaviors and deploy interventions in real-world settings using mobile devices)
A framework to study human behaviors and deploy behavioral interventions in real-world settings using mobile devices.
The framework relies on mobile sensing, digital nudges and user contexts (such as location traces, phone usage habit, and electronic calendar schedules).
OKEKE, F., SOBOLEV, M., ESTRIN, D. Towards A Framework for Mobile Behavior Change Research In Technology, Mind, and Society: APAScience, Washington DC, USA, April 2018.
https://doi.org/10.1145/3183654.3183706.
In its default state, the framework can be used to run research studies. Below is the application flow for conducting a study:
mkvirtualenv bhenv
(virtualenv wrapper creates and activates virtualenv / if you don’t have plugin, first create virtualenv then activate)pip install -r requirements.txt
.psycopg2
, open requirements.txt
and change psycopg2==2.6.1
to psycopg2
and rerun the install cmd.mv rep/fake_secret_keys.py rep/secret_keys.py
(rename fake_secret_keys to secret_keys. This file contains empty variables that will be populated later. See example with Google Oauth2.0 below.)python runserver.py
to start server on http://localhost:5000/
as dev modeNB: You need to setup Google Oauth2.0 for Google Login to work.
http://localhost:5000
and your domain as Authorized redirect URIs as local and prod urls respectively.secret_keys.py
as GOOGLE_CLIENT_ID
and GOOGLE_CLIENT_SECRET
variables respectivelypip install -r requirements.txt
.pip install psycopg2
.client_id
and client_secret
. CREATE USER repadmin WITH password 'password';
.ALTER USER repadmin WITH PASSWORD '<new password>' # password must be in quotes
.CREATE DATABASE repdb WITH OWNER repadmin;
.grant all privileges on database repdb to repadmin;
.ALTER DATABASE repdb OWNER to repadmin;
.psql -d repdb -U repadmin -W # -W prompts for a password
.You may need to configure postgres file: pg_hba.conf
if getting error:FATAL: Ident authentication failed for user
:
sudo su - postgres
or open config file in /var/lib/<pgsql_version>/data/
.host repdb repadmin all md5
.SELECT pg_reload_conf();
.
$ python manage.py db init
$ python manage.py db migrate
$ python manage.py db upgrade
$ python manage.py db --help
Celery is a task queue. Celery requires a solution to send and receive messages; usually this comes in the form of a separate service called a message broker.
There are several choices available, including: RabbitMQ, Redis, Amazon SQS etc. In this project we user Redis as the message broker.
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker.
You can follow these instructions if you plan to run periodic tasks. In this project, Celery is used for running cron jobs that dump results in the postresql database.
redis-server
.Postgres
application.db.create_all() # you can do this by importing db from models
.db.session.commit()
. You can use Postico as a gui for your DB.run celery verbose: celery -A tasks.celery worker --loglevel=info --beat
.python runserver.py
.pip install gunicorn supervisor
.echo_supervisord_conf > supervisord.conf
.supervisord -c supervisord.conf
../run_gunicorn.sh
starts server with multiple workers.To create android apps that build on ResearchStack, follow this guide.
To maintain and preserve user privacy, this project will eventually access third party datastreams using Immersive Core.