Yesterday I shipped Hubstr Relay. Not a library. A relay you can run.
A personal relay: one PHP process, one SQLite file, and two kinds of visitor. Guests see your public presence, the notes, profile, articles, reactions, and lists you signed, and can reply, react, zap, and DM you. Tenants, authenticated over NIP-42, see every kind, and everything the relay holds, including events from other users cached there... More on that soon.
Point your kind 10050 at it and it is your DM inbox. Gift wraps come in from anyone and go out only to you. It carries NIP-46 traffic, so it works as a bunker relay too. Full-text search over NIP-50, COUNT over NIP-45, expiry swept under NIP-40, protected events under NIP-70.
The policy is managed at runtime over NIP-86, signed with NIP-98. Add a tenant. Decide which kinds guests may read and write. Ban a word, a pubkey, or a hashtag, and what is already stored goes with it. Block an IP. Set the rate limits. Watch every open connection and the subscriptions it holds. And an explore feed computed from what the relay has seen: trending hashtags, most followed, most muted, most zapped by count or sats, top zappers, most reacted to, most reposted, over a day, a week, a month, or all time, plus a web-of-trust score for any pubkey as seen from your follows. As above, more on relay management and content discovery soon...
Another feature of guest writes is that admitting an event by the prefix of a tag value allows sites to host their own NIP-22 comments without becoming a public free-for-all.
Database work runs on worker processes, off the event loop. Tested at two million events, with author and kind lookups under a millisecond. A version of this relay has been running on relay.innis.xyz since December, but earlier versions have been elsewhere in the wild for far longer.
Import and export are JSONL, and an export can pull one key's whole presence, everything it wrote and everything that tagged it. Caddyfile and systemd unit included. PHP 8.4, three config keys, and it starts.
Built on innis/nostr-relay, innis/nostr-core, and innis/hubstr-core.
https://github.com/johninnis/hubstr-relay
MIT.
#nostr #php #opensource #nostrdev
