---
title: "JavaScript filesystem database"
date: 2010-12-21
description: "I couldn’t resist and, after many conversations with Mário Valente, I challenged myself to build a complete JavaScript filesystem based database from scratch. In short, something like CouchDB but …"
---


I couldn't resist and, after many conversations with [Mário Valente][1], I challenged myself to build a complete JavaScript filesystem based database from scratch. In short, something like [CouchDB][2] but written in JavaScript and using a filesystem approach for document storage.

Some characteristics of this new database system:

- fully written in JavaScript: [nodeJS][3] is my choice for its architecture and portability;
- every document must contain only [JSON][4] data;
- every document can be manipulated on the filesystem: the idea is to allow someone to edit a document using [vim][5], for instance, without breaking anything. It also lets you easily backup, move or replicate your data without creating a heavy load on the database;
- the underlying filesystem can be changed: changing the underlying filesystem offers numerous possibilities, like easy distribution (using [OpenAFS][6], [XTREEMFS][7] or others), replication (using [finefs][8] or others), and even attaching different backends (using [FUSE][9], for example);
- the system must be available through an HTTP [REST][10] interface: this makes it very easy to immediately integrate the system into any existing applications. Bonus points if the API is compatible with CouchDB;
- queries must be performed using a [MapReduce][11] approach: this should make it very easy to perform queries on a large dataset.

So, right now I'm half way through it. I managed to write the backend and I'm on my way to the HTTP REST interface. I'll create a github repo after I have something functional that can be easily built and tested.

What do you think of a system like this? Any features you'd like to add or change?

[1]: http://mvalente.eu/ "Mário Valente"
[10]: http://en.wikipedia.org/wiki/Representational_State_Transfer "REST"
[11]: http://en.wikipedia.org/wiki/MapReduce "MapReduce"
[2]: http://couchdb.org "CouchDB"
[3]: http://nodejs.org/ "nodeJS"
[4]: http://www.json.org/ "JSON"
[5]: http://www.vim.org/ "vim"
[6]: http://www.openafs.org/ "OpenAFS"
[7]: http://www.xtreemfs.org/ "XTREEMFS"
[8]: http://code.google.com/p/finefs/ "finefs"
[9]: http://fuse.sourceforge.net/ "FUSE"
