An app to search for properties on Zoopla and filter on the properties total area. The area is scraped off the floorplan image using OCR.
This project consists of a frontend (web) application written in Flutter, and a backend service written in Python. The backend requires access to a postgres database.
The simplest way to deploy it locally is to use docker:
- From the project root directory:
- Create a Google Maps API key if you don't have one.
- Create a Google Sign-in Client ID if you don't have one.
- Create a Zoopla API key if you don't have one.
- Set environment variables for API keys:
export GOOGLEMAPSAPIKEY=<your google maps API key> export ZOOPLAAPIKEY=<your Zoopla API key> export POSTGRES_PASSWORD=<make up a password for the DB user 'admin'> export SECRET_KEY=`openssl rand -hex 32` export CLIENT_ID=<OAuth2.0 client ID, in GCP API & Services -> Credentials> export URL_API=localhost # or http:/127.0.0.1
SECRET_KEYis used for auth and should be a random 32 digit hex value. Theopensslcommand above is a simple way to generate this, but you can use whatever key you like.- If you want to connect to an existing database, instead of
POSTGRES_PASSWORD, set an environment variable calledDATABASE_URLwith the full connection string. This is the environment variable name used by Heroku.
- Build and run:
note if you have set
docker compose up
URL_APIto your remote server, then for local testing run:URL_API=http://localhost docker compose up
- Test the backend:
This can take around 10s but should return
curl localhost:80/pdf/acf057f7f02b0cf3552e149de5772640bf0bfd2c.pdf
{"area":442.6} - The front end should be available at:
localhost:5001 - The OpenAPI docs foe the backend are available at:
localhost/docs
If you need to force a rebuild of the containers, try:
docker-compose build --no-cacheIf you need to clear the DB:
docker volume pruneThe following instructions show you how to create a new deployment for this app on Heroku. If you have already done this, you can run the deploy.sh script instead, which only assumes you have set the APP_NAME environment variable.
- Install the heroku cli and log in
- Set the name for your heroku app:
export APP_NAME=<your app name> export API_NAME=${APP_NAME}server
- Create two apps, one for the frontend, and one for the backend:
heroku create $APP_NAME heroku create $API_NAME
- Set the following config variables in Heroku:
GOOGLEMAPSAPIKEY: your Google Maps API keyZOOPLAAPIKEY: your Zoopla API keySECRET_KEY: (Only for backend) A random key generated usingopenssl rand -hex 32or something similar.CLIENT_ID: Your OAuth2.0 client ID. In GCP API & Services -> Credentials.
- Set the following environment variables:
note
export URL_API=https://${API_NAME}.herokuapp.com
URL_APIis a build arg for the FrontEndDockerfile, but you don't have to worry about this if you usedocker compose. - Add the postgres add-on to your backend Heroku app, i.e. the one name
$API_NAMEwhich should end inserver. Note you should first check that you haven't already provisioned postgres by runningheroku addons --app $API_NAME.heroku addons:create heroku-postgresql:hobby-dev --app $API_NAME - Log in to the Heroku container registry:
heroku container:login
- Build the images locally, most easily done via:
You can stop the containers using
docker compose up -d
docker compose downas you don't need them. - Tag the images:
docker tag home-search_backend registry.heroku.com/$API_NAME/web docker tag home-search_frontend registry.heroku.com/$APP_NAME/web
- Push to Heroku (wait for first to complete):
docker push registry.heroku.com/$API_NAME/web docker push registry.heroku.com/$APP_NAME/web
- Release the containers
heroku container:release --app $API_NAME web heroku container:release --app $APP_NAME web
- Scale up your dynos:
heroku ps:scale --app $API_NAME web=1 heroku ps:scale --app $APP_NAME web=1
- open the app
heroku open --app $APP_NAME