How I Built FunnyLeni in less than 12 Hours on Google App Engine

This post was written by +Femi TAIWO and appeared first on JunctionMedia.

The Google Cloud Developer Challenge is on right now with just about a month left and I thought it would be good to try out building something simple but entertaining within a short period on it. And release the source code for anyone to see the ease and hopefully inspire more interesting ideas.

The idea I choose

One simple idea came to mind. A site showcasing the funniest "homegrown" YouTube videos from Nigeria.

A better definition is 'Find & Watch the funny videos in Nigeria watched by your friends'.

Below is a screenshot

funnyleni

The name I chose

FunnyLeni.

Why? Just because 🙂

Showcasing the videos is the easiest part. It's just a database of a list of videos. I can sort it anyway I like. Allowing people to submit YouTube videos is just as easy.

On the other hand, finding the ones watched by your friends is 'trickier'. Google+ Sign In came to the rescue for that. More on this later in this post.

The how I chose

Thankfully, my everyday language – PHP is now supported on the Google App Engine, hence it was quite easy to get started on the project.
Google App Engine supports four languages – Java, Python, Go and PHP. If you haven't checked out Google App Engine lately or you are just hearing about Google App Engine, then the following page is for you – https://developers.google.com/appengine/docs/whatisgoogleappengine.

BTW – there are lots of interesting projects you can build on GAE like  Realtime Multiplayer games using the Python or Java.

So my plan was to use PHP + MySQL + YouTube Content + YouTube API + Google+ API.

Below is a screenshot of the database structure –

funnyleni_db

In total, I have 4 tables –

  1. Users – holds users registered
  2. Vvideos – holds the video information, how many views in total
  3. Friends – holds the list of friends attached to each user. Friends form G+ circles
  4. Views – holds which video has been seen by which user.

I'm a console-first person so I used the google-sql command line. However, Google provides a page just for importing data and running sql statements for your database instance – https://developers.google.com/cloud-sql/docs/sql_prompt

Next Step – I looked at the YouTube API [https://developers.google.com/youtube/v3/] , to find out which one would allow me to pull the information about any YouTube video.

By sending the YouTube ID, I could now get the name, length, description etc of the video. So I save those.

The Look I Chose

I love simple. I hate having to create a look and feel from scratch. I avoid it actually. Hence  I used and still use Twitter Bootstrap. A LOT. So I just picked used that.

Google provides a lot of code – called Client Libraries for plenty of its APIs. These client libraries are available for different languages [https://developers.google.com/youtube/v3/libraries]. So I downloaded the one for PHP. And used the code below to pull the YouTube info and the response received from the call.

[gist https://gist.github.com/dftaiwo/7131806 /]

Response

[gist https://gist.github.com/dftaiwo/7139236 /]

Those were the easy parts.
The harder part was solved using G+ sign-in. Seeing what videos your friends have watched involves a series of steps –

  1. You must be signed-in.
  2. You need to grant access to your Google+ Circles.
  3. FunnyLeni must compare your circle of friends with the list of users registered on FunnyLeni.
  4. If any of your friends match, then great!

Moreover, anyone can submit a video from YouTube.

I could have used frameworks like CakePHP or FuelPHP or CodeIgniter etc, but I thought it would be easier for anyone to follow if I did not use those. So I built a micro-mini controller (FunnyLeni::handleRequest) to handle the VC part of MVC.

G+ offers really kool apis and javascript-based methods to help drive engagement. You can learn more about these by going to https://developers.google.com/+/web/.

Finally you can check it out on http://funnyleni.appspot.com. 

The entire code for the first release is available on github here – http://goo.gl/8VRQY6. Warning – I wrote this in a hurry (less than 12 hours) so naturally there's room for improvement and refactoring. There are probably things I could have done much better if I took more time to think. Feel free to poke holes, suggest features and let me know on the mailing list.

I've also learnt that writing code is easier than writing a blog post about it this way. It's taken me longer than 12 hours to write this post.

The Google Cloud Developer Challenge is still on. Check out this comprehensive video on getting started with Google App Engine – https://www.youtube.com/watch?v=8jRabiFLvZQ or another cool but short one for PHP – https://www.youtube.com/watch?v=cj09WbpZ32w

If you are looking for Ideas for Great Apps and Real life use cases of App Engine – this video is a great place to start. https://www.youtube.com/watch?v=uiw2XUGa3U8.

Follow the #gcdc hashtag as well.

Happy coding!

The Google Cloud Developer Challenge – Getting Up to Speed on It

Participate in the Google Cloud Developer Challenge by developing new applications built using Google’s cloud platform.

Developers in 6 regions across the world will win prizes that include Android devices and up to $20,000 USD.

All you have to do is build and submit an amazing application in one of these categories:

  • Enterprise/Small Business Solutions , Education, Not for Profit
  • Social / Personal Productivity/Games / Fun

A winner will be chosen for each category, in each region — 12 prizes in total.

The first round of submissions closes November 21, 2013.

Prizes

  • Round One:
  • – All teams that make it to the semi-finals in each category in each region will be awarded Android devices.
  • – In order to encourage participation from women and highlight innovations from women in the developing markets, we are adding an additional prize. If a Semi-Finalist happens to be an individual or a team consisting solely of women, that team will be awarded an additional prize of $2000 USD.
  • – Any university team made up entirely of student or staff of a university (identified by the university domain email address) that makes it to the semi-finals will get $1,000.

  • Semi-Finals: 
  • – 1st prize in each category in each region will receive $20,000. This means that there will be a total of 12 grand prize winners
  • – If any team from a university wins the competition in any of the categories, the department to which the members of the team belong will win $18,000.
More on Prizes
  • All Entrants who are selected as Semi-Finalists will be awarded a Nexus 7, as available in their region, with an approximate retail value of $200 USD.
  • In order to encourage participation from women and highlight innovations from women in the developing markets, we are adding an additional prize.  If a Semi-Finalist happens to be an individual or a team consisting solely of women, that team will be awarded an additional prize of $2000 USD.
  • If an entry is submitted by a university student (as an Individual) or by a Team comprised entirely of university students and/or faculty is selected as a Semi-Finalist, that Team or Individual will be awarded an additional prize of $1,000 USD.
  • For clarification, if a Semi-Finalist happens to be an individual that is a university student and a woman or a team consisting solely of university students that are also all women, that Individual or Team will win both of the prizes above for a total prize of $3000 USD.

Finalists:

  • There will be one winner chosen from each region per category and will be awarded: $20,000 USD (total number of winners is 12).
  • Conditional University Prize: If any team from a university wins the competition in any of the categories, the department to which the members of the team belong will win an additional $18,000 USD.  In the event that the team members come from different departments, the money will be evenly divided between their departments.
Judging Criteria
Round 1: Selection of Semi-Finalists:
Each App will be evaluated by the Judges based on the following criteria:

  • Effective Use of Google App Engine
  • Originality of Concept
  • Relevance to Region
  • Polish and Appeal
  • Usability on multiple screen sizes
  • Accessibility
  • Indispensability: Is the application compelling and/or essential?
  • Amount of user interactions on their app (comments, +1s, likes etc)
  • Google+ Sign-In / Integration (Not compulsory:Bonus Points)
  • Creative use of Youtube and Google Maps APIs  (Not compulsory:Bonus Points)
  • Use of other Google platforms/APIs  (Not compulsory:Bonus Points)


Build on Google App Engine
Google App Engine makes it easy to build an application on Google infrastructure that runs reliably, even under heavy load and with large amounts of data. 

Languages
Your application can be written in 
– Java
– Python
– Go
– PHP

The Four Easy Steps:

Quick notes  about AppEngine- 
– No filesystem access
– Complete a web request in less than 60 seconds


Remember, the first round of submissions closes November 21, 2013.

Get started today! All the best!