Skip to content

Subscriptions

The Subscriptions app lets instructors create recurring subscription plans that grant subscribers access to bundled courses. Plans support multiple billing intervals, feature lists, and a full draft/published/inactive lifecycle with revenue tracking.

  • Create subscription plans with monthly, quarterly, or yearly billing intervals
  • Feature list builder for plan marketing pages
  • Course bundling — attach courses to a plan for subscriber access
  • Draft / Published / Inactive status lifecycle
  • Subscriber listing per plan
  • Dashboard stats: total plans, published count, total subscribers, and revenue
  • Pricing displayed per interval (e.g., $9.99/mo, $24.99/qtr, $89.99/yr)
RoutePurpose
/business/apps/subscriptionsDashboard with stats and full plan list
/business/apps/subscriptions/newCreate a new subscription plan
/business/apps/subscriptions/[id]Plan detail with course management and subscriber list

The main page displays four stat cards (Total Plans, Published, Subscribers, Revenue) and a complete list of all plans. Each plan row shows the title, billing interval, subscriber count, creation date, formatted price per interval, and a status badge (draft/published/inactive).

The creation form uses sveltekit-superforms with createPlanSchema validation. Fields include:

  • Title and Description
  • Price and Compare price (for showing discounts)
  • Billing interval — Monthly, Quarterly, or Yearly
  • Features — dynamic list builder with add/remove controls; features are stored as a string array
  • Thumbnail URL

The [id] detail page is the plan management hub. It loads the plan with its attached courses, the subscriber list, and the instructor’s full course catalog (for adding courses). Available actions:

  • Publish — make the plan available for purchase
  • Delete — remove the plan with redirect to list
  • Add course — attach an existing course to the plan
  • Remove course — detach a course from the plan
TableDescription
ext_subscriptions.plansSubscription plan definitions (title, price, interval, status, features)
ext_subscriptions.plan_coursesJunction table linking plans to courses
ext_subscriptions.subscribersActive subscriptions linking users to plans
  • Plan — id, instructor_id, title, slug, description, price, compare_price, interval (monthly | quarterly | yearly), status (draft | published | inactive), features (string[]), thumbnail_url, subscriber_count, created_at
  • PlanWithCourses — Plan with nested courses array
  • PlanStats — total_plans, published_plans, total_subscribers, total_revenue
ComponentLocation
Plan list + statssrc/routes/(app)/business/apps/subscriptions/+page.svelte
Create plan formsrc/routes/(app)/business/apps/subscriptions/new/+page.svelte
Plan detail (courses + subscribers)src/routes/(app)/business/apps/subscriptions/[id]/+page.svelte

Server-side logic lives in $lib/apps/subscriptions/services/index.js:

  • getInstructorStats(userId) — aggregate stats for the dashboard
  • listInstructorPlans(userId, filters) — list all plans
  • createPlan(userId, data) — create a new plan
  • getPlanWithCourses(id) — fetch plan with attached courses
  • publishPlan(id) / deletePlan(id) — lifecycle management
  • addCourseToPlan(planId, courseId) / removeCourseFromPlan(planId, courseId) — course attachment
  • listSubscribers(planId) — subscriber listing
ActionDescription
publishPublish the plan for purchase
deleteDelete the plan and redirect to list
add-courseAttach a course to the plan
remove-courseDetach a course from the plan