SocketCluster. The most underrated framework. Part 1: Intoduction
Tags: javascript, node, socketcluster, opensource
Published: 2021-03-30 19:12:45

# Part 1: An introduction to SocketCluster and its potential

## What is SocketCluster?
SocketCluster is a framework which allows you to use the [WebSocket protocol](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) to transmit between its [backend](https://github.com/SocketCluster/socketcluster) API and [client library](https://github.com/SocketCluster/socketcluster-client). The client can be used both on a backend (E.g. a Raspberry pi) or frontend application.

## What you can expect of these articles
These articles should give you a good insight of how to use a scalable SocketCluster application and how to deploy it to a Cloud service. I will try to keep it beginner friendly for everyone that has knowledge in JavaScript.

## What SocketCluster solves and which applications it can be used for
Unlike REST where there is a learning curve to fully understand the HTTP Protocol or GraphQL where it's needed to learn the fundamentals of schemas, SocketCluster lets you use its framework without actually knowing how sockets work. Nor does it really need to. The framework perfectly handles sockets in a way you just need to transfer data. You can any type of data e.g. objects, strings, buffers, ... It in some way resembles SocketIO. You could say its SocketIO on steroids. It comes with bulkier tools and scalability out of the box. It has prewritten Kubernetes files.

## Its [internals](https://github.com/SocketCluster/writable-consumable-stream)


> **NOTE**
> This is pretty technical and can be skipped.

The latest version of SocketCluster uses the [for await loop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of) which was recently introduced in JavaScript. The internals create queues that consume data asynchronously. Let's take an example where this is useful.

E.g. the EventEmitter in JavaScript might execute a callback twice. A good example is finalizing a delete operation in a SQL Database.

## Projects/companies that use SC
### Lisk
One of the most famous success stories is the Lisk protocol. A cryptocurrency blockchain written in JavaScript using SocketCluster as its peer-to-peer protocol. At the time of writing Lisk is ranked [#99](https://coinmarketcap.com/currencies/lisk/) globally according to Coin Market Cap. Here are [[1](https://github.com/LiskHQ/lisk-docs/blob/1a1a5a105f669f340a4c3a5b0119b1cae3f3e8a9/modules/protocol/pages/network.adoc)][[2](https://github.com/LiskHQ/lips/blob/master/proposals/lip-0004.md)] articles related to SocketCluster on LiskHQ's GitHub.

### Redux dev tools
Another example is Redux dev tools. They use SocketCluster to [remote monitoring](https://github.com/reduxjs/redux-devtools/blob/511c974e639f78cb4406fc4106ecaf4706fa7917/docs/Integrations/Remote.md).

### HarperDB
[Here](https://harperdb.io/blog/using-socketcluster-for-distributed-computing/) you can find an article of their reasons why. The difficulties they had over SocketIO and why SocketCluster was a better fit.

## What we will be building
We will build a full-fledged application which has much resemblance to the current problems in the world, the pandemic. We will build a contact tracing app which in theory should really scale. The technologies we will be using:

- Vue 3 with the Composition API as the frontend
- PostgreSQL as the database
- Knex.js as the query builder

Additionally I'll provide a deeper insight into Vue 3's Composition API as its fairly new technology.