Simple Weather Notifications via Text (SMS) - weatherwarner.herokuapp.com
- Weather Warner sends a short weather update via SMS. Updates are sent each morning based on the current day's forecast data.
- Recipients can subscribe to texts at weatherwarner.herokuapp.com after verifying their number.
- Current recipients can be managed via the admin page.
- Docker Compose
- Docker
Note: For Mac users, I recommend Docker Desktop for Mac, as it includes both.
- Run
./dev_setup.sh
to install the dockerised application. This will install everything required and import fixtures.
- Start Docker Compose
- Configure the Twilio Variables (
TWILIO_*
inbase.py
) with production credentials - Configure the Weather Bit
API_KEY
with a production key - In the base directory, run
./shortcuts.sh send_weather_report
to fire off the texts!
The application backend is built with an python web framework called Django backed by a PostgreSQL database. Django's ORM is powerful, so we're going to make the most of that!
Two third party APIs are used; Weatherbit for retrieving weather data and Twilio Programmable SMS to send and receive texts.
The application frontend is a React/Typescript node app using React Hooks & Axios. A static webpack build is generated during deployment and served to the backend via django-webpack-loader.
The application is contained within Docker using Docker Compose.
Circle CI is used for continuous integration to run linting & tests.
When CI passes, the application is automatically deployed to heroku using multiple buildpacks.
The webserver and webpack are required to run locally. Use the following commands:
dc up -d django
yarn run start
- Run
./shortcuts.sh test
to start pytests.
Note: You can debug tests by inserting a breakpoint (see Debugging) and running:
./shortcuts.sh test --capture=no --pdb --pdbcls=IPython.terminal.debugger:Pdb--capture=no --pdb --pdbcls=IPython.terminal.debugger:Pdb
- Run
yarn run test
from thefrontend/
root directory to run the frontend test suite.
This code uses pre-commit to enforce coding style locally. Ensure you have Python 3.7 if you'd like to run linting.
Run ./shortcuts.sh lint
to lint changed files.
./shorcuts.sh
can be run for a variety of custom commands.
Available subcommands:
logs: Follow the logs for the django container
shell: Open a shell_plus session
bash: Start a bash session in the app container
test: Run one or more tests
lint: Run isort, flake8 and black on changed files
Insert a breakpoint in the application like so:
foo = "bar"
import ipdb ; ipdb.set_trace() <=== break point
print(foo)