views:

2690

answers:

5

I've been using the following web development stack for a few years:

java/spring/hibernate/mysql/jetty/wicket/jquery

For certain requirements, I'm considering switching to a NoSQL datastore with an AJAX frontend. I would probably build the frontend with jQuery and communicate with the web application middleware using JSON. I'm leaning toward MongoDB because of more dynamic query capabilities, but am still considering CouchDB.

I'm not sure what to use in the middle. Probably something RESTful? My preference is to stick with Java (or maybe Scala or Groovy) since I'm using tools like Drools for rules and Shiro for security. But then again, I want to pick something that is quick an easy to work with, so I'm open to other solutions.

If you are building ajax/json/nosql solutions, I'd like to hear details about what tools you are using and any pros/cons you've found to using them.

Thanks!

+2  A: 

If you go with CouchDB, you can use CouchApp which is a set of scripts for deploying an application directly to a CouchDB database. In essence, you skip the middleware and use CouchDB's views, lists, and show functions along with clientside JavaScript to implement the whole app. If your app works in this architecture, it's surprisingly refreshing, simple and cool.

Barry Wark
Interesting, thanks! But how is security handled with a solution like this? Users of my system must log in to access data, and then they only can see certain data based on permissions that their account has.
Tauren
CouchApp is cool but I would say it is only for early-stage prototyping and experimentation. You will outgrow it; however it may become a part of your total application.
jhs
So what do others who are using CouchApp do when they outgrow it? From what I can tell, I would outgrow it from the start.
Tauren
Since CouchDB's API is RESTful, you can put any middleware you want in (I've seen successful Ruby and Python lightweight middleware). I'm sure anything that can handle the JSON would be fine.
Barry Wark
+4  A: 
  1. Pick whichever middleware you are most comfortable with.

  2. CouchApp is very experimental at the moment. The main issue is being able to add security to your app without having a standard HTTP pop-up box. This is obviously a big issue for standard web apps.

  3. Try and avoid parsing each DB request in the middleware and rebuilding the query for couchdb. You can make your middleware act like a proxy so most requests are forwarded on without modification. You can also add a security layer in the middlelayer on top of all requests that need authentication.

  4. Pick a middleware/framework with good URL routing capabilities. For example you could route all requests that go to mydomain.com/db/ to couchdb.

andyuk
Very good points, thanks! I fully intend to use your suggestion to have the middleware act as just a proxy.
Tauren
+1  A: 

I've been tinkering with a few. Ultimately, I'd like to move my controller layer of MVC to the jQuery/javascript frontend and use pure JSON/REST to talk with the backend. Though the backend will need strong security and, for my application some ability to do workflow, queries, and rules.

You also might want to look at:

1) Couldkit, which runs on Tokyo Cabinet. Supports JSONQuery and OAuth. Runs on Ruby/Rack may have enough functionality. Loks like a strong REST implementation. 2) Persevere, which is Java based and strongly supported in Dojo. It is REST-ish but also has some RPC type calls. Seems very powerful overall, with server-side java scripting, etc.

I wouldn't mind hearing how you're coming along.

Cheers, Alex

alxross
Thanks! I haven't looked into cloudkit or persevere yet, so I'll spend some time with them. Your requirements are similar, needing security, workflows, rules, etc.I also need i18n and L10n and user-level customizations (themes/layout/etc). Theming can be handled client-side, but I don't want to do i18n on the client. Because my current stack already does much of this, I'm toying with letting it serve i18n'ed html that includes jquery code. The jquery would then function independently using JSON/REST queries via Jersey. Migration from my current implementation might be simpler this way.
Tauren
+2  A: 

Also if you like the idea of JSON/REST and sticking to JavaScript client to server, the newer generation of Persevere's core, Pintura is pure JS JSON/REST framework that is designed specifically to work well with NoSQL DBs.

Kris Zyp
Thanks Kris, I'll check out Pintura.
Tauren
A: 

I wrote a gem called Rack::JSON for exactly this purpose, it acts as a basic REST interface to a MongoDB db. It was inspired by Cloudkit and supports JSONQuery and also runs on Ruby/Rack. It allows you to store and then access/query JSON documents.

olivernn