BeerCloud for Android and iPhone

BeerCloud on AndroidGreatBrewers.com, a Drupal 6 site, powers BeerCloud, a mobile app available in the Android Market and iTunes App Store that helps you pair beer with food, track down your favorite beers in your neighborhood, and pull up a full description of any beer with a scan of its barcode. Whether you're a beer consumer who could use some guidance in making a well-educated purchase, a food lover who wants to discover new ways to enhance a meal with a suitable beer pairing, or a traveling beer enthusiast who wants to instantly map the closest stores, bars, and restaurants carrying one of your favorite beers, BeerCloud is the quintessential mobile beer app.

Great Brewers is powered by America’s leading network of beer passionate wholesalers that collectively represent the interests of the world’s best brewers by promoting education and awareness through shared resources. The mission of Great Brewers is to bridge the gap between the world’s great brewers and the consumers who enjoy their products, with a paramount focus on education and on enhancing beer distribution practices through the sharing of information.

About BeerCloud

BeerCloud on iPhoneThis new software uses the Drupal Services module as the backend to provide beer descriptions, brewery information, the location of retailers carrying specific beers, and upcoming functions including favorites, a website user's profile, comments, tasting notes, and more. This functionality, including proximity search, is already available on GreatBrewers.com. Therefore, BeerCloud's mission is to bring all of these experiences to the user's pocket by extending all of the resources from the web.

BeerCloud further enhances the user experience by integrating with handheld device hardware features, like a GPS and camera, which are not available on most PCs. When a user scans a beer's barcode with an Android device's camera, the app will return corresponding beer information from the remote GreatBrewers.com server. The app can also utilize GPS latitude and longitude data to find the closest retailers carrying a specific beer based on locations listed on GreatBrewers.com, hence the name "BeerCloud" (the Cloud refers to Cloud computing).

From an architecture perspective, the BeerCloud app uses the Drupal storage (node with CCK and Taxonomy and user) and content management layers to create/edit/update information, then exports the content via the Services module, which functions as a communication layer. Therefore, on Android and iPhone, the native BeerCloud app works as a presentation layer, which, in Drupal terms, is just a theme!

GreatBrewers.com Architecture Backgroud

GreatBrewers.com screenshotSince all the hard work is done on GreatBrewers.com, it makes sense to give a general overview of the architecture of the site. The main content types on GreatBrewers.com are (i) Brand, (ii) Product, and (iii) Retailer. Besides some necessary CCK fields for each content type, "product" uses the NodeReference field to "brand" and the Barcode CCK field to store and generate UPC-A barcodes; each "brand" and "retailer" have Node Location data, and "brand" uses Views to display all of that retailer's products, using reverse NodeReference. The Flag module is configured to let users flag a brand (brewer), product or retailer. The beer sales location data is uploaded to one table in the database. With Views API, the sales location data is mapped between "retailer" (Node Location) and "product" (Node Id), so that Gmap Views plugin can perform a proximity search on each product. Furthermore, "beer styles" are taxonomy terms for "product." For a more comprehensive overview of how we use Drupal for GreatBrewers.com, click here.

Beer Sommelier -- Taxonomy Drilldown

Beer Sommelier is one simple application contained within BeerCloud and GreatBrewers.com. You might want to load this application on the web first to see how it works -- click here. The idea of this application is to guide users in pairing various foods with complementary beers. First, you select a main ingredient then a specific dish, and Beer Sommelier returns a list of recommended beer styles with the option to view specific beers that match each style.

"Main ingredient" and "specific dish" are very simple content items on GreatBrewers.com, so we just use Image as the content type for them, and upload images with very short descriptions. Then we set up the beer style taxonomy tree and upload a mapping table between "specific dish" nodes and "style" terms. So, whenever a product (beer) node is created with a tagged beer style, the Beer Sommelier can recommend food for it or vice versa. This food-and-style mapping table is also mirrored (uploaded) to the BeerCloud app SQLite database. So, the Beer Sommelier on mobile phones can work offline until it needs to pull out the matching commercial beers. This is done by a simple taxonomy service call with term ID. The returned list references the matching beer nodes.

Customized Text Search, Barcode Search and Proximity Search Services, and More Services

BeerCloud SearchGetting a list of nodes is just a start. The very basic service node.get from the Services module provides a simple way to load any node from a remote Drupal site. With "optional fields" arguments, you could also save some time of transferring the data over internet, and parsing the data on the client site. BeerCloud uses node.get for retrieving brand (brewer) and beer information. Furthermore, each brand (brewer) has a list of products, which are stored by NodeReference. Since we have already used Views on GreatBrewers.com to display this list, on the BeerCloud app, we simply call Views service to get that product list.

For a standard text search, we wrote a simple Node Title keyword search service. Since Barcode is just a CCK field, we included a customized integer search for that as well. In future releases, those services could totally be done by standard Search service and Views service. However, since we don't require any authentication for those search services, we created our own customized services to speed things up (authentication takes resources and time).

The workflow for barcode scanning is fairly straightforward. We use the Zxing library on Android so the camera functions as a barcode scanner, which analyzes the image and returns integers to the native application. After that, BeerCloud fetches the matching nodes through the barcode integer search service, then the app themes them on the device.

BeerCloud Proximity SearchTo enable proximity search, we exported Proximity Search Location Views into a service, since Location doesn't yet support latitude/longitude Views arguments. This receives the GPS or cell tower latitude/longitude data from a cellphone, and returns the retailers within the defined parameters.

Google Analytics Service

Since all the data coming from the Services module is themed into the native mobile phone app, there is no Google Analytics JavaScript executed on the client side (keep in mind that BeerCloud is not a Web application). However, Google rolled out a server side Google Analytics script, which transforms the reporting responsibility for Google Analytics to the server. Unfortunately, the script shipped by Google only works with browsers without JavaScript capability, meaning it does not work with non-browser clients. So, I modified Google's script and wrote a Services addon module to record each Services call. The modified version of this script supports all clients. Check out Google Analytics Service for more information.

Since launching BeerCloud mobile apps, which allow Android and iPhone device users to access data from GreatBrewers.com, Google Analytics has revealed an approximate 400% traffic increase compared to the traditional web traffic. By making scalability a top priority when engineering GreatBrewers.com, we have handled this sudden explosion of traffic with ease. On the hosting infrastructure, we have implemented Varnish, MySQL query caching, APC caching, Memcache. We are also working to migrate to a next-generation Cloud Hosting platform, which will provide us with even greater durability and scalability in the near future.

Upcoming Flag Service

The Flag module enables GreatBrewers.com users to manage their favorite brands (brewers), beers, and places to buy beer. With Views, it can achieve a lot of things. The Flag 2.0 module supports Services module, and we are working on the "themes" on BeerCloud Android to integrate the Flag service.

Code Snippets or Potential Android Library for Drupal Services

We wrote a library called DrupalCloud and put it on GitHub, which needs a lot of testing, documentation, and improvements. We much appreciate anyone's interest in, and future help with, this library. Please click here.

Thanks to:

Eric McKay, creator of GreatBrewers.com, and co-author of this case study
heyrocker and marcingy, maintainers of Services module
bdragon, maintainer of Location and Gmap module
merlinofchaos, maintainer of Views module
Sean Owen, maintainer of Zxing project
Daniel Switkin, primary developer of Zxing project.
quicksketch, maintainer of Flag module
Tom Byrne, lead graphic designer of GreatBrewers.com
Jim Yonac, iPhone developer for BeerCloud
Rob Loach, my biggest supporter
slip, co-maintainer of Barcode module
Drupal community, GreatBrewers.com community, DrupalNYC community and Android community

Why Drupal was chosen: 

GreatBrewers.com was built on Drupal 6, which is the foundation for the BeerCloud project.

Modules/Themes/Distributions
Why these modules/theme/distribution were chosen: 

These key modules provided the functionality required by this project.

Community contributions: 

BeerCloud project has contributed Barcode Module, Flag Service Module, Google Analytics Service Module and DrupalCloud (an Android library).

During the time BeerCloud was being developed, Jingsheng Wang (skyredwang) also worked on Services Module.

Team members: 
Project team: 

Eric McKay, creator of GreatBrewers.com, and co-author of this case study
Tom Byrne, lead graphic designer of GreatBrewers.com
Jim Yonac, iPhone developer for BeerCloud

BeerCloud Barcode Scanning
BeerCloud on Android
BeerCloud on iPhone
GreatBrewers.com screenshot
BeerCloud Proximity Search using Drupal Location and Views
Drupal User Profile & Text Search

Comments

Link in broken in the body copy; should be: Google Analytics Service [http://drupal.org/project/gaservice]

Can you describe a little more what you mean by mapping table.

Cheers Dan