codeforamerica / hermes-be

Backend code for Hermes (including DB migrations, REST API, cron scripts, etc.)
3 stars 3 forks source link

Build Status

hermes-be

Backend code for Hermes (including DB migrations, REST API, cron scripts, etc.)

Development setup (on Mac OS X 10.8)

First-time setup

1) Download and install Node.js.

2) Download, install and start PostgreSQL server.

3) Clone this repository to a folder on your computer. The rest of this document will refer to this folder as $PROJECT_ROOT.

4) Install project dependencies.

cd $PROJECT_ROOT
npm install

5) Create the database user. When prompted, enter the password as defined in the config/default.js file.

createuser hermes -P

6) Create the database and make the just-created user its owner.

createdb hermes -O hermes

7) Create the database schema.

cd $PROJECT_ROOT
node bin/update_db_schema.js

Every time you sync $PROJECT_ROOT with the remote GitHub repo

1) Update the project dependencies.

cd $PROJECT_ROOT
npm install

2) Update the database schema.

cd $PROJECT_ROOT
node bin/update_db_schema.js

To start the REST API server

1) Start the REST API server.

cd $PROJECT_ROOT
TWILIO_ACCOUNT_SID=<Twilio Account SID> TWILIO_AUTH_TOKEN=<Twilio Auth Token> node restapi/server.js

To update court dates from CourtNet

1) Run the Court Date Updater script.

cd $PROJECT_ROOT
TWILIO_ACCOUNT_SID=<Twilio Account SID> TWILIO_AUTH_TOKEN=<Twilio Auth Token> node bin/court_date_updater.js

To send SMS reminders for tomorrow's court dates

1) Run the SMS Reminder script.

cd $PROJECT_ROOT
TWILIO_ACCOUNT_SID=<Twilio Account SID> TWILIO_AUTH_TOKEN=<Twilio Auth Token> node bin/sms_reminder.js

Project folder structure

$PROJECT_ROOT: Folder to which this repository was cloned.
bin: Folder containing executable programs used by cron jobs, for utility purposes, etc.
config: Folder containing configuration files for the application.
lib: Folder containing code shared by various parts of the application.
migrations: Folder containing database schema migrations.
models: Folder containing models that let the application communicate with the data store.
restapi: Folder containing code for the REST API server, resources and documentation.
spec: Folder containing unit tests.
templates: Folder containing template files used by the application to render SMS responses, etc.