mirror of
https://github.com/Afilmory/afilmory
synced 2026-04-24 23:05:05 +00:00
- Added support for billing plan products and pricing settings, allowing for detailed configuration of subscription plans. - Introduced new constants and types for managing billing plan overrides, products, and pricing. - Updated the SystemSettingService to handle new billing-related settings and integrated them into the admin interface. - Enhanced the BillingPlanService to retrieve and apply product and pricing information for tenant plans. - Updated UI components to reflect the new billing plan configurations and ensure proper display of pricing details. Signed-off-by: Innei <tukon479@gmail.com>
2.9 KiB
2.9 KiB
Billing Plans & Quota Strategy
This document tracks the current subscription plans, quota knobs, and the design approach that backs the enforcement code in be/apps/core.
Goals
- Offer predictable resource guarantees (library size, upload size, sync object size, monthly processing) per plan.
- Decouple plan defaults from tenant-specific overrides so superadmins can hotfix limits without redeploys.
- Keep room for future self-serve subscriptions while allowing manual override flows during private beta.
Plan Catalog (2024-xx-xx)
| Plan ID | Label | Availability | Monthly Process Limit | Library Items | Upload Size (MB) | Sync Object (MB) | Notes |
|---|---|---|---|---|---|---|---|
free |
Free | Default for new orgs | 300 | 500 | 20 | 50 | Soft cap for testing & hobby users. |
pro |
Pro | Upcoming public tier | 1,000 | 5,000 | 200 | 500 | Placeholder numbers; tune before launch. |
friend |
Friend (Internal) | Manual via superadmin | Unlimited (null) | Unlimited | Unlimited | Unlimited | Private plan for friends/internal testers; never exposed in product UI. |
Unlimited==nullin the DB schema, meaning enforcement is skipped for that quota dimension.
Design Notes
- Plan definitions live in
billing-plan.constants.ts. Each entry carries human-friendly metadata for the super-admin dashboard plus aquotasobject. - Overrides are stored under
system.billing.planOverrides. This is a JSON blob keyed by plan id. It is parsed through zod (SystemSettingService.getBillingPlanOverrides) and merged in the billing plan service. - Payment product mapping lives in
system.billing.planProducts. Each plan id can map to provider specific identifiers (e.g.creemProductId). Plans that require checkout (likepro) stay hidden until a product id is configured, which prevents exposing upgrade buttons in environments that are not ready. - Tenant assignment is tracked via
tenant.plan_idand can only be changed by superadmins (see/super-admin/tenantsbackend+dashboard). The Friend plan is intentionally absent from any public selector. - Quota enforcement is performed in:
PhotoAssetService(manual upload size + library limit + monthly process allowance)DataSyncService(sync object size, library headroom, monthly process allowance)
- Usage accounting leverages
billing_usage_eventrows, so adding new quota dimensions is mostly a matter of emitting/aggregating the corresponding events.
Future ideas: surface plan metadata in the dashboard, wire plans to Stripe/Billing provider, and allow per-tenant overrides directly in the admin UI.