Per product decision, the sole free allowance is the one-time free project each
user gets at sign-up (utils/usage.project_entitlement). Removed the "+1 project
during the first 30 days of a subscription" bump from get_plan_for_user, so a
subscriber now gets exactly their tier's monthly limit (Professional 3, Business
8, Studio 20).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
feat(billing): free first project per tool, retire Starter tier (3 tiers)
Three product changes requested:
1. Free first project per tool on sign-up. Every new (unsubscribed) user now
gets ONE free project per tool for their whole lifetime, before subscribing.
utils/usage.py: added lifetime_usage() and a free-project branch in
project_entitlement (free_base=1 when base==0 and not admin). billing.py now
derives can_create / project_limit from project_entitlement (single source of
truth) and exposes free_projects.
2. Retired the 50 AED Starter tier -> only 3 paid tiers remain (Professional,
Business, Studio). plans_catalog now excludes tier 1, and /checkout rejects
tier 1 with a 400. PLANS[1] is kept only so existing Starter subs still resolve.
3. Landing / About / Dashboard copy: "1st month (2 projects) free" -> "Start your
1st project for free"; free card shows "Your 1st project free / per tool";
paid cards relabelled TIER 1-3; Dashboard start-bar now shows the create form
to users who still have their free project and only p…
Security:
- /cache is no longer public static files: served via an authenticated route
that verifies a valid session AND project ownership (was an IDOR exposing
confidential drawings). Frontend appends the token to <img> cache URLs.
- verify_session_token now reads role FROM THE DB (not the token), so a
demotion/suspension takes effect immediately instead of persisting 8h.
- Cancel the user's Dodo subscriptions on account deletion (was: keep billing
a deleted account).
- Rate limiter keys on the real client IP (cf-connecting-ip / x-forwarded-for)
instead of the proxy IP, which had made it collective/useless behind Render.
- Upload reads are capped at MAX_UPLOAD_BYTES to prevent memory-exhaustion DoS.
- .dockerignore/.gitignore now exclude the local venv and scratch/debug scripts
(several held hardcoded secrets and were being baked into the image).
Reliability:
- DB errors are logged (were silently printed / swallowed as "no rows").
- New transaction() context manager for a…
fix: auto-heal phantom mock subscriptions on sync
An old checkout-fallback bug seeded free 'active' subscriptions tagged
provider_subscription_id='mock_123' (e.g. a Work Programme Professional/tier-2
plan the user never paid for). auto_sync now cancels those phantom rows for the
user on the next load — targeted by the mock marker so real Dodo-backed
subscriptions are never touched — and busts the plan cache so the correct plan
shows immediately.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two payment-correctness fixes:
1) Add-ons are now ONE-TIME. Previously the extra-project allowance was added
permanently to the monthly limit, so buying one add-on granted +1 project
EVERY month forever. Now the monthly tier quota resets monthly, and each
add-on credit is consumed only when creating a project beyond that quota
(settle_project_creation + consume_extra_project). check_limit/billing expose
a single can_create gate; the dashboard uses it instead of used>=limit.
2) The checkout fallback used to INSERT a free 'manual' active subscription (or
grant a free credit) whenever create_checkout_session raised. On a transient
Dodo error this silently gave users paid plans they never bought (e.g. a
phantom tier-2 Work Programme = 4 projects). Now, when Dodo is configured,
the failure returns 502 instead of granting anything; the mock path only
runs locally when no Dodo key exists.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Subscriptions and add-ons now activate synchronously on return from checkout
instead of depending on webhooks that were failing silently.
- payments.py: resolve Dodo base URL from API-key prefix (kills test/live env
mismatch); deterministic product_id -> (feature, tier) map; synchronous
force_activate (subscriptions via /subscriptions, add-ons via /payments) with
idempotent grants; log instead of silent except:pass.
- billing.py: new POST /activate endpoint; per-tool extra-project allowance via
extra_projects_for(); feature-access "used" now matches the creation gate;
fix missing safe_execute import.
- usage.py: check_limit uses per-tool add-on column for all tools, not just qto.
- features.py: FEATURE_EXTRA_COL + extra_projects_for() helper.
- Dashboard.jsx: call /activate on payment return (retries, add-on aware);
add-on buttons now buy the correct per-tool add-on instead of a tier-1 sub.
- .env.example: document all 15 products (3 tools x 4 tiers + 1 add-on).
Co-Author…
fix: complete payment activation flow - redirect to billing after payment, show activation spinner, poll until subscription is live, show success screen with unlocked projects
perf: Massive speed boost for Step 1 (Upload) and Step 2 (Classification) by bypassing Numpy/PIL and writing native C++ compressed images directly to disk