Next is an API that provides transit related data from the Portland, OR area. Data comes from multiple sources including free-roaming scooters, free-roaming bikes, the metro area's transit system, and drive times.
This API obtains it's data from the following sources
At a top level, the returned data from this API is structured like this:
{
"bike_shares": { ... },
"trimet_stops": { ... },
"share_stations": { ... },
"drive_times": [ ... ],
}- Install Docker and Docker compose. This app lives inside containers now.
- In order to start this API locally, first configure the following environment variables:
export $POSTGRES_USER= # Postgresql Databse Username
export $POSTGRES_PASSWORD= # Postgresql Password
export $POSTGRES_DB= # Postgresql Database Name
export $TRIMET_API_KEY= # Can be obtained from Trimet's Website- To start for development, you can first run
docker-compose -f docker-compose.dev.yml up -dto start all the services and the rails app itself. It may take some time for bundler to install the needed gems!
Run a docker-compose ps to see them running:
NAME COMMAND SERVICE STATUS PORTS
next_postgres_1 "docker-entrypoint.s…" postgres running 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp
next_redis_1 "docker-entrypoint.s…" redis running 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp
next_web_1 "entrypoint.sh bash …" web running 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp
- Bash into the running
next_web_1container with./bash_into_next.shor by runningdocker exec -it next_web_1 bash. - Once inside the container,
cd /src/and start the rails app and the sidekiq jobs withforeman start.
Thats it! The src/ director is mounted as a volume inside the container, so you can make edits to the source
and see them affect the API immediately!
Follow steps 1 through 4 from above, and then:
3. Run rspec inside the src/ directory and watch the output!