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.
Key Features
Section titled “Key Features”- 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)
Page Structure
Section titled “Page Structure”| Route | Purpose |
|---|---|
/business/apps/subscriptions | Dashboard with stats and full plan list |
/business/apps/subscriptions/new | Create a new subscription plan |
/business/apps/subscriptions/[id] | Plan detail with course management and subscriber list |
Dashboard
Section titled “Dashboard”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).
Create Plan
Section titled “Create Plan”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
Plan Detail
Section titled “Plan Detail”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
Data Model
Section titled “Data Model”| Table | Description |
|---|---|
ext_subscriptions.plans | Subscription plan definitions (title, price, interval, status, features) |
ext_subscriptions.plan_courses | Junction table linking plans to courses |
ext_subscriptions.subscribers | Active subscriptions linking users to plans |
Key Types
Section titled “Key Types”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_atPlanWithCourses— Plan with nested courses arrayPlanStats— total_plans, published_plans, total_subscribers, total_revenue
Key Components
Section titled “Key Components”| Component | Location |
|---|---|
| Plan list + stats | src/routes/(app)/business/apps/subscriptions/+page.svelte |
| Create plan form | src/routes/(app)/business/apps/subscriptions/new/+page.svelte |
| Plan detail (courses + subscribers) | src/routes/(app)/business/apps/subscriptions/[id]/+page.svelte |
Services
Section titled “Services”Server-side logic lives in $lib/apps/subscriptions/services/index.js:
getInstructorStats(userId)— aggregate stats for the dashboardlistInstructorPlans(userId, filters)— list all planscreatePlan(userId, data)— create a new plangetPlanWithCourses(id)— fetch plan with attached coursespublishPlan(id)/deletePlan(id)— lifecycle managementaddCourseToPlan(planId, courseId)/removeCourseFromPlan(planId, courseId)— course attachmentlistSubscribers(planId)— subscriber listing
Form Actions
Section titled “Form Actions”Plan Detail ([id])
Section titled “Plan Detail ([id])”| Action | Description |
|---|---|
publish | Publish the plan for purchase |
delete | Delete the plan and redirect to list |
add-course | Attach a course to the plan |
remove-course | Detach a course from the plan |