Case Study: A Keybase Live Chat Feed for Chia Network

Overview

Chia Network is a “decentralized open source global blockchain which is less wasteful, more decentralized, and more secure”. It was founded by Bram Cohen, the creator of BitTorrent.

The Challenge

Chia wanted visitors to keep coming back to their website, and it was important that any visitor could stay up-to-date on news about Chia.

  1. Download & install the application.
  2. Join the Keybase group using its chat interface.

Results

The Project

To reduce this friction, we built a custom integration that previews Chia’s #general Keybase channel. It’s robust, mobile-friendly, and the message feed updates in real-time (including emoji reacts!).

Design

  • Frontend: React, React-Markdown, Bootstrap, Socket.IO
  • Backend: Node, Express, Socket.IO, and Keybase.
Architecture diagram of the Keybase Live Feed.

Frontend

We wanted the code to be simple to use, update, and maintain. We went with a time-tested, minimal React stack — only 8 dependencies in total!

  1. Emoji identifiers are based on names from the emoji-datasource NPM package.
  2. Modifiers are also supported — you can write :smile::skin-tone-2: and see the emoji with a different skin tone.

Backend

As of this writing, Keybase doesn’t offer a complete API for their Teams product. It does have endpoints for basic functionality such as identity management.

  1. List of all messages in a conversation/channel.
  2. List of all members of a conversation/channel.
  3. Profile picture of each member of each conversation/channel (for the avatar images).
  1. Metadata Listener: periodically retrieves a lists all members of the team, as well as their profile pictures, maintaining an in-memory team members cache and profile-pictures cache used by the Chat Listener. This only runs a couple times a minute since retrieving all this data is quite expensive.
  2. Socket.IO Listener: listens to incoming connection requests and hands them off to the Socket.IO handler.

Deployment

The live feed was deployed to AWS EC2 instances with Debian images. We set them up with the usual best practices, such as:

  1. Running as a SystemD service (including auto-restart on crash).
  2. Nginx reverse-proxying with Let’s Encrypt for HTTPS (including certificate auto-renewal).
  3. Runbook with step-by-step instructions for common tasks, such as applying updates and viewing logs.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store