
StackOverflow clone, created entirely with Redis and jQuery - mythz
http://servicestack.net/RedisStackOverflow/
======
antirez
trivia: the real stackoverflow uses Redis as well for caching and to implement
specific functions. I'm very proud of this since I consider stackoverflow one
of the best sites of the whole internet, together with wikipedia and a few
others.

~~~
w1ntermute
> I consider stackoverflow one of the best sites of the whole internet,
> together with wikipedia and a few others.

Though that has more to do with their community & content than their
structure. Of course, SO's structure is part of the reason for its
community/content (though I personally believe Atwood & Spolsky's star status
was more important), but just copying that isn't going to get a similar site a
lot of users or quality content.

~~~
antirez
Sure, when I say stackoverflow I don't just refer to the technology, but the
community, how the site is handled by the founders, the original aims that
resulted in the site, and so forth.

------
jdub
Interesting point from the author (after I asked on the site!)... it was
developed on Windows/.NET and deployed on Linux/Mono. :-)

~~~
aaronblohowiak
Heres the source:
[https://github.com/mythz/ServiceStack.Examples/blob/master/s...](https://github.com/mythz/ServiceStack.Examples/blob/master/src/RedisStackOverflow/RedisStackOverflow.ServiceInterface/IRepository.cs)

------
mattlong
Maybe I'm missing something, but what about this is interesting? Is it that
Redis is the backend? I'm not trying to bash it; I'm genuinely curious.

~~~
antirez
The interesting things are in my opinion that Redis is the sole backend, the
code is simple, and no Redis operation was "forced" to do something that was
not the natural goal. In practice this example shows how the Redis data model
is a natural way to model complex needs without a line of SQL and without any
need to setup indexes or things like that. I think this is a pretty important
point.

Another interesting technical detail is that the whole site uses only an HTML
template and everything else is done via javascript using jquery.

~~~
gaiusparx
Agreed. It also highlights that you don't need an mvc frameworks for web app.
Due to the popularity of framework such as Rails, many assume a framework is
the only way to go. Powerful client JavaScript library is changing how people
develop web apps.

~~~
fredoliveira
Even though you are right and it is certainly not necessary to use an MVC
framework to build a web-app such as this, you'll have to agree that the
thoughts behind using such a framework are important (data/code/interface
separation). But that doesn't mean MVC is a hammer for any nail.

~~~
blasdel
Except that this webapp is absolutely built with an MVC framework — it's just
that the M, V, and C are in different places than they are in the dogmatic
arrangement.

MVC is not a fixed design, it's a legitimate universal _Design Pattern_
(unlike most of the GoF book). It's a shared nomenclature for describing the
arrangement of concerns, not a prescriptive blueprint.

------
ck2
Why not just manipulate the url hash to allow bookmarking and re-generation of
a specific page?

~~~
scorpion032
Like like new twitter, you mean #!

------
jganetsk
Is this meant as a proof-of-concept, or a production system? What is stopping
me from using Firebug to change the client and issue a 'rm -rf /'-esque
command to Redis? Does Redis have some kind of permission checks? Is there
some interesting solution that would provide a thin ACL layer in between the
client and Redis?

~~~
mythz
It's a proof of concept, but at the same time all redis calls for this service
is shielded by strongly-typed web services api (not a free command redis) so
the only commands that are executed is what's allowed - the web services api
would not be any different than if it was backed by an RDBMS.

------
serichsen
Main difference: it does not degrade gracefully. It just doesn't work without
JavaScript activated.

~~~
gnaritas
> Main difference: it does not degrade gracefully.

Who cares, really? The percentage of people who purposefully break their
browsers isn't worth catering to.

~~~
mscarborough
> Who cares, really? The percentage of people who purposefully break their
> browsers isn't worth catering to.

Accessibility. Is there really any reason why a questions/answer site with
voting can't provide noscript tags?

Refactoring ours to deal with that, so not trying to throw stones.

EDIT: I understand mythz's comment about being a play project. i'm just
responding to the 'why break your browser' sentiment.

~~~
tomh-
Why would you provide an implementation with noscript tags? only 0.01% of your
users will probably be affected. These are the users who never click or view
ads anyway, why spent time for them while you could implement more important
features?

------
LiveTheDream
This demo also has a C# middle layer that implements a REST web service and an
ORM; it's not just datastore + client-side javascript app (like CouchApp).

~~~
mythz
Its funny when people use the term 'ORM' when there is no ORM in sight (I know
I do it to :). BTW there is no 'Relational' and no 'Mapping' in the C# Redis
client, For max speed POCO objects are just serialized as JSON or have their
primitive values stored in Redis's Sets/SortedSets.

~~~
LiveTheDream
I said ORM because the github project description says "...built with
ServiceStack, C# RedisClient, OrmLite...". Just realized now that the SO clone
is just one of several sub-projects within that repository, sorry.

------
ithkuil
btw, a similar SO clone: <http://shapado.com/>

------
k33l0r
Pretty cool, but not being able to directly link to questions is a pretty big
downside.

~~~
mythz
Well I just made it as a demo app, not meant to be a competing replacement,
deep-linking would be fairly trivial to implement.

------
VMG
Back button doesn't work

~~~
mythz
Ok due to popular demand I've just added it using HTML5 pushstate/popstate -
should work in modern browsers :)

~~~
rimantas
Give it some CSS3 love too: get rid of that body background image and use box-
shadow, also, download button is trivial to implement in CSS and will degrade
gracefully.

~~~
melling
Can't we come up with a nice way to get people to move to modern browsers? IE6
and IE7 should both fall below 10% this year. With a little prodding IE9 could
become the least supported browser within a year, and IE9 is going to be a
pretty good browser.

------
mkrecny
Nice - it's very responsive : )

------
jschuur
If you're going to pay homage, at least don't take the name too.

~~~
jschuur
On the other hand... It's open source and if it helps people figure out what
it is, then its OK.

------
Charuru
I developed something similar here: <http://hipchan.com>

And why redis? It's definitely the wrong database for the job.

couchdb is indubitably a better choice here.

~~~
Charuru
Please someone explain the downvote.

redis is a k/v store that will force you to write a lot of code to get the
results you want out of it, people use it for purposes like caching, not
storing your main content which you'll want to query in complex ways.

meanwhile couchdb is just more complex enough to make things easier, and it
features database side authentication which will allow you to write full
client side apps, which seems like what this author was going for here.

anyway it just seems to me like couchdb fits the use case here perfectly. when
i wrote hipchan i used mongodb because I had server side code to auth, no bias
here...

~~~
mythz
Can you explain where in the sample code would be beter served by a different
data storage solution with equivalent sample code?

IMHO Redis comp-sci data structures provide elegant and fast solutions to the
requirements of a StackOverflow Q&A site.

~~~
dlsspy
While I didn't make the suggestion initially, I can see where it may have come
from and might be able to expand on it some.

couchdb has a concept called couchapp (think rails for webapps written in
javascript) which allows the entire application from data storage on the
filesystem to presentation in the browser to _only_ require the couchdb
process and the web browser. The data is automatically ready for bidirectional
(or multidirectional) replication anywhere from offline apps to cloud hosting
providers -- all active.

It purports to do for your web application what git did for your application
development -- you can clone just the app from one DB to another, or clone the
entire DB for backups, offline work, or even peer-to-peer production hosting
or web.

I haven't done web apps very much myself in a couple of years, but that's one
area that's a bit tempting for me since the ones I have been interested in
have peer-to-peer data accumulation and offline work + synchronization needs.

~~~
mythz
Sure, so there are a lot of projects like this that does the same for Redis:
ServiceStack has <http://www.servicestack.net/RedisAdminUI/Public/Metadata>
Redis adapters for Nginx: <http://wiki.nginx.org/HttpRedis> and
<https://github.com/agentzh/redis2-nginx-module> Finally there is webdis
<https://github.com/nicolasff/webdis> which is standalone and includes its own
web server

~~~
dlsspy
None of these things are similar to couchapp:

    
    
        * They all require two servers running (redis + a web server)
        * None provides a framework for building an application.
        * None provides n-way replication.
        * None provides offline support.
    

I get that they do mean you can build a web app. The question above was why it
would make sense to use couch instead of redis. The primary answer is because
the database already does most of what you want (including serving the HTML to
the web browser) since it speaks the same language as the eventual client.

~~~
mythz
>They all require two servers running (redis + a web server)

So? separating web service access to the datastore is simply separation of
concerns and just good modular design. A redis hybrid solution is still going
to be faster than Couch.

>None provides a framework for building an application.

There is lua scripting available in some of them and the application fx is
generally on the client.

>None provides n-way replication.

Out-of-the-box Redis supports trivial (as many as slaves as you want)
replication.

>None provides offline support.

eh? wtf?

------
watt
Did they clone the community too? _zing_

~~~
antirez
I think the goal of the author was not to compete with stack overflow, but to
show a programming example.

~~~
watt
Perhaps I am reading the post title incorrectly. What DID they really clone?
Oh, title like "created a Q&A site engine using Redis and jQuery, and styled
it to look a bit like StackOverflow, whoop-de-doo" is not catchy.

Q&A sites are not about the code, they are about the people, asking and
answering the questions. It's nothing without the community.

~~~
rhizome
Q&A sites are certainly _partially_ about the code. UXwise, I'd much rather
use SO than Yahoo Answers.

------
wildster
I think you would need to be very good a C to replicated something like that.

