GUN

Gun is an open-source and realtime, decentralized, offline-first, graph database engine written in JavaScript. It is designed to be small and simple for fast data synchronization which runs everywhere JavaScript is supported. Gun is a fully distributed database aiming at scaling web application and correctly synchronizing data among devices with offline-first feature.

History

Gun was built by Mark Nadal in 2014. He spent 4 years researching scaling up his web application, and eventually he found out it was hard with traditional databases or Master-Slave databases because of one big bottleneck, and decided to create Gun, a P2P database which can run on any browsers.

Data Model

Graph

Gun uses graph to represent data and data relations. A logical graph in Gun is denormalized into a subset of JSON files.

Logging

Not Supported

Query Interface

Custom API

Gun provides custom API for query interfaces. Some other choices are also available including GraphQL and SPARQL.

System Architecture

Shared-Disk

Compression

Prefix Compression

Gun uses radix tree to store user data in memory, and it also uses it for persistent storage by default. Gun also supports third party persistent storage service like Amazon S3, so data compression can be done outside of Gun.

Query Compilation

Not Supported

Checkpoints

Not Supported

Indexes

Patricia/Radix Trie

By default, Gun uses the Radisk Storage Engine as an in-memory and on-disk radix tree to store user data. Gun supports some existing persistent storage services like S3 to be plugged in, and also offers interfaces for developers to build persistent layer for it, so indexing can be flexible.

Isolation Levels

Snapshot Isolation

Gun allows offline usage and synchronizes data when online with eventual consistency. Each user has their own copy of data when using. Conflicts are handled by Hypothetical Amnesia Machine (HAM) when presented during synchronization.

Foreign Keys

Not Supported

GUN Logo
Website

http://gun.js.org/

Source Code

https://github.com/amark/gun

Tech Docs

https://gun.eco/docs/

Developer

Mark Nadal

Country of Origin

US

Start Year

2014

Project Type

Commercial, Open Source

Written in

JavaScript

Supported languages

JavaScript

Operating Systems

Linux

Licenses

Apache v2