Regarding invite codes, I've proposed using Nostr badges for access control. https://github.com/neilck/nostr-access-control