Drive the Vote helps people arrange free rides to the polls on election day. It consists of:
Here's what the Philadelphia dispatch and driver apps looked like on election morning 2016:
git clone git@github.com:john/drive.vote.git
cd drive.vote
Certain features require you to add a .env file to the root app directory containing these values:
SECRET_KEY_BASE=wwww
TWILIO_SID=xxxx
TWILIO_TOKEN=yyyy
GOOGLE_API_KEY=zzzz
You can generate the value for SECRET_KEY_BASE by running bundle exec rake secret
.
The Twilio values are used for sms interactions with voters and can be obtained from your Twilio account, which you'll also use to create a Twilio number with sms capabilities, and update the ride zone you want to work with to use it. Using Twilio numbers during local dev requires setting up ngrok.
GOOGLE_API_KEY is used for geolocation, and can be created in the Google API console. Enable all geo APIs for the key.
docker-compose up
. This will start three containers: one for postgres, one for redis and one that runs rails + the webpack dev server.docker-compose exec web bundle exec rails db:create db:schema:load db:seed
to setup the database.docker-compose stop
Your current directory will be mounted into the docker instances so changes to the files should go live immediately without restarting the environment. If you need to restart the rails server, just run docker-compose up
again.
To get a bash shell on the current docker instance, run:
docker-compose exec web bash -l
To get a Rails console on the current docker instance, run:
docker-compose exec web bundle exec rails console
redis-server /usr/local/etc/redis.conf
)gem install bundler
bundle install
rake pg:first_run
on the first run, and rake pg:start
for subsequent runs to start the DBrake db:create; rake db:migrate; rake db:seed
.bundle exec rake foreman:dev
to start the server in dev mode. You can check Procfile.dev to see the servers this starts.For production, instead of foreman:dev
, run
rake assets:precompile
rake foreman:prod
If you don't want to use foreman, you have to run the rails server (Puma) and the webpack server in separate terminals: bundle exec rails server
and bundle exec ./bin/webpack-dev-server
, respectively.
bundle exec rake spec
executes all tests in the spec directory. Run locally before committing, the app won't deploy if specs don't pass.
If adding or modifying tests that will make new calls to the Google Maps APIs, you'll need to run with a valid GOOGLE_API_KEY
, both to get your tests to pass, and also to refill the cached test data for use in later runs (including CI). See the discussion in spec/rails_helpers.rb
for instructions on how to run with a live API Key.
A process needs to run every minute or so to check scheduled rides, and promote ones that are approaching their pickup time from 'scheduled' to 'waiting assignment,' so that they become available to drivers. That process needs to POST to this url, which will promote imminent rides: /api/1/rides/confirm_scheduled
.
The preferred production setup is to run a dedicated worker instance, but any instance acting as a worker (dedicated or not), needs to have the DTV_IS_WORKER env var set to TRUE.
The call to confirm_scheduled can be made via cron or using the scheduled AWS Lambda available in this repo.
In practice it turns out scheduled rides seem to be the primary use case. The app also supports on-demand rides via SMS. In that case information is gathered by a basic text bot, information about which can be found in converation_bot.md
Go to http://localhost:3000 and log in as the generic admin with email seeds@drive.vote
and password 1234abcd
. Since this account has admin privileges, logging in with it takes you directly to the admin site. If it has only driver privileges, it would take you to the driver app, and if only dispatcher privileges, to the dispatch page for the ride zone attached to your account. If for some reason your account has no privileges at all, you'll end up at the homepage, but that shouldn't happen. Note the accounts in seeds.rb don't exist in production, so don't get cute.
Useful URLs:
https://www.labnol.org/internet/geo-location/27878/ ?
For features that send emails, run MailHog or MailCatcher locally. The development environment is configured to send email to the correct port. On macOS you can use brew to install and run Mailhog:
brew update && brew install mailhog
brew services start mailhog
Once started you can view the Mailhog client at http://localhost:8025/
git checkout -b my-new-feature
bundle exec rake
git commit -am 'Add some feature'
git push origin my-new-feature
This software is released under the MIT License. See the LICENSE.md file for more information.