Payments move out of the hub into t5de-payments (its own repo, database and secrets) to contain the risk. Patreon is the first way to pay: it's the seller, so sales tax and VAT are its. Polar's acceptable use policy now names YouTube downloaders, so it's only used on a written yes. No IMVU credits, no Stripe or PayPal directly. Music's paid tier sells hosting only: YouTube's limits are the same in both tiers. Entitlements become a count (music.rooms) because a Patreon member has one tier; the owner picks which rooms are paid.
23 KiB
T5DE Music and shared accounts (plan)
Status: draft (2026-11-18). Decisions marked Decided were agreed in discussion; the rest are proposals. Open decisions are at the end.
A cheap music bot for IMVU rooms: a bot account sits in the room and takes chat commands, and the room's radio plays a stream we serve for that room. A small paid tier from the start (Paid tier, below). Room owners manage it at music.t5de.dev. People sign in with Discord and link IMVU accounts there without making a T5DE account first; one can be added later without losing anything.
Goals
- Cheap at scale: listeners pull audio from a bandwidth-cheap host (Oracle Cloud's free tier to start), never through home or the relay. A paid tier priced near cost, through a Patreon membership and a payments service of its own (docs/payments.md).
- Three things to play to start (Decided): existing internet radio stations (a searchable list from radio-browser.info), the owner's own stream (bring your own), and a queue of songs found on YouTube. More sources later without reworking anything (Sources, below). Jamendo and Audius are out for now: Jamendo's API is free only for non-commercial use, and the paid tier makes this commercial.
- Owners decide who can do what: which commands, for whom (everyone, chosen IMVU users, the room's moderators, the owner), with cooldowns and bans.
- Sign in with Discord, IMVU linking without a T5DE account, and a T5DE account later on the same identity.
- T5DE accounts as an OAuth/OIDC provider, first for our own sites, later for anyone's.
Non-goals: a client feature (this works for every IMVU user, T5DE or not), and hosting anyone's music files.
Overview
browser IMVU room (every visitor's client)
│ │ plays https://radio.t5de.dev/r/<room>
▼ ▼
home (t5de-apps) music.t5de.dev ───────────────┐ Oracle Cloud (t5de-music)
music web + API + Postgres │ streamer (Go) ◄── sources: stations, own streams,
(rooms, permissions, queue, audit) │ ▲ search → yt-dlp/ffmpeg
│ OIDC │ │ control
▼ └──────► bot (TS, @imvu/bot) ──► IMVU (chat, presence)
home (t5de-apps) hub.t5de.dev: T5DE accounts config + events, cached so home being down
Discord sign-in, IMVU links, OIDC provider doesn't stop the radio
Two planes:
- Control plane, at home (Komodo stack on t5de-apps, like the hub): the music website and its API, with their own Postgres. Small traffic; backups and deploys as for every other stack.
- Data plane, on Oracle (
domains/t5de/music.tfin dhkatz/infra): the streamer and the bot. All the bandwidth. It keeps the last config it was given, so the radio keeps playing if home is down; only managing it pauses.
Hostnames: music.t5de.dev for the website (Cloudflare-proxied to the relay, like the hub) and radio.t5de.dev for
streams (DNS-only, straight to Oracle). The infra branch currently gives music.t5de.dev to the Oracle VM; that moves
to radio.t5de.dev. (The 1 GB free VM can't also hold Next.js and Postgres.)
Accounts
One account system, two front doors (Decided)
Discord sign-in is added to the hub's Better Auth, and the music site signs in through it (OIDC). A person who only ever uses Music has a basic account: made by signing in with Discord, no username or password, invisible to the hub's community features. Becoming a T5DE member later means adding a username and password (and approval, when registration is closed) to that same account.
On music.t5de.dev the button says "Sign in with Discord". It goes to the hub's authorize endpoint with a hint to use Discord, which redirects straight on to Discord, so the person sees Discord's consent screen and comes back. They never fill in a T5DE form.
Why not a separate user database in Music, merged with T5DE accounts later:
- IMVU links would live in two places, and "the most recent proof wins" (design.md, Identity) can't hold across two databases: the same IMVU account could belong to different people in each.
- Every later service (more bots, a T5DE-run catalog, others' sites) would repeat sign-in, linking and merging.
- The OIDC provider is needed eventually anyway; Music becomes its first client instead of something to migrate.
The cost: Music's sign-in depends on the hub being up, and the hub gains a second kind of account.
Kinds of account
| Basic | Member | |
|---|---|---|
| Made by | Discord sign-in (from Music or the hub) | Sign-up with username and password, or a basic account finishing setup |
| Sign-in | Discord | Username and password, plus Discord once linked |
| IMVU links | Yes (same table, same cap and rules) | Yes |
| Hub features (products, catalogs, proxy, rooms) | No: "Finish setting up your T5DE account" | Yes, once approved |
| Other sites (OIDC) | Yes | Yes |
Stored as a column on user (kind: basic | member); permissions treat basic accounts like unapproved ones on the
hub's own routes.
Email (Decided):
- Better Auth needs one, so a basic account takes Discord's, and only when Discord says it's verified. A Discord account without a verified email can't sign in; the message says to verify it in Discord and try again.
- Never link or merge by matching email. Better Auth's implicit linking (signing in with a provider whose email matches an existing account adds it to that account) is turned off; check the option's name in 1.7. Discord is linked to an account only from that account's signed-in session. Otherwise anyone who puts a member's address on a Discord account could take theirs over.
- Signing in with a Discord account whose email already belongs to a member it isn't linked to: no new account; "This email belongs to a T5DE account. Sign in to it and link Discord from Account."
- The email is for account messages only. Music and other clients don't get it unless a later scope asks.
Linking Discord to an existing T5DE account
- Member links Discord (Account page) and the Discord account is new to the hub: it's simply added (Better Auth account linking).
- The Discord account already belongs to a basic account: offer to merge it into the member. The basic
account's IMVU links move over (the most recent proof wins, so nothing conflicts), the Discord sign-in moves, and
the basic account is deleted. The hub tells its OIDC clients (
user.merged {from, into}, a signed back-channel call) so Music moves rooms and permissions to the surviving account. - Never merge two members automatically; that stays a moderator action (console, audited).
IMVU linking
- Same rules as today (tagline code, link cap, the most recent proof wins), on the hub, for both kinds of account.
- Music shows its own linking screens and calls the hub's link routes with the person's access token (scope
imvu:link), so people link without leaving music.t5de.dev. - The hub's challenge code moves to
@imvu/verify(imvu.js; the same tagline proof, stateless, already published). Optional, but it removes the hub's own copy.
The OIDC provider
- Better Auth's OAuth 2.1 / OIDC provider plugin on the hub's API, issuer
https://hub.t5de.dev/api/auth(a separateaccounts.t5de.devcan come later without changing clients, if the issuer is a config value from day one). Check what Better Auth 1.7 ships and which plugin is current before starting. - Tokens stay Ed25519 JWTs from the existing JWKS (
jwtplugin). - First-party clients (Music now) are configured in code, trusted (no consent screen), and may ask for
imvu: the real IDs and names of the person's linked IMVU accounts. Music needs real IDs: it acts in IMVU rooms and checks ownership. This is an exception to "Alts stay private" (design.md), limited to T5DE's own services and stated in the privacy text. - Third-party clients (later): registered in the console, consent screen, pairwise
sub, and pairwise IMVU IDs only, as design.md already says for catalogs.
Music
Repository
t5de-music on git.t5de.dev, set up like the hub (Bun, Turborepo, same release flow, modules/app-repo in
dhkatz/infra):
| Path | What |
|---|---|
apps/web |
Next.js 16, Tailwind 4, shadcn/ui from @t5de/ui: music.t5de.dev |
apps/api |
Elysia on Bun, Drizzle and its own Postgres: rooms, permissions, queues, audit; the bot's config and events |
apps/bot |
TypeScript on @imvu/bot (imvu.js): joins rooms, reads commands, enforces permissions |
streamer/ |
Go: one station per room, sources, the /r/<room> streams (Go like t5de-catalog) |
Its own database (Decided): a Postgres container in Music's stack, as each hub environment has in its own
(stacks/t5de-hub/compose.yaml in dhkatz/infra), so deploying works as it does now. Music never reads the hub's
database: it knows people by their OIDC sub and asks the hub's API for anything else. Migrations, backups and
restores stay per app, and either can move to another host alone. The cost, no joins across the two, doesn't matter
at this size.
Rooms and who manages them
- Owner: whoever has linked the IMVU account that owns the room. A room's ID is
<ownerCid>-<n>, so this needs no call to IMVU, just the person's links (from theimvuclaim). - Managers: people the owner adds on the site (by IMVU username they've linked, or an invite link). They change settings but can't remove the owner or other managers.
- Adding a room: pick one of your linked accounts' rooms (paste its link or ID; IMVU can't list a user's rooms), see the stream URL to paste into the room's radio settings, turn the bot on.
Chat commands
| Command | What | Default for |
|---|---|---|
!np |
What's playing | Everyone |
!play <search> |
Search and queue the first match | Everyone |
!queue, !remove <n> |
Show the queue, remove your own (managers: any) | Everyone |
!skip |
Skip (vote among listeners for non-DJs, later) | DJs |
!station <name> |
Switch to a station from the room's list | DJs |
!stop, !resume |
Stop or resume the radio | Room moderators |
!help |
Whispered list of what you may use | Everyone |
Levels: everyone, DJs (IMVU accounts the owner lists on the site), the room's IMVU moderators (read from the
room, re-read every few minutes), owner and managers. Each command's level is a setting, plus cooldowns, a per-person
queue limit, the longest song allowed, and banned IMVU accounts. The bot checks the sender by IMQ's user_id, never
the message text.
What plays
- Stations: a directory from radio-browser.info (HorizonRadio's
RadioBrowserClient, ported to Go: mirror discovery, failover). The owner picks the room's list;!stationswitches among them. Now-playing comes from the station's ICY metadata (HorizonRadio'sIcyStreamReader). - Own stream: an Icecast/Shoutcast URL the owner (or a DJ) gives on the site. The bot announces who's on air.
- Search and queue: tracks found by search, starting with HorizonRadio's YouTube source (yt-dlp search, ffmpeg decode).
- Fallback: when the queue is empty, the room's default station (or silence), so the stream never ends.
Each is a source provider (below).
Sources
Modelled on HorizonRadio's source SDK (HorizonRadio.Sdk/Sources), in Go:
- A provider (HorizonRadio's source factory) is a Go package registered at startup: an ID, a name, its kind, and
a settings schema the site renders as a form (as HorizonRadio's Sources tab does). Optional capabilities are small
interfaces the streamer checks for:
Searcher: a query to results (track, playlist, album, station), each a ref:{source, locator, title}.Recognizer: claims pasted links (a YouTube URL, an.m3u/.pls, an Icecast address), so!play <link>and the site's "paste a link" pick the provider by themselves. Only unambiguous ones, as in HorizonRadio.Enumerator: expands a ref into its tracks (a playlist, an album).Describer: names a collection without expanding it.Account: needs an account or API key connected first, for the service or per room.
- Content providers (YouTube now; later SoundCloud, Jamendo, Bandcamp, owners' uploads) play through the room's
queue and can be mixed into playlists. A track is fetched once into a shared audio cache (HorizonRadio's
AudioCache: whole files only, size-limited, least recently used goes first), already loudness-normalized and in the stream's format. - Live providers (radio-browser stations and own streams now; others later) play as one endless item: switched to, not queued, like HorizonRadio's self-driven sources.
- Metadata providers are separate (MusicBrainz first, as in HorizonRadio): they tidy titles and artists for now-playing and the queue page.
- Everything stored keeps refs (queues, playlists, a room's station list, history), so a new provider needs no migration, and a removed one leaves rows shown as unavailable.
- Rooms choose which providers they allow; an operator setting turns one off for everyone (for example when YouTube blocks us).
- Providers are compiled in. If one ever has to be written in another language, the same capabilities become a small HTTP contract to a sidecar.
On the free VM, CPU runs out before the network does: re-encoding audio for every room would allow only a few rooms on 1/8 of a CPU. So tracks are encoded once, into the cache (44.1 kHz stereo, constant-bitrate MP3), and playing them only copies frames. Live sources already in a compatible MP3 format pass straight through; the rest are transcoded, a handful at a time.
Relayed or direct
A station or own stream can reach listeners two ways:
- Relayed: the room's radio stays set to our URL (
radio.t5de.dev/r/<room>), and our streamer plays the station into it. Switching is instant and needs nothing from IMVU, but every listener uses our bandwidth. - Direct: the room's radio is set to the station's own URL, so listeners pull from the station and we use no bandwidth. Switching by chat command then means the bot changes the room's radio setting itself.
Seen in IMVU (2026-11-18): a room's moderators, not just its owner, can change its stream URL and turn it on and off ("On Air"). So a bot the owner makes a moderator should be able to do the same, through whatever call IMVU's client makes; phase 0 finds that call. Relayed first; direct per room once the call is known. The bot also turns On Air on when it starts playing, so owners don't have to.
Streamer
- One goroutine per active room: reads frames from the current source, paces them in real time, fans out to listeners with a small ring buffer (instant start; slow listeners are dropped). ICY metadata for now-playing.
- MP3 for compatibility (bitrate per room, 96-128 kbps); rooms with nobody listening cost nothing.
- Control API on the compose network only: the bot and Music's API call it, never the internet.
- Counts listener-hours per room, for Music's dashboard and the 10 TB budget.
Bot
- One IMQ connection per bot account, many rooms each; rooms spread over a few accounts (bot accounts verify their
email, per
@imvu/bot's README). - Config (rooms, permissions) from Music's API over a WebSocket with a local cache; events back (joined, booted, commands used, errors) for the room's activity page.
- Booted from a room: leaves, and tells the owner on the site.
Paid tier (Decided: sell the hosting)
What's paid for is the service around the music (quality, capacity, features), never a source. Every source is in both tiers, free with limits:
- If YouTube breaks or has to go (blocked, a takedown, a processor's demand), paid rooms keep everything they paid for, and it's switched off without refunds.
- What the pricing page sells is music bot hosting, not "pay to play YouTube songs". YouTube's limits are the same in both tiers (Decided), so nothing about YouTube is for sale.
- The free tier is the trial: people use it, want better audio or more listeners, and upgrade.
| Free | Paid (Patreon: $1.99 a month for 1 room, $4.99 for 3) | |
|---|---|---|
| Rooms | 1 | 1 or 3, by tier, on top of the free one |
| Stations and own streams | Yes (direct where possible, so they cost nothing) | Yes |
| YouTube search and queue | Fair-use limits: queue length, songs an hour, the longest song | The same |
| Audio | 64 kbps | 128 kbps |
| Listeners | A small cap (about 10) | Up to the room's capacity |
| Saved playlists, scheduled playback | No | Yes |
| Relayed stations (when direct isn't possible) | No | Yes |
| Linked rooms | No | An add-on, later |
The free limits are what keep free YouTube affordable: it's always relayed (bandwidth) and fetched once per track (CPU), unlike direct stations. The bot also leaves free rooms when they're empty. Exact limits are settings, tuned once there's usage to look at.
IMVU credits aren't a way to pay (Decided, docs/payments.md).
Paying (Decided: Patreon first, docs/payments.md): a Patreon membership, linked to the person's account on payments.t5de.dev. A Patreon member has one tier, so tiers are room bundles: "Room" ($1.99 a month, 1 room) and "Rooms" ($4.99, 3 rooms); the most popular community bot starts at $4.99 for one room. After Patreon's 10% and processing, $1.99 is about $1.59. Yearly memberships at a discount once Patreon turns them on for the page.
The paid entitlement is music.rooms, a count (docs/payments.md, Concepts). The owner picks which of their rooms are
paid on the room's page, up to the count. If the count drops (a lapse, a smaller tier), the most recently picked
rooms go back to the free tier first, and the owner can swap which ones.
One stream URL, many rooms. The stream is plain HTTP, so anyone can paste a room's URL into other rooms (or any player), and they'll all hear it. Only the bot's own room has commands, but every extra listener costs bandwidth, and a paid stream shared this way is a second room for free. So:
- Listener cap: a stream takes at most the room's capacity in listeners, plus a small margin (the bot knows capacity and who's there). A stream with far more listeners than its room has people is being played elsewhere, and shown so on the room's page.
- Rotating URLs, once the bot can set the room's radio (phase 0): the room's URL carries a token the bot replaces every day or so; the old one keeps working for a while, then stops, so copies elsewhere die out.
- Linked rooms as a feature later: one stream played in several rooms on purpose (a club with more than one room), with the bot in each and the cap set from their total capacity.
Bandwidth cost per room, for the price: at 96 kbps, 10 listeners for 8 hours a day is about 100 GB a month, free within Oracle's 10 TB and about 90¢ past it at Oracle's rate ($0.0085/GB). Busy relayed rooms past the free tier need an unmetered host, not a higher price.
Website
Pages: home (what it is, how to add it), sign in, my rooms, and for each room: overview (status, now playing, listeners, the stream URL), what plays (stations, own stream, queue), commands and permissions, DJs, managers and bans, activity. Account: Discord, IMVU links, and "Make it a T5DE account" (goes to the hub).
Same look as the hub and t5de.dev (neutral, light/dark following the system, color only for status, short copy, Title Case headings), the same header and footer ("unofficial: not made by or affiliated with IMVU").
Shared code
| Package | From | Used by |
|---|---|---|
@t5de/ui |
the hub's components/ui, globals.css, header and footer shell |
hub web, t5de-site, Music web |
@t5de/auth |
new: OIDC sign-in for T5DE's Next.js sites (redirect, callback, session cookie, refresh, getMe) |
Music web, later t5de-site |
@imvu/verify |
imvu.js (published) | hub (IMVU linking) |
@imvu/bot, @imvu/client |
imvu.js (published) | Music bot |
@t5de/* packages go to git.t5de.dev's npm registry (Gitea has one; the image registry is already there), built and
published by CI like images. t5de-site moves from its copies to @t5de/ui when convenient.
Risks
- Licensing: songs played on request are interactive streaming, which internet-radio licenses don't cover, and charging for it makes it commercial. Relaying stations and owners' own streams is the safest part. Search providers stay pluggable, so a licensed one can replace or join YouTube.
- Payment processors: Stripe and the merchants of record forbid selling services that infringe copyright, and Polar's rules name YouTube downloaders outright. A paid service built on YouTube's audio can get the account closed, with funds held. Patreon is used, selling hosting only, and payments are a service of their own (docs/payments.md), so a closed account can't take the hub or Music down with it.
- YouTube from a datacenter: yt-dlp from cloud IPs is often blocked ("confirm you're not a bot") and needs a token provider, a JavaScript runtime and sometimes an account's cookies; it's also against YouTube's terms. Paying users will expect it to work, so the operator setting that turns it off, and the status page, matter more.
- IMVU: bot accounts can be flagged or banned; per-account room limits and long-run behaviour are untested (imvu.js ROADMAP.md, "Still open").
- Free tier: Oracle reclaims idle free VMs (upgrade the account to Pay As You Go); 10 TB a month is about 300 listeners on average at 96 kbps.
Phases
- Check the assumptions (days): IMVU's room radio plays an HTTPS MP3 stream from our host; which call sets a
room's radio, and whether a moderator bot may make it (direct mode; reading room data needs a signed-in session,
and the test account's cached one has expired); one bot account in ~20 rooms for a few hours. The Oracle VM up
(dhkatz/infra
music-oracle, with the rename to radio.t5de.dev). - Accounts (hub): Discord sign-in, basic accounts, the OIDC provider with Music as a trusted client and the
imvuscope, link routes that take access tokens.@t5de/uiextracted, hub web on it. - Music, managing (t5de-music): repo and CI, web and API, sign-in, rooms and ownership, managers, permissions, DJs, bans, the stream URL. Infra: its stack and Postgres on t5de-apps, music.t5de.dev.
- Music, playing: streamer with stations (relayed) and own streams, the bot with commands and permissions, config sync. Beta (free tier). 3b. Payments (t5de-payments, docs/payments.md phases 1-2): entitlements and grants, Patreon; the paid tier.
- Search and queue: content providers and the audio cache, the YouTube provider from HorizonRadio, MusicBrainz
metadata,
!play, the queue page. (Phase 3's stations and own streams are already live providers.) - Accounts, later: merging basic into member accounts,
user.merged, third-party OIDC clients (console, consent, pairwise IDs).
Open decisions
- The free tier's exact limits, and YouTube's fair-use limits (Paid tier, above).
- Direct mode's details, once phase 0 has found the call that sets a room's radio and On Air.