Chirper is the first open-source non trivial web application example with .NET/NoSql integration. Chirper implements a simple twitter clone that, unlike twitter
, uses Cassandra as its only database. It would’ve been probably cooler to code Chirper it in Ruby or in Python but, unfortunately, this is already done.
Chirper’s front-end is written in C# / Asp.net MVC 2.0. The back-end is based on Cassandra using the Aquiles library. The source code is freely available under the terms of the Apache License, Version 2.0.
Installation
Before going into Chirper’s design details in the next sections, you might want to play a bit with it first. For this, you will need to: (1) configure the database store with Chirper’s schema, and (2) setup Chirper in your favorite webserver that supports Asp.net.
Cassandra configuration
Simply edit Cassandra’s storage-conf.xml file and add a Chirper keyspace as follows:
<Keyspaces> <Keyspace Name='Chirper'> <ColumnFamily Name='Users' CompareWith='UTF8Type'/> <ColumnFamily Name='Tweets' CompareWith='UTF8Type'/> <ColumnFamily Name='Following' CompareWith='UTF8Type'/> <ColumnFamily Name='Followers' CompareWith='UTF8Type'/> <ColumnFamily Name='TimeLine' CompareWith='UTF8Type'/> <ColumnFamily Name='UserLine' CompareWith='UTF8Type'/> ... </Keyspace> </Keyspaces>
We will go through the data schema in more details below. If you don’t have already a Cassandra node at hand don’t worry, it’s easy to set up. Here is how I did.
Installing the webapp
Just download the Chirper’s latest binary and unzip it somewhere on your hard drive. From your webserver configuration console create a new webapp based on the unzipped Chirper folder. The exact webapp creation steps depend on your webserver. Here are the instructions for IIS7.
The alternative would be to check-out the source code and run (or debug) Chirper from visual studio, using the development web server.
Design
Front-end
Chirper is still work in progress. However, it has already the most important features: tweeting, following other users, displaying timeline and userline, dispalying followers list etc. The front-end is really simple, nothing much to say here. Here are the main components:
- Two MVC controllers are handling all the user actions: one controller for authentication and registration (similar to the one presented here) and another controller for everything else. The views are kept very simple too.
- The model consists essentially of two classes: User and Tweet. Follower and Following are just users with a time-stamp.
- A repository class abstracts all the web application logic from the back-end operations. This is really helpful in case we might want to mock the db store for testing.
Back-end
Chirper’s schema is really straightforward and very similar to the one implemented in Twissandra. Basically, we have two main families: Users and Tweets. Four other families are introduced to join theses main families in order to implement timelines and followers lists.
Users family
All Chirper users are recorded in this family. Rows are keyed by user name. Each column name/value represents a user’s property: Name, DisplayName, Location, Password etc.
Tweets family
This family holds all Chirper tweets (or chirps
). The rows are keyed by tweet id (a UUID). As for users, the columns represent the tweet properties.
Timeline and Userline families
A timeline (resp. userline) is simply a set of time-stamp/tweet id pairs held in rows keyed by user ids. The timestamps correspond to when the tweet was tweeted. In the userline family, the tweets are those tweeted by the user used as row key. In the timeline family, the tweets are tweeted by the followed users.
Following and Followers families
The following (resp. followers) family joins users with their following (resp. followers) users.
Conclusion
It was surprisingly easy to interface a .NET webapp with Cassandra. I had to write a few helper functions around the Aquiles connector but it did the job very well. Chirper’s schema is NOT designed to scale. It was kept very simple for the purpose of demonstration. I am currently looking for some help on Chirper’s web design, if you feel like contributing, please drop a comment here. It would also be nice to host a running instance of Chirper on the web (as Twissandra and Retwis do). If you can help on this please contact me.




Pingback: Tweets that mention Chirper: twitter clone WebApp with .NET front-end and Cassandra NoSql back-end - Chaker Nakhli's Blog -- Topsy.com
JavierCanillas
July 27, 2010 at 5:25 pmThanks for taking the time to test Aquiles. I have already added a link in my project as a success story!
kerwin
December 15, 2010 at 11:58 amgood job! I’m glad to see there is .net sample for cassandra.
Ross Warren
February 28, 2011 at 12:07 amI am currently working on a Twitter clone with Cassandra / Hector for Java, with some extra features such as geolocation and Liking! The basic column families were inspired by your project so thank you muchly! I will add a link to your project from mine, I should really have done so already! My project can be found here http://ross-warren.co.uk/?p=171
Khozeima
June 8, 2011 at 8:34 amHello
i have tried setting this up locally with cassandra-0.8.0 but i keep getting the following even though i have got cassandra up and running and see the keyspaces
======================================================================
Cannot read, Remote side has closed
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Thrift.Transport.TTransportException: Cannot read, Remote side has closed
Source Error:
Line 29: RegisterRoutes(RouteTable.Routes);
Line 30:
Line 31: AquilesHelper.Initialize();
Line 32: }
Line 33: }
Chaker
June 8, 2011 at 10:22 amHello Khozeima,
I didn’t test Chirper with the latest Cassandra version.
Try updating the Aquiles library and see how it goes. You can fork the project and pull back your updates. I’ll be happy to integrate them.
dynamik
December 1, 2011 at 4:54 pmI am having the same problem as Khozeima, although I got the latest Aquiles lib 1.0.0