title: Using git repository as a database backend
body: <p>I'm doing a project that deals with structured document database. I have a tree of categories (~1000 categories, up to ~50 categories on each level), each category contains several thousands (up to, say, ~10000) of structured documents. Each document is several kilobytes of data in some structured form (I'd prefer YAML, but it may just as well be JSON or XML).</p>
  
  <p>Users of this systems do several types of operations:</p>
  
  <ul>
  <li>retrieving of these documents by ID</li>
  <li>searching for documents by some of the structured attributes inside them</li>
  <li>editing documents (i.e. adding/removing/renaming/merging); each edit operation should be recorded as a transaction with some comment</li>
  <li>viewing a history of recorded changes for particular document (including viewing who, when and why changed the document, getting earlier version - and probably reverting to this one if requested)</li>
  </ul>
  
  <p>Of course, the traditional solution would be using some sort of document database (such as CouchDB or Mongo) for this problem - however, this version control (history) thing tempted me to a wild idea - why shouldn't I use <code>git</code> repository as a database backend for this application?</p>
  
  <p>On the first glance, it could be solved like this:</p>
  
  <ul>
  <li>category = directory, document = file</li>
  <li>getting document by ID => changing directories + reading a file in a working copy</li>
  <li>editing documents with edit comments => making commits by various users + storing commit messages</li>
  <li>history => normal git log and retrieval of older transactions</li>
  <li>search => that's a slightly trickier part, I guess it would require periodic export of a category into relational database with indexing of columns that we'll allow to search by</li>
  </ul>
  
  <p>Are there any other common pitfalls in this solution? Have anyone tried to implement such backend already (i.e. for any popular frameworks - RoR, node.js, Django, CakePHP)? Does this solution have any possible implications on performance or reliability - i.e. is it proven that git would be much slower than traditional database solutions or there would be any scalability/reliability pitfalls? I presume that a cluster of such servers that push/pull each other's repository should be fairly robust &amp; reliable.</p>
  
  <p>Basically, tell me <em>if</em> this solution will work and <em>why</em> it will or won't do?</p>