foodtruck

module
v1.0.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2020 License: MIT

README

FoodTruck

FoodTruck is an application which provides search interface for food trucks in San Francisco area. The datasets (permits and schedules) are provided by DataSF.

Components

  • foodtruck-search provides search interface for food trucks.
  • foodtruck-import imports food truck data into a Postgres database.

Installation

The following terminal commands are tested on MacOS and should work on POSIX compatible systems (i.e. Linux and maybe WSL).

There are two ways to install and use FoodTruck application: using Docker or building binaries from source. For simplicity, the following instructions use Docker. If you're familiar with Golang then feel free to build binaries from source.

Step 1. Database Setup

FoodTruck uses Postgres database for storing data so you must setup the database first. Go to the Database Setup page and complete the required steps.

Step 2. Build the Docker image

If you have completed the Database Setup steps then you should already have foodtruck Docker image on your system. When you make code changes or pull the latest code you must rebuild the docker image.

# Clone the repo if you haven't and go to the root repo directory
git clone github.com/devfacet/foodtruck
cd foodtruck/

# Run the following command from the repo root directory:
docker build -t foodtruck .
# It should output `Successfully tagged foodtruck:latest` for a successful result.

# To test the Docker image run the following command:
docker run -it --rm foodtruck
# It should output the help information for a successful result.

foodtruck-search-help

Usage

Before continue make sure you've completed the Database Setup and foodtruck-db Docker container is up and running. Otherwise nothing will work.

# To check whether foodtruck-db container is up and running:
docker ps

# To check foodtruck Docker image
docker run -it --rm foodtruck
Search Food Trucks From Command Line Interface
# First run the foodtruck container which includes foodtruck tools:
docker run -it --rm --link foodtruck-db:foodtruck-db foodtruck /bin/bash
# Note that `--link` argument creates a network connection between foodtruck and database containers.

# Export database address env variable for shorter commands:
export DB_ADDRESS=postgresql://postgres:postgres@foodtruck-db:5432/foodtruck

# Search food truck locations with default values:
foodtruck-search location

foodtruck-search

# Try different latitude, longitude and radius values:
foodtruck-search location --lat=37.759875 --long=-122.425942 --radius=2

foodtruck-search

Search Food Trucks via REST API
# First run the foodtruck container to start the REST API server:
# Note that `-p 8000:8000` maps the REST API port in the container to the host system.
docker run \
  -it \
  --rm \
  --link foodtruck-db:foodtruck-db \
  -p 8000:8000 \
  foodtruck \
  foodtruck-search \
    --db-address=postgresql://postgres:postgres@foodtruck-db:5432/foodtruck \
    listen \
      --address=0.0.0.0:8000

# It should output "listening for API requests... address=0.0.0.0:8000" for a successful result.
# Open a browser window and go to http://localhost:8000/locations/?lat=37.777651&long=-122.406759

Try different latitude, longitude and radius values: http://localhost:8000/locations/?lat=37.759875&long=-122.425942&radius=2 foodtruck-search

Build

# Requires Go >=1.14 (https://golang.org/dl/)
# It will create the following files (make sure $GOPATH is set):
#   $GOPATH/bin/foodtruck-search
#   $GOPATH/bin/foodtruck-import
./build.sh

Test

# Requires Go >=1.14 (https://golang.org/dl/)
./test.sh

Release

git add CHANGELOG.md # update CHANGELOG.md
./release.sh v1.0.0  # replace "v1.0.0" with new version
git ls-remote --tags # check the new tag

Contributing

See CONTRIBUTING.md

License

Licensed under The MIT License (MIT)
For the full copyright and license information, please view the LICENSE.txt file.

Directories

Path Synopsis
api
cmd
Package giner provides abstraction layer for Gin Web Framework.
Package giner provides abstraction layer for Gin Web Framework.
Package postgres provides abstraction layer for PostgreSQL database operations.
Package postgres provides abstraction layer for PostgreSQL database operations.
Package search implements search interface.
Package zlog provides abstraction layer for zerolog logging library.
Package zlog provides abstraction layer for zerolog logging library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL