Skip to content
radrootslabsPublic

About

Create and manage local food networks over Nostr relays

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Tangle

A Nostr relay for collaborative farming and local food communities.

What it does: Tangle is a multi-tenant Nostr relay that routes requests to tenants by hostname. Each tenant has its own relay URL, Pocket store, resource and rate limits, and optional NIP-29 groups.

Getting started | Docs | Config | Releases | License

Getting started

Install Rust and Git. The repository uses the toolchain pinned in rust-toolchain.toml.

git clone https://radroots.dev/git/tangle.git && cd tangle

cargo check --workspace --locked

Copy the host and tenant config files:

mkdir -p runtime/tenants

cp config/tangle.host.example.json runtime/tangle.host.json
cp config/tenants/farmers_market.example.json runtime/tenants/farmers-market.json

Run the relay:

cargo run -p tangle -- config validate --config "runtime/tangle.host.json"
cargo run -p tangle -- tenant list --config "runtime/tangle.host.json"
cargo run -p tangle -- run --config "runtime/tangle.host.json"

Relative tenant directories and Pocket store paths resolve from the directory containing the host config. Each tenant supplies a distinct groups.relay_secret even with groups disabled. The relay derives its NIP-11 self identity from this key and uses the same key when it signs group events. Replace the example key with a private key unique to the tenant. Use the same authority in host and relay_url, and the same canonical URL in enabled groups. Use the host and tenant schemas for editor validation and tangle config validate to check cross-field and filesystem rules.

The host caps active tenants, connections, and subscriptions. The tenant caps aggregate subscriptions, subscriptions per connection, and WebSocket frame and message size. The rate limiter reclaims expired buckets during admission and rejects new keys at capacity until a bucket expires.

Check readiness and the tenant's NIP-11 document:

curl http://localhost:7000/.well-known/tangle/ready

curl --header 'Accept: application/nostr+json' --header 'Host: relay.radroots.test' http://localhost:7000/

Operator routes accept loopback connections only. If a proxy connects over loopback, exclude /.well-known/tangle/ from public forwarding. The metrics response contains host totals and a tenant_metrics object keyed by tenant ID.

Tenant store ownership

Before a new store serves traffic, Tangle binds it to its tenant ID, schema, relay URL, and relay public key. The host holds an exclusive store lock while the tenant is open. Stop the host before running backup, export, or adoption.

For an existing unbound Pocket store, record the intended tenant identity and stop every process using that store. Preserve a verified independent offline recovery copy before binding it:

tangle tenant adopt --config runtime/tangle.host.json --tenant farmers-market --input /path/to/recovery-copy

The command verifies the persistent Pocket files against the recovery copy before writing the tenant identity record. It leaves the recovery copy intact. Keep the copy until the configured tenant starts and you have verified its events and group state.

Tenant backups are written as v2 bundles. Restore also accepts v1 bundles whose checksummed payload and recorded tenant ID, schema, host, relay URL, and relay public key match the selected tenant. It binds the restored copy to that identity before publication and recreates the transient LMDB lock as needed. For a v1 bundle without a recorded relay public key, recover offline using the original relay and adopt the recovered store with a verified independent copy.

For offline throughput measurements, run tangle_backup_benchmark from the tangle_bench package with a fresh output directory. The default workload seeds one million synthetic events and records backup, export, and checksum verification times in report.json. Pass a smaller event count for a smoke run.

Protocol support

Status

Tangle is under active development. Interfaces and configuration may change.

Acknowledgements 👋

Tangle is a mashup of:

Thanks to Mike and Jon for creating and open-sourcing these projects.

License

This repository is licensed under AGPL-3.0-or-later. See LICENSE.

About

Create and manage local food networks over Nostr relays

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages