Subscriptions & Plans — Code Map
API
apps/api/src/plans/
plans.module.tsplans.controller.ts—@Controller('organizations/:orgId/plans').RequiresFeature('membership_plans')on mutating routes.plans.service.ts—create | findAll | findById | update | remove | purchase. InternalrequireFeaturehelper for service-layer tier checks.plans.service.unit.spec.ts— unit tests.dto/create-plan.dto.tsupdate-plan.dto.tspurchase-plan.dto.ts—{ successUrl, cancelUrl }.
apps/api/src/subscriptions/
subscriptions.module.tssubscriptions.controller.ts— both member-scoped (/subscriptions/my/*) and admin-scoped (/subscriptions/:id/*) routes.subscriptions.service.ts— lifecycle. IncludessweepDueCancellationsinvoked by the cron.cancellation-cron.service.ts—@Cron('30 2 * * *')flipscancel_at_period_endrows tocancelled.cancellation-requests.controller.ts— request submission + owner approve/reject.cancellation-requests.service.ts— owns thecancellation_requeststable lifecycle.cancellation-flow.int.spec.ts— integration test for the full request → approve → refund handshake.dto/enroll-member.dto.ts
Web (apps/web/src/)
app/[lang]/(protected)/dashboard/plans/— plan CRUD UI.app/[lang]/(protected)/dashboard/payments/— owner-side payments console (includes a Cancellations tab driven bycomponents/payments/cancellation-requests-list.tsx).app/[lang]/(protected)/dashboard/members/— admin sub view, freeze/cancel actions.components/subscriptions/cancel-subscription-dialog.tsx— member-facing self-cancel UI.components/payments/cancellation-requests-list.tsx— owner approve/reject UI.components/payments/cancellations-widget.tsx— dashboard counts (pending requests + scheduled cancels).components/member/plan-card.tsx— member-facing subscription summary.
Shared
libs/shared/src/lib/schemas/plan.schema.ts— Zod schemas forPlanResponse.libs/shared/src/lib/schemas/membership.schema.ts—SubscriptionResponse,SubscriptionWithPlan.
DB
libs/db/src/lib/schema/payments.ts—plans,subscriptions,cancellation_requests.libs/db/src/lib/schema/enums.ts—planType,planInterval,subscriptionStatus,cancellationRequestStatus,membershipPaymentStatus.libs/db/src/lib/schema/memberships.ts—memberships.paymentStatusis mutated by the renewal cron + webhook processor.
Notifications
apps/api/src/notifications/cancellation-notifications.service.ts—cancellationScheduled,cancellationRequestSubmitted,cancellationRequestApproved,cancellationRequestRejected,newCancellationRequestForOwner,refundCompleted.apps/api/src/notifications/templates/payment-failed.ts,debt-warning.ts,payment-receipt.ts.
Cross-references
apps/api/src/payments/services/webhook-processing.service.ts— mutatessubscriptionson payment events.apps/api/src/payments/services/recurring-charge.service.ts— mutatessubscriptionsandmemberships.paymentStatusdaily.apps/api/src/bookings/— callssubscriptionsService.deductCredit / refundCredit.apps/api/src/courses/course-checkout.service.ts— usesplan.type='course'rows, bypassesplans.purchase.