DEV Community

Alexey Sitnikov
Alexey Sitnikov

Posted on

I built an offline wiki that fits in a single 19 KB HTML file

I kept hitting the same wall looking for an offline wiki. Kiwix is great, but it's an app plus multi-GB ZIM files. IPFS needs connectivity and setup. I just wanted something dead simple: a knowledge file you can open on any phone with no install, and hand to the next person over Bluetooth or a USB stick.

So I built Portable Knowledge Mesh. It's one reader.html (~19 KB). You open it β€” even straight from file:// β€” load a .mesh pack, and read/search offline. To share it, you just send the file; the other person opens it in any browser. The whole thing β€” reader plus a 21-article survival pack β€” is under 50 KB. It fits in a single chat message.

🌐 Portable Knowledge Mesh β€” an offline wiki in a single file

A Wikipedia that spreads via Bluetooth, USB, and AirDrop β€” no server, no install, no internet required.

License: MIT Content: CC BY-SA 4.0 Release Made by one dev

πŸ‡·πŸ‡Ί Русский Β· πŸ‡ͺπŸ‡Έ EspaΓ±ol Β· translations wanted β€” see #good-first-issue


What is this?

Portable Knowledge Mesh is a single HTML file that turns any phone or laptop into an offline wiki. It opens in a browser β€” even straight from a USB stick, an email attachment, or a Bluetooth share β€” and lets you read, search, and pass on curated knowledge without ever touching a server.

  • πŸš€ Zero install β€” double-click reader.html, it works. No app store, no setup.
  • πŸ“΄ Fully offline β€” no internet, no backend, no API keys, no account.
  • πŸ”’ Tamper-proof β€” every knowledge pack is cryptographically signed (ECDSA P-256, WebCrypto). Forgeries are rejected automatically.
  • 🦠 Viral by design β€” send a .mesh file over…

Here are the parts that turned out interesting to build.

A single file that runs from file://

The constraint "must work when double-clicked off a USB stick" kills a lot of the usual toolbox:

  • No Service Worker β€” they require a secure context; file:// isn't one.
  • No IndexedDB β€” in a file:// (null) origin it's unreliable and non-portable across browsers.

So v0.1 keeps everything in memory + sessionStorage, and a .mesh is just a single JSON document (zero dependencies, trivially parseable). The fancy ZIP + CompressionStream container is a later optimization β€” for v0.1, plain JSON is what makes it bulletproof on file://.

Tamper-proof packs with WebCrypto (no libraries)

If knowledge spreads device-to-device with no server, "is this pack genuine?" matters. Each pack is signed: every article (block) is hashed with SHA-256, a Merkle root is computed over the sorted block hashes, and the publisher signs that root with ECDSA P-256 via the browser's built-in crypto.subtle. The reader re-derives everything and verifies β€” change one byte of a signed article and the badge turns red.

// recompute block hashes -> Merkle root -> verify the publisher's signature, all in-browser
async function verifyPack(mesh) {
  const m = mesh.manifest;
  const per = {};
  for (const [id, md] of Object.entries(mesh.content.blocks)) {
    per[id] = await sha256Hex(md);
  }
  const root = await sha256Hex(Object.keys(per).sort().map(id => per[id]).join(''));
  if (root !== m.merkle_root) return 'tampered';            // content was modified

  const key = await crypto.subtle.importKey(
    'jwk', m.publisher.pubkey_jwk,
    { name: 'ECDSA', namedCurve: 'P-256' }, true, ['verify']
  );
  const ok = await crypto.subtle.verify(
    { name: 'ECDSA', hash: 'SHA-256' },
    key, b64ToBytes(m.signature_b64),
    new TextEncoder().encode(m.merkle_root)
  );
  return ok ? 'verified' : 'tampered';   // no private key = can't re-sign a forged root
}
Enter fullscreen mode Exit fullscreen mode

Two attack paths, both covered: edit a block and the recomputed hash won't match the manifest; edit the manifest to match and the signature over the new root fails (you can't re-sign without the private key).

The CRDT trap I had to avoid (for v0.2 editing)

v0.2 will let local communities adapt articles. My first instinct was a CRDT like Yjs or Automerge β€” until I remembered the quota death spiral: sequence/text CRDTs accumulate tombstones, history grows without bound, and safe garbage collection needs coordination among all nodes. In an offline mesh where devices may not meet for months, there's no server to compact β€” so the document just bloats until QuotaExceededError.

The fix is choosing a lighter CRDT, not abandoning CRDTs:

  • LWW-Map per block instead of a sequence CRDT β€” only the current value per field is kept, so no tombstone history.
  • Lamport clocks, never wall-clock. Offline devices have unreliable, forgeable clocks (dead CMOS battery β†’ 1970; set the date to 2099 and you always "win"). Conflicts resolve by logical time, tie-broken by author key.
  • Trusted-snapshot compaction β€” a trusted editor publishes a signed snapshot that peers who trust them accept as a new baseline, dropping old ops. Compaction with no server.

Sneakernet first

WebRTC is tempting for sync, but without STUN/TURN it only connects inside one LAN β€” too fragile to be the critical path. So the primary transport is just moving the file: Bluetooth, AirDrop, USB, QR, email. WebRTC LAN-sync is a v0.3 bonus, never a dependency.

Where it is now

  • βœ… v0.1 β€” portable read-only reader (this release)
  • 🚧 v0.2 β€” editable overlay + local web of trust + Lamport sync over file exchange
  • πŸ“‘ v0.3 β€” installed PWA mode + WebRTC LAN-sync + trusted-snapshot compaction

It ships with Barefoot Skills β€” 21 practical offline articles (water, energy, repair, food, shelter), risk-stratified so safety-critical topics are signed and read-only. Code is MIT, content CC BY-SA, all sourced from open corpora (Appropedia, Wikibooks, Practical Action).

I'd love your feedback

  1. Is the single-file / "sneakernet" approach genuinely useful, or a gimmick?
  2. What knowledge packs would be worth curating first β€” first aid, repair, farming, a specific language?

And if you want to poke holes in the crypto or the v0.2 merge design, please do β€” that's exactly the kind of review I'm hoping for.

Repo: https://github.com/by-sitnikov/portable-knowledge-mesh

Top comments (0)