DEV Community

Roy J. Wignarajah
Roy J. Wignarajah

Posted on • Updated on

ChatCraft Adventures #2

This week, I've started to dip my toes into tarasglek/chatcraft.
This is what I've done so far:

Tech Stack Research

My classmates and I were tasked with doing preliminary research on parts of the tech stack used to develop ChatCraft. I chose to research Cloudflare R2 and WebAssembly. I am still learning about these topics, but below is what I've been able to learn. I appreciate any feedback that would improve my understanding.

Cloudflare R2

R2 is Cloudflare's cloud storage service for unstructured data and is S3-compatible (compatible with the AWS S3 API). This allows customers/businesses to migrate to/from AWS S3 and other cloud vendors that sell S3-compatible storage.

Why use R2?

As I understand, R2's main selling point is that it doesn't charge egress fees. Egress traffic refers to accessing data stored in an S3 bucket. This includes things like downloading files from an S3 bucket and streaming/distributing media hosted on an S3 bucket. Other cloud vendors like AWS put a charge on egress traffic, called egress fees. Egress fees can be hard to track, which can lead to unexpected costs for clients. R2's lack of egress fees makes it a popular S3-compatible storage solution.

Uses in ChatCraft

For ChatCraft, knowing about R2 is important because ChatCraft uses Cloudflare R2 buckets. During development, a local version of Cloudfare (and of other backend services) can be launched by using pnpm:

pnpm dev-functions
Enter fullscreen mode Exit fullscreen mode

WebAssembly (WASM)

WebAssembly is an assembly-like language that runs on web applications and a compilation target for low level programming languages like C++ and Rust. This is important because it means web developers can write high performance programs in languages like C++, compile them to WASM, and then run those programs on web applications with near-native speeds.

Why learn/use WASM?

Historically, web applications were primarily written in JavaScript. JavaScript fulfills many use cases on the Web today, but some computationally-intensive use cases, like video editing and computer vision, require high-performance (fast speeds). Additionally, mobile devices and other resource-constrained platforms require high-performance programs to provide value to their users.

WASM allows web developers to create high-performance programs for these use cases and devices.

How to use WebAssembly

MDN Web Docs recommends four ways to use WebAssembly:

  • Write WebAssembly from scratch
  • Port a C/C++ application with Emscripten
  • Make a Rust program and target WebAssembly as output
  • Write AssemblyScript and compile to WebAssembly

Uses in ChatCraft

Currently there are no explicit uses of WASM in ChatCraft. However, WASM presents opportunities to add computer-intensive functionalities that would run in the browser.

Contributions

This week I've been exploring ways to use WebAssembly in ChatCraft. There are some libraries or tools we may want running on ChatCraft (and in the browser by extension), and compiling these libraries to WASM might be one way to do this. However, this might be a few weeks away. For now, I've been able to update secrets decryption documentation.

Secret OPerationS (sops)

ChatCraft uses sops to store and share secrets. When installing ChatCraft on my local machine, I noticed the decryption instructions did not work for me. After working with my instructor I was able to decrypt my key and update the documentation. More details on this is available on my Pull Request.

Next steps

In the next week, I hope to learn more about WASM and to fix more issues in ChatCraft.

Top comments (0)