heart-it/p2p-from-scratch-labs — explained in plain English
Analysis updated 2026-05-18
Learn how DHT discovery and hole punching let peers connect directly.
Study how an append only log tracks history with Merkle roots.
Run a lab where two writers converge on one shared consistent view.
See how offline writes sync and catch up when a peer reconnects.
| heart-it/p2p-from-scratch-labs | 00kaku/gallery-slider-block | 0xkinno/vellum | |
|---|---|---|---|
| Stars | 0 | — | 0 |
| Language | JavaScript | JavaScript | JavaScript |
| Last pushed | — | 2021-05-19 | — |
| Maintenance | — | Dormant | — |
| Setup difficulty | easy | easy | hard |
| Complexity | 3/5 | 2/5 | 4/5 |
| Audience | developer | general | developer |
Figures from each repo's GitHub metadata at analysis time.
Each lab runs with a single npx command on Node.js 18 or later, no server or account needed.
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.
A set of small runnable code labs teaching peer to peer networking concepts using the Holepunch software stack.
Mainly JavaScript. The stack also includes JavaScript, Node.js, Holepunch.
License is not stated in the README shown, so terms of use are unclear.
Setup difficulty is rated easy, with roughly 5min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Don't trust strangers blindly. Verify against the repo.