Giter VIP home page Giter VIP logo

assassin's Introduction

ASSASSIN

GitHub license GitHub license1 GitHub license GitHub license2 GitHub license31 GitHub license3 GitHub license4 GitHudk

Background

Usage

Why do we need a new database?

  • No existing decentralized databases are compatible with web workers.

What are web workers?

  • You can outsource JavaScript to web workers.
  • Web workers allow you to run multi-threaded JavaScript.
  • When you run JavaScript in parallel to the main thread, the main thread is free to respond to user input.

Can you explain web workers with a picture?

You can see in the diagram that without web workers (that's the "before" part of the picture), the main thread has to finish processing all JavaScript before responding to user input. With the use of web workers (that's the "after" part of the picture), the main thread can send JavaScript to web workers and then focus on updating the UI.

web worker diagram

Features ๐Ÿ’ฅ

๐Ÿ’ซย  Lightweight: Shipped with less than 100 lines of client side code.

โš–๏ธย  Decentralized: Your database has no single point of failure. If the server goes down, your data is easy to retrieve.

โœจย  Works in private browsing: I researched databases like LevelDB, PouchDB, and Gun, which rely on IndexedDB for client-side storage. I wanted these databases to be effective, but I ended up creating this database partly because IndexedDB is disabled in private browsing, which means none of these databases work for me.

Methods:

  • killer.connect(url) - Connect to the server. url refers to the url of the server. You put the server's url into this this function.
  • killer.create(key,value) - Add an entry to the database.
  • killer.update(key,new value) - Update the value of a key in the database.
  • killer.delete(key) - Delete an entry in the database.
  • database - Inside the main thread, you can always access the database through the variable called database.

Get Started: Server

First, you need to make a fly.io account. If you haven't already installed Docker, install it and have the daemon running while you deploy your server. To deploy your server, type this in your terminal and hit "Enter" after the end of each line.

shell

You can copy and paste:

cd /path/to/where_you_want_this_to_be_stored
git clone https://github.com/genderev/assassin_server.git
cd assassin_server
flyctl init
flyctl deploy

You can also deploy your server to buddy.works or begin.com on your own, if you want.

Get Started: Browser

You can save this file or you can clone this repo and use assassin.js in the dist folder. assassin.js goes inside the web worker that the main thread posts messages to. You can see an example of how to do this in the source code for the demo.

Architecture:

  • Data Model: Assassin is a key/value store that supports mapping a key to its corresponding value.
  • System Architecture: The DAT protocol distributes and hosts data between many computers, so there is no one location where data is stored. Assassin relies on the the DAT protocol for data persistence. The metadata of the key-value pairs are stored in a distributed trie structure.
  • Isolation Levels: The isolation level is determined by the end user of the database. Assassin is designed to have a low isolation level.
  • Storage Model: Assassin sends data to the server, which then stores the metadata in the distributed file system Hyperdrive, which is built on the DAT protocol. The data itself is distributed and hosted between multiple peers.

Why is it called Assassin?

  • My website currently uses the Gun database.
  • Gun has many features I like and the founder is pretty nice.
  • Gun stopped working for me.
  • Gun's storage adapter RAD relies on IndexedDB, which is disabled in private browsing.
  • Gun syncs data peer to peer through WebRTC, which doesn't function in web workers.
  • Assassin is sort of (seriously, very little) like Gun but for web workers.
  • Gun + worker = Assassin ๐Ÿ’ฅ

Demo ๐Ÿš€

https://assassin-demo.surge.sh

Built with ๐Ÿ”ง

  • Hyperdrive - Thanks for the abstraction layer on top of DAT!
  • HTML - For creating the web demo
  • CSS - For styling the web demo
  • JavaScript - For logic
  • Node.js - To serve the logic

Make sure to share your opinion in:

And if you really want to help make Assassin better, make a pull request! I really want to Assassin to have these things, so make a pull request showing how to add them:

  • User authentication

Assassin is open source, and always will be.

Support me on:

Star the repo, Tweet, and share among your friends, teams and contacts!

assassin's People

Contributors

beginci avatar genderev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

assassin's Issues

[bug] - Example update key duplication

Hi ๐Ÿ‘‹

I discovered the project recently via dev.to, and it seems really cool!
I figured a little problem about the demo: the update part seems to duplicate the key

https://i.imgur.com/okVAtSX.png

I guess it's not a normal thing, so I report you this bug ๐Ÿ˜„

Anyway, great job for your project!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.