LaraHack 2018: My Project
This weekend was the first LaraHack, a 48 hour online Laravel hackathon.
A Laravel Hackathon Starting 3rd Feb 2018larahack.com
I wasn’t sure if I’d have time to participate (and it turned out I couldn’t participate for the full 48 hours), but I found time to build something.
Once the event started, the (optional) theme was announced: Make a game with Laravel.
Games are tough, much tougher than most people expect, and since I knew my time was going to be limited, I decided to build something else instead.
As mobile applications gained popularity, the problem of getting people to pay for these applications was a discussed a lot.
Developers would often mumble:
“you’ll spend $4 on a cup of coffee at (insert your favorite coffee brand here, usually Starbucks), why won’t you spend a paltry $1 on my app?”
As I purchased a cup of coffee on my train ride down to NYC this past Friday it got me to thinking about the quote above. The $4 price mentioned is usually for a fancy high end blend, and even factoring in high San Francisco prices I knew I was paying far less than $4.
What is the average price of a cup of coffee across the country?
I had put the question out of my mind, until I was trying to decide what to build for LaraHack.
The idea was simple, but just how would I be able to work out the average price of a cup of coffee from all over the country? Although it might be fun to travel all over the country buying coffee, I’m pretty sure my budget wouldn’t extend much further than my local coffee shop.
I searched Google, and while there were some news posts about the price of coffee there was no data that I could use. One article did catch my eye:
The article had a very cool infographic…
Right there was the data that confirmed my suspicion, none of the coffee options where over $4. But this was a just a one time snapshot, and I wanted something that would be updated on a regular basis. The data was sourced from Square purchases. I doubted they would give me access to their data.
This got me thinking about where else I could get this information. I started to think about online ordering. Grubhub jumped to mind, you can order from lots of different restaurants from all over the country, surely coffee was on the menu too. Unfortunately I was unable to be find a public API, and although a private one appears to exists, I doubted I’d be able to get access for this idea, and even if I could not in time for the hackathon.
I continued to think about menus, and after some more searching landed on Foursquare. Not only would their API allow me to search for cafes from all over the countries, their API would also allow me to inspect the menus for some of these cafes too, which often includes pricing. Not every venue on Foursquare has a menu online, but I’d could get enough data to build what I wanted, and I could signup and start developing right away.
I found a Laravel package for interfacing with Foursquare:
php-foursquare - A simple foursquare API v2 library for PHP focused on supplying core functionality without any extra…github.com
I built a few small pages that let me search Foursquare specifically for cafes, and view their menus, and find those that contained coffee as an option that listed the price.
Once I found a match I added that cafe to the website database.
I then wrote a Laravel command to query Foursquare on a regular basis to save the price of the coffee for each cafe to the local database.
Once I had a list of prices for coffee I was able to calculate the average.
I wanted to keep things very simple for the hackathon, so I ended up designing a very simple website, just 2 pages. One that shows the average price of coffee and a page the describes the website.
I decided to go with a big bold typography style, since the information was pretty limited, and I wanted it to make an impact. This kept things simple and easy to build.
In the time I had available I was able to find about 30 cafes that had pricing information available, and they currently have an average price of $2.29 for a cup of coffee.
I’ve I’d had more time, I would have loved to find more cafes, and provide a breakdown by city and state for the price of coffee, perhaps in the coming weeks.
I’m not sure how often Foursquare updates the pricing in it’s database, but I will be updating my local database daily. It will be interesting to see how the pricing changes.
Keep an eye on the website to see if the average price of a up coffee changes…
I was able to finish a project that looks pretty simple when you look at the completed website. However, figuring out a way to source the data and keep that data updated on a regular basis is far trickier than the essentially one page website that I build.
I’m looking forward to seeing what others have built during LaraHack, I’m sure there will be many great projects.