Database written in JavaScript, Open Source Firebase

290 views
Skip to first unread message

Mark Nadal

unread,
Jul 27, 2015, 5:22:03 PM7/27/15
to js-tools
Hey everyone! Brand new here.

There are a bunch of javascript databases out there if you google around:

 - http://pouchdb.com/

However most of these do not handle versioning, concurrency, conflict resolution, or synchronization - with the exception of pouchdb, pouchdb does.

I had previously spent 5 years doing R&D on synchronization systems and concurrency, so I thought I would give a stab at it. Here is a couple things I did differently:

 - Realtime, like Firebase all updates happen live. In other databases you have to constantly poll for new data, which is kinda of annoying. Recently RethinkDB and PostgreSQL have moved to a push based model, but they aren't written in javascript so you still have to get the browser to speak their protocol. 

 - Offline, like PouchDB it will resync your data when the browser comes back online and it also handles resolving conflicts. I had had nightmares dealing with MongoDB versioning and doing crazy cache invalidation stuff, but moving to a deterministic conflict resolution model cleaned things up quite a bit, and now I don't even use MongoDB any more - just gun in nodejs and in the browser.

 - Decentralized or Peer-to-Peer, like BitTorrent all the data is fully distributed and requires no Master-Slave(-prone-to-failure) setup. There are very few databases out there like this, Riak and Cassandra with CRDTs come close. Because I designed the concurrency model right with the offline approach, I get Master-Master architecture for free and it is really awesome - check out the demo link below.

 - Embedded, into the browser and nodejs, not in the hardware sense. This one is actually really important, because you do not have to run a separate database server and worry about scaling it - which was always the bottleneck of my MongoDB use. Instead, all you have to do is linearly add more app servers to handle user load, and as you do that gun automatically scales up!

- Graph, like regular old javascript objects. I had gotten too many "TypeError: Converting circular structure to JSON" and I was generally frustrated with not being able to have relational data that I decided to go with graphs. This gave me the opportunity to support key/value, documents and relations all together, since any tree (documents) or matrix (tables) can be represented by a graph.

These things were what drove me to build http://gunDB.io/ a completely Open Source database implemented entirely in JavaScript. It is what I think is the "Grand Unifying Theory" of database architecture design.

Really hope you guys like this new tool and would love to hear feedback! I've been working on a bunch of documentation and tutorials:

 - Source and repo: https://github.com/amark/gun
 - Getting started, ToDo App tutorial: http://gun.js.org/web/think.html
 - Getting started, Chat App tutorial: http://gun.js.org/web/converse.html

Overall, I'd love for this thread to be a discussion on javascript databases in general but of course want to hear people's feedback on mine.

Cheers!

 ~ Mark
Reply all
Reply to author
Forward
0 new messages