Skip to content

feat(demo): cap public demo user at 5 owned workspaces#103

Merged
victorsoriadrp merged 1 commit into
mainfrom
feat/demo-workspace-quota
Jul 6, 2026
Merged

feat(demo): cap public demo user at 5 owned workspaces#103
victorsoriadrp merged 1 commit into
mainfrom
feat/demo-workspace-quota

Conversation

@victorsoriadrp

Copy link
Copy Markdown
Contributor

Summary

Pragmatic launch-day protection: the public demo user (`demo@archipulse.org`) is capped at 5 owned workspaces. Prevents pollution of the shared demo instance from viral traffic when the anchor video ships on 2026-07-06.

Behavior

When the demo user tries to create a sixth workspace:

The message converts the limit into an adoption CTA. Non-demo users are unaffected.

Changes

  • `workspace.Store`: new `CountOwnedByUser(userID)` method (owner-role only).
  • `workspace_handler.create`: quota gate before `Store.Create` when `svc.Cfg.DemoMode` is true and `claims.Email == svc.Cfg.DemoEmail`.
  • `demoUserWorkspaceQuota = 5` package-level constant.

Explicit tech debt

This hardcodes the demo email in a handler — not the right long-term design. Issue #102 tracks the proper refactor to a Plans + Quotas system that applies to all users.

Marked with a TODO(#102) comment. When #102 lands, the entire `if claims.Email == ... DemoEmail` block gets replaced by a generic quota middleware and this constant deleted.

Also protects

  • Cloudflare rate limit already in place at edge (100 req / 10s / IP) → catches bots.
  • This PR adds app-level protection → catches human abusers or slow bots that pass the rate limit.

Test plan

  • After deploy, log in as demo user, create 5 workspaces → all succeed.
  • Try to create 6th → HTTP 429 with CTA message.
  • Delete one demo workspace → creating a new one succeeds again.
  • Non-demo users can still create workspaces without limit.

Deploy notes

Must be propagated to the `demo` branch after merge to main so Railway rebuilds. See [[reference-deploy-branches]] in memory.

Prevents pollution of the shared public demo instance from viral traffic
after the anchor video launches. When the demo user tries to create a
sixth workspace, the API returns 429 with a friendly CTA pointing to
GitHub for self-hosted deployment.

This is intentional tech debt hardcoded to the demo email — see issue
#102 for the planned refactor to a proper plans/quotas system that
applies to all users, not just demo.

- workspace.Store: new CountOwnedByUser method for owner-role counting.
- workspace_handler.create: quota gate before Store.Create when the
  caller is the configured demo user (svc.Cfg.DemoEmail) and demo mode
  is enabled. Returns HTTP 429 with a message that converts the limit
  into an adoption CTA ("star us on GitHub").
- Quota is a package-level constant (demoUserWorkspaceQuota = 5) that
  will be removed together with the hardcode when #102 lands.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 6, 2026

Copy link
Copy Markdown

Deploying archipulse with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1efb0e8
Status: ✅  Deploy successful!
Preview URL: https://fd1c2fb1.archipulse.pages.dev
Branch Preview URL: https://feat-demo-workspace-quota.archipulse.pages.dev

View logs

@victorsoriadrp
victorsoriadrp merged commit 11ebdc4 into main Jul 6, 2026
2 checks passed
@victorsoriadrp
victorsoriadrp deleted the feat/demo-workspace-quota branch July 6, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant