Beansight is now open source

Four years ago, I started working on Beansight with Cyril, Guillaume and Jean-Baptiste, a project that became a long adventure.

beansighthb

The website (that we host at www.beansight.com) and associated mobile apps allow users to create predictions and vote on other’s predictions. Computation is done to extract from all votes a percentage of probability for a given event.
The website features all mechanisms of a social website : registration, login, user profiles, followers / following, content creation, comments, moderation tools, administration dashboard, API, i18n.

Main page when logged into Beansight
Main page when logged into Beansight

All our code and design are now available under the open source Apache licence. That means anyone is free to use it to run a similar website or to build upon it. Get it from GitHub.

The technological architecture is quite regular: a server is generating web pages using a MVC framework, data is stored in a relational SQL database and user generated images are stored on the file system. Some simple client-side JavaScript is enriching these generated pages.

We built Beansight using the great Play! Framework. It turned out that Play! was a really great choice for our architecture and project. At that time, Play! was a Java web framework that got rid of the traditional Java web stack to focus on a simple MVC architecture, inspired by rails and other modern web frameworks, that prevails convention over configuration.
It was a real pleasure working with this language in a framework so well designed for websites like our.

Beansight Android application
Beansight Android application

Mobile application are native for iOS and Android and we used jQuery mobile for the mobile web version.
We decided to keep a very simple UI as part of our native mobile apps. We were one of the first apps to use ViewPager on Android for example.

We realised quite soon that we needed to build an API, mostly for these mobile apps. Our MVC architecture allowed us to easily create one. Ideally I think the main website should have use it (either client or server side). Anyway, our API code and website code were sharing a lot, thanks to our rich object oriented Models. You can find the API documentation in a GitHub wiki.

We used different hosts. We first started with PlayApps.net, the Platform As A Service offer from the builders of the Play! Framework. We never encountered any issue with it and were very satisfied to not bother about system administration. However, we had to move due to the service closing. Beansight was then running on Gandi Hosting. Here we had to take care about administring our server, which added some pain to the maintenance of Beansight.
Finally, in order to reduce the costs and make it easier to setup as part of the open source process, we made sure it is compatible with the Heroku PaaS hosting.
Today, Beansight can be easily run on any Linux server or pushed to Heroku with any MySQL database (beansight.com is now using clearDB for example).

I hope this code will be useful to somebody. I would be pleased to see you starting a new community from it, building something on top of it, or using it as part of another project.
While a few technical improvements could be done, I think it is still quite reliable, with a pretty well documented source code and good architecture.

Get all the code on GitHub:

Advertisements

Square of the Dead

or “28 check-ins later“…

This week-end, I participated to the foursquare global hackathon. I worked with Jean and Olivier on

I’ve been having an idea for a long time: imagine a virtual virus that is spreading due to our social interactions. Wouldn’t it be great to see it spread and to see how people react? Foursquare was the ideal product to build upon. So I pitched a crazy idea about virus and zombies, saying that a game mechanism was still to be defined.

Inspired by zombie movies, we worked a long time to define a simple game pluggable on foursquare. After a couple of iterations, we came up with a simple system:

Square of the Dead, rules

Players can either be survivors or zombies.

  • When you are a zombie, you contaminate every place you check into. Your goal is to spread the virus.
  • When you are a survivor, you get contaminated if you check into a contaminated place. Your goal is to survive, for this you can find guns in non-contaminated places. These guns will allow you to de-contaminate places and transform zombies from these places into survivors.

The game do not require so much actions from the players, they just have to keep using foursquare to play. We minimized the problems by adopting a cross-platform notification system that everyone is already using: emails.

Technically, we used the Play! framework deployed on App Engine using Siena. I ran into a bug that made us lost some precious hours.

We will polish the game and maybe come up with some nice other features (like a map to see the virus spreading all over the world!).
Try “Square of the Dead” now.

Olivier, designer, also blogged about his experience.

Working on the project, picture by Le Camping

I really enjoyed the hackathon. Other projects were really great. here are my favorites:

  • 4sqBox: receive files when you chek-in somewhere
  • fstalk2her: check the boy/girl ratio before going into a bar and see what you have in common with these people 😀
  • Check Me In: Check-in just by facing your smartphone in front of the venue’s iPad (use case: you have no network)
  • Gettogether: very slick mobile app to organize something with friends.

Open Divers: How is it done?

It all starts with some drawings: first the a few screens of what the website should roughly look like. And then the data model, to get an overview of all the entities of the website, and their relations. Have a look, you will see that objects are very linked:

Current Data Model of the website

I’m developping using Play! framework. It is a very efficient Java web framework, where you focus on getting things done. I can assure you it’s not traditional Java (servlets and all) and that when you start feeling comfortable with it, you can build a clean website very quickly. If you are a web developer who wants to try something refreshing, you should give it a try. (I think you can compare it to RoR, Jango or Symfony)

I first start by defining the objects (Models) of the platform, and relations between them. The framework uses JPA to automatically create the underlining database.

Then I define actions in Controllers to display and edit this data: “show dives”, “explore”, “login” are example of actions.

Finally, I create the different pages (the Views) using HTML and the templating engine. I first used some code from HTML5 boilerplate to start building on something clean. I use some Javascript (with the jQuery library) to perform dynamic actions on the client side (messages that disappear, pop-up layers for login…). I also use jQuery UI for some widgets (a date picker, an accordion for the dive edition page) and the Google Maps Javascript API to display satellite maps. (I really needed satellite imagery, so I cannot use OpenStreetMap data).

I did not found the time to write unit tests, functional tests or front end tests, this is very bad. It will be the first thing I do when I start working on the project again.

There is still a lot to do, it’s a first version, let’s add on top of it. Check out the screenshots from yesterday’s post.