Co-authored-by: userAdityaa <aditya.chaudhary1558@gmail.com> Co-committed-by: userAdityaa <aditya.chaudhary1558@gmail.com>
5.0 KiB
This file describes the domain model. This description should be translated into standard structs and sqlite schemas in a way that makes sense.
- Fields marked as private should use
#[serde(skip_serializing)]in their definition. - Fields marked as readonly should use
#[serde(skip_deserializing)]in their definition.
Identity
Identity is a description of a user.
pubkey- the user's nostr pubkeyis_admin- whether the user is an admin
Activity
Activity is an audit log of all actions performed by a user or a worker process. This allows us to trace history to create invoices, synchronize actions to external services, and debug system behavior.
id- a random activity IDtenant- a tenant IDcreated_at- unix timestamp when the activity was createdactivity_typeis one of:create_tenantupdate_tenantcreate_relayupdate_relayactivate_relaydeactivate_relayfail_relay_synccomplete_relay_sync
resource_typeis a string identifying the resource type being modified.resource_idis a string identifying the resource id being modified.
Plan
A plan represents a rate charged for relays at a given feature/usage limit. Plans aren't saved to the database, but are simply hardcoded. However, they are exposed through the API so they can be used as a single source of truth.
id- the plan slugname- the plan nameamount- the plan monthly cost in USDmembers- the max number of members a relay can have before needing to upgrade. If empty, membership is not limited.blossom- whether blossom media hosting is available on this planlivekit- whether livekit audio/video calls are available on this planstripe_price_id(nullable) - the identifier of the price in Stripe. Null for the free plan.
There are three plans available:
free- $0/mo, up to 10 members, no blossom/livekitbasic- $5/mo, up to 100 members, includes blossom/livekitgrowth- $25/mo, unlimited members, includes blossom/livekit
Tenant
Tenants are customers of the service, identified by a nostr pubkey. Public metadata like name etc are pulled from the nostr network. They also have associated billing information.
pubkeyis the nostr public key identifying the tenantnwc_url(private) a nostr wallet connect URL used for paying invoices generated by the system on the tenant's behalfnwc_error(private) a string indicating the most recent NWC payment error, if any. Cleared on successful NWC payment.created_atunix timestamp identifying tenant creation timestripe_customer_ida string identifying the associated stripe customerstripe_subscription_id(nullable) a string identifying the associated stripe subscription. Created when the first paid (non-free) relay is activated, deleted when the last paid relay is removed or deactivated. Free-only tenants have no subscription.past_due_at(nullable) unix timestamp when the tenant's subscription became past due. Set on payment failure, cleared on payment success.
Relay
A relay is a nostr relay owned by a tenant and hosted by the attached zooid instance. Relay subdomains MUST be unique.
id- a random ID identifying the relaytenant- the tenant's pubkeyschema- the relay's db schema (read_only, calculated based onsubdomain+id)subdomain- the relay's subdomainplan- the relay's planstripe_subscription_item_id(nullable) - the Stripe subscription item id. Only set for relays on paid plans.status- one ofactive|inactive|delinquent. Onlyactiverelays count toward billing.delinquentis set by the billing system when a relay's subscription becomes past due;inactiveis set when a user or admin manually deactivates a relay.synced- whether the relay has been successfully synced to zooid at least once.sync_error- a string indicating any errors encountered when synchronizing.info_name- the relay's nameinfo_icon- the relay's icon image URLinfo_description- the relay's descriptionpolicy_public_join- whether to allow non-members to join the relay without an invite codepolicy_strip_signatures- whether to remove signatures when serving events to non-adminsgroups_enabled- whether NIP 29 groups are enabledmanagement_enabled- whether NIP 86 management API is enabledblossom_enabled- whether blossom file storage is enabledlivekit_enabled- whether livekit calls are enabledpush_enabled- whether relay push is enabled
Some attributes persisted to zooid via API have special handling:
- The relay's
secretis generated once on relay creation, persisted to the zooid configuration, and isn't stored in the database. Relay updates do not resendsecret. - The relay's
hostis calculated based onsubdomain+RELAY_DOMAIN - The value of
inactiveis calculated based onstatus - The relay's
livekit_*configuration is inferred based on environment variables andlivekit_enabled. - The relay's
rolesare hard-coded for now.