Comm

repository·master·Indexed 43 days ago

https://github.com/comme2e/comm

An E2E-encrypted messaging application combining private DMs using Double Ratchet/X3DH with a federated community layer hosted on keyservers. The project features a React Native mobile app, a React desktop website, and Rust-based backend services.

Tokens
41.2K
Snippets
164
Records
218
Agent score
56%

What's inside Comm

  1. Overview of Comm architecture and security

    master

    Comm is an E2E-encrypted messaging application that combines Signal-like private messaging with an IRC-like federated community layer.

    Security Model

    • DMs and Group Chats: End-to-end encrypted (E2EE) between devices. This is achieved using pairwise Double Ratchet sessions initiated via X3DH.
    • Communities: Organized as a tree structure of channels. These are hosted on federated, user-run backends called keyservers. Communication with keyservers is encrypted via TLS.
    • Backend Services: Centralized services are written in Rust and are designed to never touch plaintext data.
  2. Understand the Comm repository structure

    master

    The repository is organized into two main monorepos: a Javascript-based monorepo for client apps/keyservers and a Rust-based monorepo for backend services.

    Client & Keyserver (Yarn Workspaces)

    • native: React Native application code (supports iOS and Android).
    • keyserver: Node/Express server code. This acts as the application server for the communities layer and can also serve web and landing content.
    • web: React desktop website code.
    • landing: The Comm landing page.
    • lib: Shared code across workspaces, including the Redux stack used by both native and web.

    Backend Services (Cargo Workspaces)

    • services: Various backend services written in Rust.
    • shared: gRPC and protobuf definitions, along with shared Rust libraries.
  3. Work with a stack of diffs in Phabricator

    master

    A "stack" is a series of related diffs that represent a multi-part change.

    Creating dependencies

    To ensure reviewers see the relationship between diffs in a stack, include Depends on D123 (replacing D123 with the actual diff revision ID) in the commit text of the child commit. You can also specify dependencies via the Phabricator web UI.

    Managing the stack

    It is highly recommended to use git rebase -i (interactive rebase) to manage stacks. This allows you to "diff up" multiple commits at once or amend specific commits in the middle of a stack during the review process.

  4. How Nix manages dependencies in the environment

    master

    Nix installs packages into the Nix store at unique, package-specific paths (e.g., /nix/store/[hash]-clang/bin/clang).

    When you execute nix develop, Nix automatically modifies environment variables, most notably PATH, to expose these binary dependencies to your current shell session. This mechanism allows the environment to support various build toolchains like pkg-config, CMake, and other language-specific package managers without manual path configuration.

  5. Run Node scripts in the keyserver

    master

    To execute scripts located in keyserver/src/scripts, you must first ensure the Node server is running.

    1. Start the server:
    cd keyserver
    yarn dev
    1. Run the specific script from the keyserver directory:
    yarn script dist/scripts/name.js

    (Replace name.js with your target script file).

    cd keyserver
    yarn dev
    # In another terminal
    yarn script dist/scripts/name.js
  6. Work with Phabricator diffs and stacks

    master

    Comm uses Phabricator for code review. Unlike GitHub PRs, a diff corresponds to a single commit.

    • Create a new diff: Run arc diff from the Git repo. It creates a diff for the most recent commit.
    • Update a diff: Amend your commit and run arc diff again. Arcanist uses the Differential Revision: line in the commit text to identify existing diffs.
    • Manage a stack: For multi-part changes, create dependency relationships (e.g., include Depends on D123 in the commit text). Use git rebase -i to manage the stack.
    • Land a diff: Once accepted, run arc land. If you have a stack of unlanded commits, create a new branch containing only the commits you want to land before running the command.
    arc diff
    arc land
  7. Run JSI codegen for React Native

    master

    The project uses JSI (JavaScript Interface) to allow synchronous communication between C++ and JS in React Native. Code is automatically generated from Flow schemas located in native/schema.

    To generate the necessary C++ files from the Flow interfaces, run the following commands from the repository root:

    cd native
    yarn codegen-jsi

    Note: The input schemas must be defined as Flow interfaces that inherit from React Native's TurboModule interface.

  8. Install and Configure MariaDB

    master

    Install MariaDB via Homebrew and configure it to start on boot using brew services.

    1. Install and Start:
    brew install mariadb && brew upgrade mariadb
    brew tap homebrew/services
    brew services start mariadb
    1. Set Root Password:
    sudo mysqladmin -u root password
    1. Initialize Database and User: Open the MariaDB console (mysql -u root -p) and run:
    CREATE DATABASE comm;
    CREATE USER comm@localhost IDENTIFIED BY 'your_password';
    GRANT ALL ON comm.* TO comm@localhost;
    brew install mariadb && brew upgrade mariadb
    brew tap homebrew/services
    brew services start mariadb
    sudo mysqladmin -u root password
  9. Install the Comm development environment using Nix

    master

    The Comm repository provides a Nix development shell that packages all necessary prerequisites for running deployment scripts and Terraform logic.

    To set up the environment:

    1. Clone the repository.
    2. Run the provided installation script.
    3. Enter the Nix shell.

    If you prefer not to use Nix, you must manually install Terraform, AWS CLI, and MariaDB (to use the mysql client).

    git clone git@github.com:CommE2E/comm.git
    cd comm
    ./scripts/install_nix.sh
    nix develop