A user-owned database. Just for eweπŸ‘

Overview

eweserdb

πŸ‘ πŸ‘ πŸ‘ EweserDB, the user-owned database πŸ‘ πŸ‘ πŸ‘

Matrix

A User owned database

EweserDB empowers developers to quickly create a cloud-synced, local-first, user-owned database, like a decentralized firebase.

Built using matrix-crdt Demo link

features:

  • user owned
  • interoperable between apps
  • real-time sync between devices
  • real-time collaboration
  • no backend code
  • strongly typed schemas
  • extensible
  • local-first (coming soon)
  • full end to end encryption (coming soon)

Motivation

Current paradigm:

You ask the app: Can I see my data? e.g.

You ask Facebook: Can I see my friends list, please?

User-owned data paradigm:

The app asks you: Can I see your data? e.g.

Facebook asks you: Can I see your friends list?

This flipping of the ownership dynamic enables some important features:

  • Users can leave the platform at any time and take their data with them to a new one with no loss.
  • Apps cannot survive purely on vendor lock-in or network effects and must instead compete to provide the best experience for users.
  • Third party apps can build new features and use your data in new innovative ways without relying on the first app's permission, or on them maintaining an API.
  • Data changed in the user-owned database by one app will sync to other apps.
  • Users can decide to give apps access to only certain parts of their data, and some parts can be read only.
  • Users can get started or try out a new app with all their data ready, no onboarding, and able to enjoy all the features of the new app right away.

Get Started

For react apps:

npm install @eweser/db @eweser/hooks

and also our dependencies (currently not bundled, but could be based on feedback/user preference)

npm install @syncedstore/core @syncedstore/react matrix-crdt matrix-js-sdk

This is a simplified demo. For a more complete working version with typescript see e2e/example/src/App.tsx

// main.tsx
import { DatabaseProvider } from '@eweser/hooks';
// wrap your app in the DatabaseProvider
<DatabaseProvider>
  <App />
</DatabaseProvider>;
import { DatabaseContext, CollectionProvider, CollectionContext } from '@eweser/hooks';

const App = () => {
  const { db, loginStatus, login } = useContext(DatabaseContext);
  // call `login()` and then:
  if (loginStatus === 'ok')
    return (
      <CollectionProvider
        db={db}
        name="Notes Collection 1"
        aliasKey="default-notes-collection"
        collectionKey="notes"
      >
        <Internal />
      </CollectionProvider>
    );
};
const Internal = () => {
  const { store } = useContext(CollectionContext);
  const notes = store.documents;
  // do something with the documents
  // you can edit the documents object directly and they will sync to the remote database.
  // open in two browsers to see!
};

Features

Structure

See /examples/dbShape.ts for how the data is structured.

Like MongoDB, EweserDB has documents and collections. In SQL database terms, collections are like tables and documents like rows. Each collection can have only one document. Documents have a strict schema(typescript type). See examples of documents in the /collections folder.

documents can be linked by reference using the document's _ref property. The ref is simply the <collection-name>.<room-id>.<document-id>

Rooms

Each room corresponds to a Matrix chat room that will be created on the user's Matrix account inside a space called "My Database". Rooms in EweserDB are private (invite-only) and (coming soon) will be fully end to end encrypted by default.

The registry is a special collection that stores the addresses(roomAliass) to all of the user's other rooms.

ACL - Access Control, Privacy and Sharing

Building on top of Matrix allows for advanced ACL features right out of the box. All ACL happens on the room level. Users can decide which apps or other users have read or write access to which rooms simply by using Matrix's built in privacy control features and by inviting or kicking out other users in the room. The exact mechanics for how to achieve this are still being worked out. See "App development strategy, user consent" below.

User owned

Matrix currently is a 'federated' system, working towards 100% user-owned and decentralized. When a user signs up to the DB they must provide a Matrix homeserver url. The user's data lives on the home server so at first glance it appears that the server owns the data and this is no different than facebook servers owning/controlling the data.

The first big difference is that users can sign up using a self-hosted homeserver or a homeserver of their choice that they trust more.

Another key distinction is that with end to end encryption enabled (coming soon), the homeserver cannot read any of the data.

Thirdly, because of Matrix's federated model, users could have a second homeserver that connects to each of their rooms, and their data would be stored on both, decreasing centralized control.

EweserDB also plans to increase user ownership by making backing up and restoring the user's data easy and automatic. Backups could be through a traditional provider like dropbox or web3 options like IPFS (through pinata) or Ethereum (through swarm).

Extending the Database and Collections

Say you'd like to add a new collection or document type, like TodoItem, or BlogPost etc. Either you'd like it to be only accessible by your app, or to other apps that use eweser-db as well.

To make the collection usable by other apps, submit a pull request to add the collection types. Follow the examples in the db/src/collections folder.

To only use a document in your app, fork the project and do the same thing, or extend locally and use some //@ts-ignores for the type errors you will encounter.

App development strategy, user consent

As it is designed now, when the user signs in, for the duration of the session it gives read/write access to the full user-owned database. Users should be made aware of this fact. People are already comfortable with an app managing it's own data, but it is another level of trust required in the app to also let it manage data used by other apps. Users need to know the level of trust they are putting in each app when they sign ing.

Because user-owned data flips the current data storage paradigm on its head, app developers might be wondering how to share public data between users. For example, a user might mark a certain collection of notes as public and apps could aggregate them and let other users search and discover those.

One solution would be to add a matrix account of the app as an observer to the rooms(collections) the user has marked as public, update a traditional database as the updates happen. But this might not scale very well if the app needs to listen to thousands/millions of collections.

Another option would be to simply use a traditional database for public collections, but then that would break interoperability between apps.

This is an area that needs further consideration. Community input is appreciated.

Limitations

  • Matrix events size limit
  • connecting to rooms can be slow depending on the homeserver, especially the getRoomIdForAlias call when the homeserver has many rooms it needs to search through.

Contribute and develop

  • Make an app with EweserDB and provide feedback. We can make an 'awesome-eweserdb' list of interoperable apps that use it.
  • Submit a pull request to add (for example):
    • a new collection type to the db package.
    • a new e2e test to the e2e package.
    • a new example app to the example package.
    • a new feature to the db or hooks package.
    • something from the to do list below.

Set up local dev

lerna bootstrap && npm install && npm run build npm run dev

The example app is in packages/e2e/example It will be served at http://localhost:5173/

npm run dev-e2e will run the tests in packages/e2e and open cypress.

Unit tests are rather limited at the moment, but you can run them with npm run test.

End to end tests are more practical for this project because so much of the functionality is dependent on the live matrix server.

To Do

  • Helper functions like getRegistry, getRoom, getRef
  • Cross-collection refs, document linking and lookup
  • "Joins" or aggregation searches across collections. e.g. select all documents in the notes collection that have a ref to a document in the flashcards collection.
  • Backups - add storage account (dropbox, pinata, etc)
  • File storage - add storage account links in the document to the files.
  • Offline mode.
  • E2E encryption
  • Sharing, and public collections
  • Per-App Access control. Instead of signing in the matrix client as the user, we could instead sign in with a Matrix account provided by the app owner, and then have the use invite that account into each room, specifying read-only or write permissions.
  • Stress testing. warnings about room or document size limits
  • Tests. Always more tests.

flesh out example:

  • make a note editor with basic CRUD
  • design a UI for grouping collections(rooms) of notes
  • make flashcard app.
  • connect data from 2 apps with refs. e.g. in a note, click 'turn into flashcard' and it creates a flashcard in the flashcard app and links to it in the note.
You might also like...

This project entails a To-do-List whereby a user can input the tasks they want to do, check the tasks done and also clear all tasks when all of them are completed. It is efficient for a user who want to manage their time and keep track of their day.

This project entails a To-do-List whereby a user can input the tasks they want to do, check the tasks done and also clear all tasks when all of them are completed. It is efficient for a user who want to manage their time and keep track of their day.

Screenshot Here is a screenshot for the project. To-Do-List Project This is a Microverse project that entails a to-do-list which one is able to add an

Jun 16, 2022

This project is a user friendly project that provides the accurate constellation name of the user

This project is a user friendly project that provides the accurate constellation name of the user

OVERVIEW: This is a group project by certain members of the 100Devs community. Contributors Lee Gill | GitHub: LeeGee64 | Twitter: @LeeGee64 | LinkedI

Jun 15, 2022

A live instant messaging app that translates user messages into the other user's preferred language.

BabelFish Description BabelFish is an interactive multi-person chat app with built in live translation. It is created using the MERN stack (MongoDB, E

Jul 18, 2022

A Minimalist to do list website where user can add, remove and edit multiple tasks and All the changes user makes in his to do list is saved in browser local storage so that it can be accessed later.

Testing for Add Remove function in To Do List App Jest framework is used for testing. Created (addremove.test.js) for a file containing the add item a

Aug 15, 2022

AweSome Book App displays the book details entered by user and saves the information in Local storage. User can add and remove a book title/author to the library and from the library.

Awesome Book App with ES6 Used npm init -y command to create package.json file. Created the entry point for the JavaScript code called index.js Create

Aug 15, 2022

Food Delivery APP is a website designed to provide interactive user experience and increase user engagement when ordering food delivery.

Food-Delivery-APP Features Food Delivery APP is a website built with HTML/Tailwind CSS/JavaScript, React and enhanced with 3D design using Spline to p

Oct 6, 2022

Tampermonkey script which adds the ability to add a user-defined label/tag/flair on a user, shown throughout Hacker News.

Hacker News User Tags Hacker News User Tags is a Tampermonkey userscript which allows the user to associate a custom coloured label/tag on usernames t

Oct 7, 2022
Owner
Eweser DB
User Owned Databse
Eweser DB
Hemsida fΓΆr personer i Sverige som kan och vill erbjuda boende till mΓ€nniskor pΓ₯ flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo fΓΆr kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Import/Export data from and to your database in just few clicks.

Strapi Plugin Import Export Entries Import/Export data from and to your database in just few clicks. Features Import Import data directly from the Con

Baptiste Studer 72 Dec 28, 2022
Share short notes with just a link. No database. No storage!

Patra | Share your notes! You can share short notes with just a link. No database. No storage! write short articles in markdown and share the link! wr

Sharath Kumar 9 Nov 12, 2022
Types generator will help user to create TS types from JSON. Just paste your single object JSON the Types generator will auto-generate the interfaces for you. You can give a name for the root object

Types generator Types generator is a utility tool that will help User to create TS Interfaces from JSON. All you have to do is paste your single objec

Vineeth.TR 16 Dec 6, 2022
Hadmean is an internal tool generator. It is language agnostic, schema driven, extremely customizable, featured packed, user-friendly and has just one installation step.

Hadmean Report a Bug Β· Request a Feature Β· Ask a Question Table of Contents About Quick Demo Motivation Why you should try Hadmean Getting Started Pre

Hadmean 344 Dec 29, 2022
Interplanetary Database: A Database built on top of IPFS and made immutable using Ethereum blockchain.

IPDB IPDB (Interplanetary Database) is a key/value store database built on top of IPFS (Interplanetary File System). Project is intended to be an MVP

turinglabs 8 Oct 6, 2022
Visualize, modify, and build your database with dbSpy! An open-source data modeling tool to facilitate relational database development.

Visualize, modify, and build your database with dbSpy! dbSpy is an open-source data modeling tool to facilitate relational database development. Key F

OSLabs 115 Dec 22, 2022
This project is built with JavaScript, Webpack, HTML & CSS, Leaderboard api. When user clicks on Refresh button it hits the api and responds with the data, The user can also post data to the api

leaderboad Description the project. this project is about the leaderboad i did during Microverse to build a website for adding Data to the API and fet

Emmanuel Moombe 4 May 30, 2022