• Stars
    star
    8,258
  • Rank 4,474 (Top 0.09 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Peer-to-Peer Databases for the Decentralized Web

OrbitDB

Matrix npm version node

OrbitDB is a serverless, distributed, peer-to-peer database. OrbitDB uses IPFS as its data storage and Libp2p Pubsub to automatically sync databases with peers. It's an eventually consistent database that uses Merkle-CRDTs for conflict-free database writes and merges making OrbitDB an excellent choice for p2p and decentralized apps, blockchain applications and local-first web applications.

Test it live at Live demo 1, Live demo 2, or P2P TodoMVC app!

OrbitDB provides various types of databases for different data models and use cases:

  • log: an immutable (append-only) log with traversable history. Useful for "latest N" use cases or as a message queue.
  • feed: a mutable log with traversable history. Entries can be added and removed. Useful for "shopping cart" type of use cases, or for example as a feed of blog posts or "tweets".
  • keyvalue: a key-value database just like your favourite key-value database.
  • docs: a document database to which JSON documents can be stored and indexed by a specified key. Useful for building search indices or version controlling documents and data.
  • counter: Useful for counting events separate from log/feed data.

All databases are implemented on top of ipfs-log, an immutable, cryptographically verifiable, operation-based conflict-free replicated data structure (CRDT) for distributed systems. ipfs-log is formalized in the paper Merkle-CRDTs. You can also easily extend OrbitDB by implementing and using a custom data model benefitting from the same properties as the default data models provided by the underlying Merkle-CRDTs.

Project status & support

  • Status: in active development
  • Compatible with js-ipfs versions >= 0.66.0 and go-ipfs versions >= 0.17.0

NOTE! OrbitDB is alpha-stage software. It means OrbitDB hasn't been security audited and programming APIs and data formats can still change. We encourage you to reach out to the maintainers if you plan to use OrbitDB in mission critical systems.

This is the Javascript implementation and it works both in Browsers and Node.js with support for Linux, OS X, and Windows. Node version 16 is supported.

A Go implementation is developed and maintained by the Berty project at berty/go-orbit-db.

Table of Contents

Usage

Read the GETTING STARTED guide for a quick tutorial on how to use OrbitDB.

For a more in-depth tutorial and exploration of OrbitDB's architecture, please check out the OrbitDB Field Manual.

Module with IPFS Instance

If you're using orbit-db to develop browser or Node.js applications, use it as a module with the javascript instance of IPFS

Install dependencies:

npm install orbit-db ipfs
import IPFS from 'ipfs'
import OrbitDB from 'orbit-db'

;(async function () {
  const ipfs = await IPFS.create()
  const orbitdb = await OrbitDB.createInstance(ipfs)

  // Create / Open a database
  const db = await orbitdb.log("hello")
  await db.load()

  // Listen for updates from peers
  db.events.on("replicated", address => {
    console.log(db.iterator({ limit: -1 }).collect())
  })

  // Add an entry
  const hash = await db.add("world")
  console.log(hash)

  // Query
  const result = db.iterator({ limit: -1 }).collect()
  console.log(JSON.stringify(result, null, 2))
})()

Module with IPFS Daemon

Alternatively, you can use ipfs-http-client to use orbit-db with a locally running IPFS daemon. Use this method if you're using orbitd-db to develop backend or desktop applications, eg. with Electron.

Install dependencies:

npm install orbit-db ipfs-http-client
import { create } from 'ipfs-http-client'
import OrbitDB from 'orbit-db'

const ipfs = create(new URL('http://localhost:5001'))

const orbitdb = await OrbitDB.createInstance(ipfs)
const db = await orbitdb.log('hello')
// Do something with your db.
// Of course, you may want to wrap these in an async function.

API

See API.md for the full documentation.

Database browser UI

OrbitDB databases can easily be managed using a web UI, see OrbitDB Control Center.

Install and run it locally:

git clone https://github.com/orbitdb/orbit-db-control-center.git
cd orbit-db-control-center/
npm i && npm start

Examples

Install dependencies

git clone https://github.com/orbitdb/orbit-db.git
cd orbit-db
npm install

Some dependencies depend on native addon modules, so you'll also need to meet node-gyp's installation prerequisites. Therefore, Linux users may need to

make clean-dependencies && make deps

to redo the local package-lock.json with working native dependencies.

Browser example

npm install # if not yet installed
make build
npm run examples:browser # if browser isn't opening, open examples/browser/browser.html in your browser

Using Webpack:

npm install # if not yet installed
make build
npm run examples:browser-webpack # if browser isn't opening, open examples/browser/browser-webpack-example/index.html in your browser

Check the code in examples/browser/browser.html and try the live example.

Node.js example

npm run examples:node

Eventlog

See the code in examples/eventlog.js and run it with:

node examples/eventlog.js

Workshop

We have a field manual which has much more detailed examples and a run-through of how to understand OrbitDB, at orbitdb/field-manual. There is also a workshop you can follow, which shows how to build an app, at orbit-db/web3-workshop.

More examples at examples.

Packages

OrbitDB uses the following modules:

OrbitDB Store Packages

Community-maintained Typescript typings are available here: https://github.com/orbitdb/orbit-db-types

Development

Run Tests

npm test

Build

npm run build

Benchmark

node benchmarks/benchmark-add.js

See benchmarks/ for more benchmarks.

Logging

To enable OrbitDB's logging output, set a global ENV variable called LOG to debug,warn or error:

LOG=debug node <file>

Frequently Asked Questions

We have an FAQ! Go take a look at it. If a question isn't there, open an issue and suggest adding it. We can work on the best answer together.

Are there implementations in other languages?

Yes! Take a look at these implementations:

The best place to find out what is out there and what is being actively worked on is likely by asking in the Matrix. If you know of any other repos that ought to be included in this section, please open a PR and add them.

Contributing

Take a look at our organization-wide Contributing Guide. You'll find most of your questions answered there. Some questions may be answered in the FAQ, as well.

If you want to code but don't know where to start, check out the issues labelled "help wanted".

Sponsors

The development of OrbitDB has been sponsored by:

If you want to sponsor developers to work on OrbitDB, please reach out to @haadcode.

License

MIT © 2015-2023 Protocol Labs Inc., Haja Networks Oy, OrbitDB Community

More Repositories

1

orbit

A distributed, serverless, peer-to-peer chat application on IPFS
1,637
star
2

ipfs-log

Append-only log CRDT on IPFS
JavaScript
394
star
3

orbit-web

Orbit Web Application
JavaScript
262
star
4

crdts

A library of Conflict-Free Replicated Data Types for JavaScript
JavaScript
211
star
5

field-manual

The Offical User's Guide to OrbitDB
JavaScript
210
star
6

awesome-orbitdb

Useful resources for using OrbitDB and building projects on it
134
star
7

welcome

☄️💫 The OrbitDB community and documentation repo
95
star
8

orbit-db-control-center

UI for managing OrbitDB databases
JavaScript
85
star
9

orbit-core

Orbit communication protocol and library
JavaScript
70
star
10

orbit-db-cli

CLI for orbit-db
JavaScript
61
star
11

orbit-textui

A prototype terminal client for Orbit
JavaScript
48
star
12

orbit-electron

Orbit Electron App
JavaScript
45
star
13

orbit-db-docstore

Document Store for orbit-db
JavaScript
40
star
14

orbit-db-store

Base class for orbit-db data stores
JavaScript
40
star
15

orbit-db-http-api

A HTTP API Server for the OrbitDB distributed peer-to-peer database
JavaScript
38
star
16

orbit-db-pinner

A pinning service for Orbitdb, a decentralized database based on IPFS.
JavaScript
35
star
17

py-orbit-db-http-client

A python client for the Orbitdb HTTP API
Python
33
star
18

orbit-db-identity-provider

Default identity provider for OrbitDB
JavaScript
32
star
19

orbitdb.org

The website for OrbitDB
HTML
32
star
20

orbit-db-eventstore

Append-Only Log database for orbit-db
JavaScript
30
star
21

go-orbit-db

Go implementation of OrbitDB.
Go
28
star
22

orbit-db-access-controllers

Access Controllers for OrbitDB
JavaScript
27
star
23

orbit-db-kvstore

Key-Value database for orbit-db
JavaScript
26
star
24

orbit-db-types

Unofficial orbit-db typings!
TypeScript
25
star
25

web3-workshop

A workshop showing how to build a basic app using OrbitDB
SCSS
25
star
26

repo-template

A template for creating new repositories in the @orbitdb organization
22
star
27

example-orbitdb-todomvc

TodoMVC with OrbitDB
JavaScript
22
star
28

orbit-db-pubsub

Message propagation module for orbit-db
JavaScript
19
star
29

orbit-db-feedstore

Log database for orbit-db
JavaScript
16
star
30

orbit-db-powergate-io

A bridge between OrbitDB and Powergate, which is itself a bridge between Filecoin and IPFS.
JavaScript
14
star
31

orbit-chat

Deprecated: Rewrite of orbit-web. Go to https://github.com/orbitdb/orbit-web
JavaScript
14
star
32

research

Decentralized Database Research
13
star
33

orbit-db-cache

Local cache for orbit-db
JavaScript
11
star
34

orbit-db-counterstore

Counters database for OrbitDB
JavaScript
10
star
35

orbit-db-keystore

A local key manager for OrbitDB
JavaScript
9
star
36

SCPs

Inbox for proposals to improve OrbitDB
HTML
9
star
37

opentelemetry-plugin-orbitdb

OpenTelemetry Plugin for OrbitDB
TypeScript
8
star
38

orbit-db-storage-adapter

A wrapper for abstract-leveldown compliant stores, used by OrbitDB
JavaScript
8
star
39

example-orbitdb-todomvc-updated

TodoMVC app using OrbitDB
JavaScript
7
star
40

orbit-db-io

Helper module used in OrbitDB to interface with storage layer
JavaScript
7
star
41

localstorage-level-migration

Move items from localstorage to leveldb
JavaScript
6
star
42

orbit-db-polkadot-iam

Identity Provider and Access Controller for Polkadot / Substrate based accounts
JavaScript
5
star
43

ipfs-post

POST prototype for IPFS
JavaScript
5
star
44

.github

Default Community documents
5
star
45

orbit-db-test-utils

Shared test utilities for OrbitDB-related projects
JavaScript
5
star
46

orbit-bot

Bot for Orbit communication network that caches messages
JavaScript
5
star
47

orbitdb-identity-provider-did

Create, sign and verify OrbitDB identities using Decentralized Identifiers (DIDs).
JavaScript
5
star
48

quickstart

A preconfigured instance which allows developers to "test drive" OrbitDB.
JavaScript
5
star
49

benchmark-runner

OrbitDB Benchmark Runner
JavaScript
4
star
50

orbitdb-orbit-crypto

Crypto primitives for Orbit
JavaScript
4
star
51

example-orbitdb-webpack

How to use OrbitDB JavaScript module with webpack
JavaScript
3
star
52

orbit-db-access-controller-store

Deprecated: OrbitDB Access Controller Store
JavaScript
3
star
53

spec

Specifications for implementing the OrbitDB System
3
star
54

logo

🌑 Orbit's brand files, formats and guidelines
2
star
55

orbit-db-community-stats

A script to get stats for the orbitdb GitHub organization
Python
2
star
56

eslint-config-orbitdb

Deprecated: Standard ESLint config for OrbitDB
JavaScript
2
star
57

orbitdb-identity-provider-ethereum

Provides creation and signing of identities using an Ethereum wallet.
JavaScript
2
star
58

examples

Implementing OrbitDB on various Javascript platforms.
JavaScript
2
star
59

orbit-db-http-api-bash-client

A HTTP API client for the OrbitDB distributed peer-to-peer database in bash
1
star