whatisgithub

What is p2p-from-scratch-labs?

heart-it/p2p-from-scratch-labs — explained in plain English

Analysis updated 2026-05-18

0JavaScriptAudience · developerComplexity · 3/5Setup · easy

In one sentence

A set of small runnable code labs teaching peer to peer networking concepts using the Holepunch software stack.

Mindmap

mindmap
  root((p2p labs))
    What it does
      Runnable P2P examples
      Companion to a written series
      One command per lab
    Tech stack
      JavaScript
      Node.js
      Holepunch stack
    Use cases
      Learn P2P networking
      Study hole punching
      Explore Autobase and Hyperdrive
    Audience
      Developers learning P2P

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Learn how DHT discovery and hole punching let peers connect directly.

USE CASE 2

Study how an append only log tracks history with Merkle roots.

USE CASE 3

Run a lab where two writers converge on one shared consistent view.

USE CASE 4

See how offline writes sync and catch up when a peer reconnects.

What is it built with?

JavaScriptNode.jsHolepunch

How does it compare?

heart-it/p2p-from-scratch-labs00kaku/gallery-slider-block0xkinno/vellum
Stars00
LanguageJavaScriptJavaScriptJavaScript
Last pushed2021-05-19
MaintenanceDormant
Setup difficultyeasyeasyhard
Complexity3/52/54/5
Audiencedevelopergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Each lab runs with a single npx command on Node.js 18 or later, no server or account needed.

License is not stated in the README shown, so terms of use are unclear.

So what is it?

p2p-from-scratch-labs is a collection of small, runnable code examples that go along with a written series called P2P from Scratch. Each lab is a standalone program built on the Holepunch peer to peer software stack, kept intentionally short enough that someone can read through the whole thing in one sitting rather than digging through a large codebase. The labs are organized into two tiers. The first eight cover the core ideas of building peer to peer software in order: finding other computers on a distributed network and punching through firewalls to connect directly, sending structured messages over an encrypted connection, building an append only log that tracks its own history using Merkle roots, running range queries against a sparse database that only downloads the pieces it needs, watching how peers announce themselves and reconnect after dropping off, having two independent writers converge on one shared and consistent view of data, building a chain of identity and device verification from a single seed phrase, and handling writes made while offline that later sync and catch up with other peers. A second, deeper set of four labs revisits some of those same topics with more nuance, covering things like inspecting exactly what a connection reveals about you during setup, downloading a single file from a larger shared drive without pulling everything, keeping a checkpoint moving forward by majority vote when a network splits into pieces, and issuing an invite that lets a new person join without that invite ever containing the actual secret key. Every lab can be run with a single command using npx and works with Node.js version 18 or later, with some also prepared to run under the Bare and Pear runtimes. None of the labs use a server or require an account, and any temporary data they create is stored in a directory that gets wiped away once the lab is closed. This is aimed at developers who want to learn peer to peer networking concepts by running small working code rather than reading only theory.

Copy-paste prompts

Prompt 1
Run npx @heart-it/p2p-hello and explain what DHT discovery and hole punching are doing.
Prompt 2
Walk me through the p2p-append-only lab and how Merkle roots track history.
Prompt 3
Explain how p2p-one-truth gets two Autobase writers to agree on one view.
Prompt 4
Show me how p2p-invite lets a stranger join without ever sharing the secret key.
Prompt 5
Help me run the p2p-sparse-db lab and understand sparse Hyperbee range queries.

Frequently asked questions

What is p2p-from-scratch-labs?

A set of small runnable code labs teaching peer to peer networking concepts using the Holepunch software stack.

What language is p2p-from-scratch-labs written in?

Mainly JavaScript. The stack also includes JavaScript, Node.js, Holepunch.

What license does p2p-from-scratch-labs use?

License is not stated in the README shown, so terms of use are unclear.

How hard is p2p-from-scratch-labs to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is p2p-from-scratch-labs for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.