This project runs a webapp to allow fast sampling of US addresses within arbitrary (but usually CENSUS-based) geometries.
There are four parts of the stack:
- The PostGIS database
- A "work box" VM that has all the CLI tools for working with the DB
- The Python API
- The UI
The full stack can be run with:
docker compose up --build
The app will be served at http://localhost/
.
You will need to ingest some TIGER and OpenAddresses data to use it.
(See below!)
We use Postgres with the PostGIS extension for geospatial analysis.
In addition, we use the TIGER extension for PostGIS to provide geographic context.
You can run a database locally with docker-compose.
See the scripts in ./ctl/
for more info.
For development, it's useful to just run the ctl
and db
VMs in docker.
docker compose up db ctl --build
When you are setting up a new PostGIS database, you will need to ingest data from TIGER.
We provide a container in the docker-compose environment to make this easy.
# Get a shell in the controller container:
docker exec -it usps_ctl_1 /bin/bash
# Run TIGER ingestion script.
# Here I'm only pulling Vermont data; you can pass any state here, or `all`.
./init_tiger_data.sh VT
# Run OpenAddresses ingestion script.
# Again, only doing one small (but mighty) state for demoing.
./init_addr_data.sh VT
This will begin downloading and ingesting TIGER data into your database. Ingesting the entire country will take a long time to run (many hours, even days), so make sure you have a snack handy.
See the api/README.
See the app/README.
You can add a supplemental docker-compose.prod.yml
to expand the cluster for deployment.
Tips:
- Use a better nginx config (with SSL)
certbot/cerbot
can handle certificates- The
postgresql.conf
should be tuned for your hardware - The
services.db.shm_size
might need to be increased for large volumes of data - Use production-ready secrets as needed
- Configure the volumes in docker compose to be persistent on a disk (preferablly SSD for Postgres data!)