How yeusepe/yucp-creator-assistant works
Purpose and runtime entry points
YUCP Creator Assistant is a multi-tenant entitlement platform: creators connect storefronts and Discord guilds; buyers prove identity or purchases; verified entitlements drive Discord roles, gated downloads, and package access.
Primary runtime entries:
• Discord bot: apps/bot/src/index.ts
• Bun HTTP API: apps/api/src/index.ts, apps/api/src/createServer.ts
• Cloudflare Worker/Vite web dashboard: apps/web/src/router.tsx, apps/web/src/routes/__root.tsx
• Convex backend functions and schema: convex/schema.ts, convex/http.ts
Interaction surfaces: bot, web, and API
The bot exposes creator and administrator workflows, processes Discord interactions, and runs role synchronization and gated-download delivery. It calls backend capabilities through internal RPC rather than directly owning persistence.
• Command registry and handlers: apps/bot/src/commands/index.ts, apps/bot/src/handlers/interactions.ts
• Role and download services: apps/bot/src/services/roleSync.ts, apps/bot/src/services/lienedDownloads.ts
• API route composition and server boundaries: apps/api/src/routes/index.ts, apps/api/src/internalRpc/router.ts
The web app is the browser-facing dashboard, account area, OAuth/verification UI, and API/auth proxy. Authenticated dashboard routing is separated from public routes.
• Router and authenticated shell: apps/web/src/router.tsx, apps/web/src/routes/_authenticated.tsx
• Server-side API/auth proxy: apps/web/src/lib/server/api-proxy.ts, apps/web/src/routes/api/$.ts
Identity, authorization, and tenant boundary
Better Auth is hosted with Convex; the API and web frontend broker sessions, OAuth flows, origin enforcement, and scoped identities. Guild/workspace ownership and collaborators establish the tenant context for creator operations.
• API auth/session layer: apps/api/src/auth/index.ts, apps/api/src/auth/session.ts
• Convex auth integration: convex/betterAuth/auth.ts, convex/auth.ts
• Tenant/workspace authorization: convex/creatorWorkspacePermissions.ts, convex/workspaceResolution.realtest.ts
• Public API authorization surfaces: apps/api/src/routes/publicV2/auth.ts, apps/api/src/routes/publicV2/bindings.ts
Providers, webhooks, and verification
Provider adapters normalize OAuth, API-key, webhook, buyer-link, and license-verification behaviors across Discord, Gumroad, itch.io, Jinxxy, Lemon Squeezy, Patreon, Payhip, VRChat, and manual licenses. The API receives provider callbacks/webhooks; Convex persists connections and processes durable domain state; verification sessions resolve buyer identity and product access.
• Shared provider registry/contracts: packages/providers/src/index.ts, packages/providers/src/descriptors/index.ts
• API provider adapters and webhook ingress: apps/api/src/providers/index.ts, apps/api/src/routes/webhooks.ts
• Verification orchestration: apps/api/src/verification/sessionManager.ts, apps/api/src/verification/completeLicense.ts
• Durable webhook processing: convex/webhookIngestion.ts, convex/webhookProcessing.ts
Entitlements, policies, and role synchronization
Convex is the system of record for products, provider connections, buyer subjects, entitlements, guild links, role rules, and audit/event data. The policy package produces allow/deny decisions and remediation guidance. Completion or webhook changes enqueue role-sync work, which the bot executes against Discord.
• Entitlements and product resolution: convex/entitlements.ts, convex/productResolution.ts
• Role-rule and sync pipeline: convex/role_rules.ts, convex/roleSyncEnqueue.ts, convex/roleSyncWorkpool.ts
• Policy engine: packages/policy/src/engine.ts
• Bot-side Discord mutation: apps/bot/src/services/roleSync.ts
Package storage and protected delivery
A separate package lifecycle supports creator uploads, VPM repositories, installer/TUF metadata, and buyer-authorized delivery. Uploads enter quarantine, are ingested/materialized into object storage, registered in a PostgreSQL catalog, and served by Cloudflare Workers with signed/DPoP-bound access controls.
• API package endpoints: apps/api/src/routes/creatorUploads.ts, apps/api/src/routes/vpmRepository.ts
• Catalog control plane: ops/catalog/catalog.ts, ops/catalog/database.ts
• Ingestion/materialization: ops/ingest-pipeline/ingestPipeline.ts, ops/materialization/materializationBroker.ts
• Edge delivery: services/delivery-worker/src/index.ts, services/rendition-worker/src/index.ts
Infrastructure and external dependencies
Core runtimes are TypeScript on Node (bot), Bun (API), Convex (database/functions), and Cloudflare Workers (web and delivery). Production secrets are sourced from Infisical. External boundaries include Discord APIs/OAuth, provider storefront APIs and webhooks, S3-compatible/R2-style object storage, PostgreSQL for the catalog, and HyperDX/OpenTelemetry observability.
Shared contracts and cross-runtime utilities reside in packages/private-rpc/src/index.ts, packages/application/src/composition/createApplicationServices.ts, and packages/shared/src/index.ts.
Main entry points: src/index.ts Bun API · src/index.ts Discord bot · entitlements.ts Entitlement resolution · ingestPipeline.ts Ingest and materialize
Components 22
Runtime surfaces
- Discord bot · Runs creator workflows, interactions, role sync, and downloads.
apps/bot/src/index.ts - Interaction handlers
apps/bot/src/handlers/interactions.ts - Bun API · Composes public, internal, provider, and package routes.
apps/api/src/index.ts - Internal RPC router · Backend capability boundary used by the bot.
apps/api/src/internalRpc/router.ts - Web dashboard · Creator dashboard, account, OAuth, and verification UI.
apps/web/src/router.tsx - API/auth proxy
apps/web/src/lib/server/api-proxy.ts
Identity and tenant control
- Better Auth · Sessions, OAuth, origins, and scoped identities.
convex/betterAuth/auth.ts - Workspace authorization · Guild ownership and collaborator access establish tenant context.
convex/creatorWorkspacePermissions.ts
Entitlements and automation
- Convex domain backend · Persists products, connections, buyers, entitlements, rules, and events.
convex/schema.ts - Entitlement resolution · Resolves products and buyer access.
convex/entitlements.ts - Policy engine · Produces allow/deny decisions and remediation guidance.
packages/policy/src/engine.ts - Role-sync workpool · Queues role changes after entitlement updates.
convex/roleSyncWorkpool.ts
Provider verification
- Provider contracts · Normalizes provider OAuth, API key, webhook, and license behavior.
packages/providers/src/index.ts - Webhook processing · Ingests and processes provider events.
convex/webhookProcessing.ts - Verification orchestration · Resolves buyer identity, licenses, and product access.
apps/api/src/verification/sessionManager.ts
Package lifecycle
- Creator package endpoints · Accepts uploads and serves VPM repository operations.
apps/api/src/routes/creatorUploads.ts - Ingest and materialize · Moves quarantined uploads into distributable package artifacts.
ops/ingest-pipeline/ingestPipeline.ts - Package catalog · Registers package and repository metadata.
ops/catalog/catalog.ts - Object storage · Stores quarantined and materialized package objects.
- Protected delivery worker · Serves signed and DPoP-bound package access.
services/delivery-worker/src/index.ts
Other components
- Discord platform · OAuth, interactions, guild roles, and DMs.
- Storefront providers · Commerce APIs and webhook sources.
Connections 28
- Discord platform → Discord bot: interactions and OAuth
- Discord bot → Interaction handlers: dispatches
- Interaction handlers → Internal RPC router: internal RPC
- Internal RPC router → Convex domain backend: domain operations
- Web dashboard → API/auth proxy: authenticated requests
- API/auth proxy → Bun API: proxies API/auth
- Bun API → Better Auth: brokers sessions and OAuth
- Better Auth → Convex domain backend: identity state
- Workspace authorization → Convex domain backend: tenant-scoped access
- Bun API → Workspace authorization: authorizes creator operations
- Bun API → Provider contracts: uses adapters
- Storefront providers → Bun API: OAuth callbacks and webhooks
- Bun API → Verification orchestration: starts verification
- Verification orchestration → Entitlement resolution: proves buyer access
- Bun API → Webhook processing: persists webhook events
- Webhook processing → Entitlement resolution: updates access
- Entitlement resolution → Policy engine: evaluates rules
- Policy engine → Role-sync workpool: approved role changes
- Role-sync workpool → Discord bot: sync work
- Discord bot → Discord platform: mutates guild roles
- Bun API → Creator package endpoints: package requests
- Creator package endpoints → Object storage: quarantined objects
- Object storage → Ingest and materialize: ingests uploads
- Ingest and materialize → Package catalog: registers artifacts
- Ingest and materialize → Object storage: materializes objects
- Protected delivery worker → Package catalog: resolves package metadata
- Protected delivery worker → Object storage: serves authorized artifacts
- Entitlement resolution → Protected delivery worker: authorizes buyer delivery