Bus-Fly-Go

Responsive image
Responsive image

ShowOHI/O

Bus-Fly-Go was recently presented at ShowOHI/O 2017! This document was used at the show and provides a great overview of the project.


What is Bus-Fly-Go?

Bus-Fly-Go is an extreme budget travel application, implemented using Rails. It pairs up bus tickets from middle-sized cities, with cheaper flights originating from large, alternative airports.

Example: Consider a user's request to travel round-trip from Columbus, Ohio to Mumbai, India. Bus-Fly-Go first searches for direct flights between Columbus and Mumbai. On average, this ticket will cost around $1,000-$1,200. Pretty expensive eh? No worries though, as Bus-Fly-Go already started searching for bus tickets from Columbus, to the larger, cheaper airports!

The application finds bus tickets from Columbus to alternative cities like New York, Chicago, Washington D.C. and Baltimore. It then pairs the bus tickets with optimally matching flights from the given alternate city, to the end destination, Mumbai. Therefore, if a flight from Chicago to Mumbai is found for $800, and bus tickets are available from Columbus to Chicago for under $50 a piece, it can potentially save $100-$300.


Technical Specifications

Languages: CSS, HTML, JavaScript, Ruby, SQL
Technologies: Bootstrap, Firebase, jQuery, PhantomJS, Rails, React, Redis, RubyMine, Sidekiq, SQLite


Technical Highlights

Ruby on Rails is used as the base framework for Bus-Fly-Go. Firebase, a JSON based cloud data structure, is used to store results, because of its accessibility to the client. Client-side ReactJS pulls results down from Firebase and presents the appropriate view to the end user.

Ticket data is scraped using PhantomJS, which unfortunately, is the slowest running function of the application. Sidekiq, a background processing utility for Ruby, is used to gather and push ticket data to Firebase for each alternate city. Thus, a Sidekiq worker is created for each alternate city, in an effort to speed up the web scraping process.

Code Example: When a user requests to see bus and flight ticket data, the controller in Rails quickly sends a temporary loading web page to the user, after launching the initial Sidekiq background worker.

  # app/controllers/trips_controller.rb
  [...]

  if @trip.save

  # Launch initial Sidekiq worker
  TripWorker.perform_async(@trip.token, @trip.from, @trip.to, @trip.dep_date, @trip.arv_date)

  # Send asynchronous loading page to the user
  format.html { redirect_to @trip, notice: 'Trip is being loaded.' }
  format.json { render :show, status: :created, location: @trip }

  else
  [...]

Multiple Sidekiq workers are then dispatched by the backend. Each worker gathers and pushes bus and flight ticket data to the user, which is therefore loaded in asynchronously.


  # app/helpers/trips_helper.rb
  [...]

  # Method being performed in the background by Sidekiq
  def perform(token, from, to, dep_date, ret_date)

  # Class which holds universal trip information
  t = TripInfo.new(token, from, to, dep_date, ret_date, is_ret)

  # In this example, consider three alternate cities. Now we launch a Sidekiq worker for each alternate city, which all run simultaneously
  TripWorkerThread.perform_async(t.getToken(), [...], "CHI")
  TripWorkerThread.perform_async(t.getToken(), [...], "NYC")
  TripWorkerThread.perform_async(t.getToken(), [...], "BWI")
  [...]


Project Status

Bus-Fly-Go is still under development. Although the core product is functional, it is a continually evolving project.

Bus-Fly-Go is kept in a private repository. Please contact me if you would like to learn more about the project.