Better name coming soon. 🤷🏻♀️
To run the development server, you must have Docker installed.
From the root of the repo, run:
docker-compose up
This will spin up Postgres, Webpack, and Django services.
You can access the application from your web browser at: http://localhost:8000/
You can connect to the PostgreSQL database at postgres://politweets:politweets@localhost:15432/politweets
To get data, you will need access to both the ProPublica Congress API and the Twitter API.
Once you have your credentials, you will need an .env
file in the root of the repository with them. This file is ignored by git to prevent you from publishing your secret keys. You can either create an .env
file with this format:
PROPUBLICA_API_KEY='XXXXXXXXXX'
PROPUBLICA_API_BASE='https://api.propublica.org/congress/v1/'
TWITTER_CONSUMER_KEY='XXXXXXXXXX'
TWITTER_CONSUMER_SECRET='XXXXXXXXXX'
TWITTER_ACCESS_TOKEN='XXXXXXXXXX'
TWITTER_ACCESS_TOKEN_SECRET='XXXXXXXXXX'
Or you can run this script to run through the automated setup wizard:
scripts/setup
You may need to restart docker-compose
after creating this file.
With the API credentials in place, run these commands to synchronize data:
# Sync members of congress to the database
docker-compose exec django pipenv run ./manage.py sync_members
# Sync new tweets to the database
docker-compose exec django pipenv run ./manage.py sync_tweets
To build production assets run:
cd client
npm install
npm run build
To force Django to use the production assets, create a file politweetalyzer/settings/local.py
:
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
WEBPACK_LOADER = {
'DEFAULT': {
'BUNDLE_DIR_NAME': '',
'STATS_FILE': os.path.join(BASE_DIR, 'client', 'dist', 'webpack-stats.build.json'),
}
}
Then run the Django server without the Webpack container:
docker-compose up django
We use Heroku's container-based deployment. To run deployment commands, you must have Heroku CLI installed and be logged in to Heroku's container registry. Then run:
scripts/deploy
This script will:
/client/dist