Skip to content

Subscription Management


Plans

Plan Storage Duration Notes
FREE 25 GB Indefinite Default for all new users
DAILY Configurable 1 day Admin-assigned
WEEKLY Configurable 7 days Admin-assigned
MONTHLY Configurable 30 days Admin-assigned
YEARLY Configurable 365 days Admin-assigned

Storage limit per plan is set per-user via user.storage_limit (in GB).


Current Workflow (Pre-Razorpay)

All plan assignments are manual via admin panel:

  1. Admin Panel → User Management → Select user
  2. Change plan_opted to target plan
  3. Set storage_limit to the plan's GB allowance
  4. Save — user immediately sees updated plan and storage

UserSubscription Model

File: lenzeye_UserSubscription.py

Column Type Description
id Integer PK
user_id Integer FK User this subscription belongs to
plan String Plan name (FREE, DAILY, etc.)
started_at DateTime When subscription started
expires_at DateTime When subscription expires (null for FREE)
is_active Boolean Currently active flag
payment_id String Razorpay payment ID (when integrated)

Subscription Guard

File: subscription_guard.py

A decorator that blocks access to paid features if subscription is expired:

python @subscription_required(plans=['MONTHLY', 'YEARLY']) def premium_feature(): ...

  • Checks user.plan_opted and subscription expiry
  • Redirects to upgrade page if plan insufficient
  • Returns 403 JSON response for API routes

Storage Enforcement

File: subscription_utils.py

python def check_storage_limit(user_email: str, upload_size_bytes: int) -> bool: user = User.query.filter_by(email=user_email).first() storage_used_gb = user.storage_used storage_limit_gb = user.storage_limit upload_size_gb = upload_size_bytes / (1024 ** 3) return (storage_used_gb + upload_size_gb) <= storage_limit_gb

Called at upload initiation. If storage would be exceeded, upload is rejected with a clear error message.


Guest Upload Monthly Reset

File: guest_upload_monthly_reset.py

  • Resets per-user guest upload counters on the 1st of each month
  • Tracks: total files received, total data received in current month
  • Scheduled via Celery beat (monthly cron)
  • Used for monitoring, not for access control

Razorpay Integration (In Progress)

When complete, Razorpay will enable self-service:

User selects plan → Razorpay checkout → Payment webhook → Flask updates plan

Config file: razorpay_config.py

python import razorpay client = razorpay.Client(auth=(RAZORPAY_KEY_ID, RAZORPAY_KEY_SECRET))

Status: Configuration complete. Webhook handler and plan update logic in progress. Activated when enable_razorpay_payment=True in AdminControlFlags.


TL;DR

Plans: FREE (25 GB, default), DAILY/WEEKLY/MONTHLY/YEARLY (admin-assigned). Storage enforcement: check_storage_limit() at upload initiation. Current assignment: Manual via admin panel. Razorpay: Config ready, webhook in progress, activated via feature flag.