A quick, out-of-the-box service directory with geographic search and admin features
Issues and especially pull requests are welcome. Take a look at the issues tab to see what needs doing.
A simple, production-ready directory of services that can help residents cope if they're staying at home due to the coronavirus pandemic.
Adaptations for different councils are on branches.
It has:
- 📍 A simple search form and results page where the user chooses the kind of help they need and gives their postcode, then sees relevant services
- 👩💻 A read-only JSON API for other applications to consume. Available at
/api/services
- 🔐 An admin panel and user accounts. Anyone can register but to sign in an existing user must first approve the account. At
/admin
. - 🕵️♀️ A form for users to submit their own services, which can then be published by an admin. At
/services/new
.
It uses the geocoder
gem and Google's geocoding API to power geographical functionality.
The list of categories that can be searched by are defined in app/model/service.rb
. Make sure the data source matches these.
The following environment variables can be set:
GOOGLE_API_KEY
: an API key from Google with the geocoding API enabled, used on the server.GOOGLE_CLIENT_KEY
: a API key from Google with the maps and static maps APIs enabled, used in the browser. This one will be publicly exposed to lock it down to just the hosts you plan to run the app on.GA_PROPERTY_ID
: optional, for Google Analytics trackingDATASOURCE
: optional, public URL to a CSV data source, see belowSENDGRID_API_KEY
in order to send emails. You could configure the app to use another service like Notify instead if you wish.
You need ruby, rails, node.js, npm and a local postgresql server ready.
bundle install
npm install
# create database and run migrations
rails db:setup
# populate initial database
rails db:seed
rails s
There's a seed file that will fill the database with fake data.
It will be on localhost:3000
and you can find the admin panel at /admin
.
If you're using Docker, docker-compose up
will set up a local database for you.
Suitable for 12-factor compliant hosting like Heroku.
It has a Procfile to automatically run pending database migrations on every deploy.
Alongside the admin panel, this app can also consume bulk data straight from a Google Sheet, if it's formatted in the right way.
We think this is a good way to get new products up and running fast, because there are no new admin tools to train people on.
- Get your data into the right format. Here's an example sheet to get you started.
- Make sure your sheet is publicly sharable
- Add
/export?format=csv
to the end of the URL to get a link to a CSV version, and save that as an environment variable calledDATASOURCE
. - Run
rails csv
on the hosted app, using the Heroku console or your hosting's equivalent
It should pull in all the rows from your data sheet and geocode postcodes into latitudes and longitudes.
If your data schema is different, you might need to adjust the rails csv
task a little. You can see what the task does in lib/tasks/csv.rake
.
✅ an optional map view
✅ a recommended service feature, which bumps one service per category to the top of the list
✅ admin user accounts and a proper admin panel
✅ a form for the public to submit their own service suggestions
✅ Email notifications to users when a new service is submitted for review