Skip to content

My final project for Hackbright: a web app that uses Python, Flask, CSS, JavaScript, PostgreSQL, and the Google Maps API to create a visual, map-based search of SF OpenData food truck permits.

breanneboland/go-truck-yourself

Repository files navigation

Go Truck Yourself, v 1.0

Go Truck Yourself uses San Francisco’s OpenData (and a few puns) to display what food trucks are licensed to operate in which locations. The app lets you find your true food truck love by day, location, and relevant term in either the truck’s name or the business description on file with the city.

SF OpenData Mobile Food Facility Permits
SF OpenData Mobile Food Schedule

You can learn more about the developer at her site or on LinkedIn.

Contents

  • Technologies
  • Features
  • Data and wrangling it
  • Queries
  • Structure and files
  • Screenshots

Technologies

Go Truck Yourself is built on a Flask server (which is built with Python). It uses SQL Alchemy to query a PostgreSQL database. The maps are created using the Google Maps API with markers created from a variety of JSON feeds derived from said database. Other assorted goodies: Jinja, JavaScript, jQuery, and entirely too much coffee.

Features

Current Features
The homepage shows trucks scheduled to be open that day. Each point’s InfoWindow™ is created by a single schedule record on file with San Francisco. From that InfoWindow, you can learn the truck’s name, permitted hours, location, and business details; a link within connects you to the truck’s detail page, which shows all of its weekly locations alongside its business details.

Buttons above the homepage map link to maps that show truck locations filtered by the other days of the week. The search box on each map allows targeted zoom, so you can see which food trucks are near your location any day of the week.

You can roll the dice and find a random truck via the nav, or you can search by business name, food type, or other descriptive word or phrase to find trucks matching your search term. Links on the search results page take you to truck detail pages.

Suggest a Truck accounts for the inevitable gaps in any municipal data; information submitted through that page is recorded to a txt file for future research and inclusion.

Future Features
Future plans for this app include:

  • Turning the map markers into arrays instead of creating them directly from the relevant JSON feed, as the current approach limits filtering and other display options with the Google Maps API
  • Caching said arrays for better performance
  • Organized data scraping to augment existing database entries and add information on trucks outside of the SF OpenData system
  • From said data scraping, adding information from Yelp, Twitter, and the trucks’ official websites to the truck records
  • Adding a Twilio feature that will return truck records via text
  • An automated API query to refresh the database, removing deleted entries and adding new ones

Data Wrangling

Like most databases, the information available via SF OpenData varies enough that my server required a number of contingencies to ensure the data properly displayed. Still, considering the size of the tables (the schedule permit table tops 125,000 rows) and how many stewards it likely has, the data is remarkably clean.

Server-side processes account for empty cells, inconsistent and overlapping opening and closing times, and entries that are in one table but not the other. The random function initially queries the schedule table rather than the business permit table for this reason; using the truck business permit table for this function often returned truck IDs and information without any associated schedule items, which resulted in unhelpful truck detail pages.

The times listed on the truck detail pages are created by combining each day’s schedule rows to create a complete list of times; they are then sorted, and the earliest and latest times are pulled and formatted to create a readable range of times during which truck enthusiasts could find said truck each day.

Queries

The majority of the queries in Go Truck Yourself are made with SQL Alchemy, pulling information from a PostgreSQL database in a variety of ways. The two tables (truck business permits and truck schedule permits) are connected by a foreign key generated by the business permit table; each record in the truck schedule permits table includes this ID, if available, plus a schedule line ID record.

The day-of-week maps use a string version of the day of the week to get the correct JSON back; this was a fortuitous decision, as one discovery during the course of this project was that Python and JavaScript number the days of the week differently. The API includes day-of-the-week information in both string and integer form, but the string version proved, weirdly enough, to be the easier option.

One feature, linked from the About page, directly uses the SF OpenData API to query. The initial decision to use a local database created from a CSV was one of circumstance: this app was created for, among other reasons, presentation at an event, and it needed to work independently of internet access to ensure it would be functional, even if wifi stopped being available. (You never know, even in the Bay Area.) However, this was another fortuitous decision, as these particular API databases do not accept the fuzzy search method available on other data APIs that use the SODA API. (To put it another way: it doesn’t like like.) As a result, the API-specific search is pretty rigidly defined, requiring the exact business name to get results. In the end, it was included to practice using an API’s specific instructions, which is why it’s tucked into the app’s About page. The local database search is far more versatile and effective.

Structure

requirements.txt
System dependencies for installation.

food_truck_db_seed.py
This file contains the two classes, database structures, and CSV parsing used to create the two tables that fuel Go Truck Yourself.

server.py
The routes that make the pages come together.

static
This contains a location version of Bootstrap (see the previously mentioned wifi-independence attempted with this app), the custom CSS file, and the one (!) image used in this app.

templates
This folder contains the various HTML files that are combined by Flask to create the lovely, robust app you hopefully now see before you.

truck-submissions.txt
This is where submission suggestions are recorded for future access.

Screenshots

Homepage

Day of Week Page

Truck Detail Page

Search Results

Submission Form

Submission Acceptance

About

My final project for Hackbright: a web app that uses Python, Flask, CSS, JavaScript, PostgreSQL, and the Google Maps API to create a visual, map-based search of SF OpenData food truck permits.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published