Assassin ⚡️ - An open source, free database for killing slow webpages 
Tags: webdev, webperf, javascript, showdev
Published: 2020-09-06 17:51:43



<center><h1> <a href="https://github.com/genderev/assassin"><strong>Assassin</strong></a> ⚡️ - kill slow webpages </h1>


<h3><strong>Assassin works to kill database transactions that block the UI.</strong></h3>

Database operations can be slow, but no existing databases solve this problem the obvious way: outsource difficult tasks to <a href="https://dev.to/g33konaut/javascript-in-parallel-web-workers-explained-5588">web workers</a>. </center>

<img alt="diagram" src="https://dev-to-uploads.s3.amazonaws.com/i/5jfybjca16hapciysn28.png">

 

<hr>

I wanted to make a database that is:

- Open source
- Responsive
- Decentralized
- Optimized for web workers
- Designed for private browsing

<strong>That's why I created my own database with JavaScript.</strong>

<h3>
  Features 💥
</h3>

<p>💫&nbsp;<strong> Lightweight</strong>: Shipped with less than 100 lines of client side code. </p>

<p>⚖️&nbsp;<strong> Decentralized</strong>: Your database has no single point of failure. If the server goes down, your data is easy to retrieve. </p>

<p>💎&nbsp;<strong> Works in private browsing</strong>: I researched databases like LevelDB, PouchDB, and Gun, which rely on <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> for client-side storage. I wanted these databases to be effective, but I ended up creating this database partly because <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> is disabled in private browsing, which means none of these databases work for me. </p> 

<p><strong>Methods:</strong></p>

<ul>
<li>
<code>killer.connect(url)</code> - Connect to the server. </li>
<li>
<code>killer.create(key,value)</code> - Add an entry to the database.</li>
<li>
<code>killer.update(key,new value)</code> - Update the value of a key in the database.</li>
<li>
<code>killer.delete(key)</code> - Delete an entry in the database.</li>
<li>
<code>Read the database</code> - Inside a web worker or the main thread, you can access the database through the variable called <code>database</code>. </li></ul>

<h3>Architecture:</h3>

<ul>

<li><strong>Data Model</strong>: Assassin is a key/value store that supports mapping a key to its corresponding value. </li>

<li><strong> System Architecture</strong>: 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 <a href="https://dev.to/salonix__/trie-data-structure-2jml">trie</a> structure.</li>

<li><strong>Isolation Levels</strong>: The isolation level is determined by the end user of the database. Assassin is designed to have a low <a href="https://en.wikipedia.org/wiki/Isolation_(database_systems)">isolation level</a>.</li>

<li><strong>Storage Model</strong>: Assassin sends data to the server, which then stores the metadata in the distributed file system <a href="https://github.com/hypercore-protocol/hyperdrive">Hyperdrive,</a> which is built on the DAT protocol. The data itself is distributed and hosted between multiple peers.</li>

<li><strong>Highly Available</strong>: Assassin is highly available and eventually <a href="https://en.wikipedia.org/wiki/CAP_theorem">consistent</a>. Assassin always saves the last edits made to the database when conflicts arise. This <a href="https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type">CRDT</a> may change later.</li>

</ul>

<h3>Why is it called Assassin?</h3><ul>
<li>My personal website currently uses the <a href="https://gun.eco/">Gun</a> database.</li> <li> Gun has many features I like and the founder is pretty nice. </li><li> <strong>Gun stopped working for me.</strong></li> 
<li>Gun's  storage adapter <a href="https://gun.eco/docs/RAD">RAD</a> relies on IndexedDB, which is <strong>disabled in private browsing</strong>. </li><li>Gun syncs data peer to peer through WebRTC, which <strong>doesn't work in web workers.</strong></li>
<li>Assassin is sort of (seriously, very little) like Gun but for web workers.</li><li> <strong>Gun + worker = Assassin</strong> 💥 </li></ul>


<h4>
  Built with 🔧
</h4>

<ul>
<li>
<a href="https://github.com/hypercore-protocol/hyperdrive">Hyperdrive</a> - Thanks for building an abstraction layer on top of the DAT protocol!</li>
<li>HTML - For creating the web demo</li>
<li>CSS - For styling the web demo</li>
<li>JavaScript - For logic</li>
<li>
<a href="https://nodejs.org">Node.js</a> - To serve the logic</li>
</ul>

<h3>Make sure to share your opinion on:</h3>

<ul>
<li>the Assassin <a href="https://github.com/genderev/assassin">GitHub repository</a>
</li>
<li>the <a href="https://gitter.im/assassindb/community">Gitter server</a>
</li>
</ul>
     
<p>And if you really want to help make Assassin better, contribute to the <a href="https://github.com/genderev/assassin">GitHub repo</a>!</p>

<p><strong>Assassin is open source, and always will be.</strong></p>

<h3>
  <strong>Support me on:</strong>
</h3>

<ul>

<li><strong><a href="https://ko-fi.com/assassindb">Ko-Fi</a></strong></li>


</ul>

<p>Star the <a href="https://github.com/genderev/assassin">repo on GitHub</a>, <a href="href=https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2Fgenderev%2Fassassin&text=Assassin%20works%20to%20kill%20slow%20database%20transactions.">Tweet</a>, and share among your friends, teams and contacts!