diff --git a/PlotLine/Docs/Architecture/Phase5-MultiUser-Subscription-Architecture.md b/PlotLine/Docs/Architecture/Phase5-MultiUser-Subscription-Architecture.md new file mode 100644 index 0000000..26ff295 --- /dev/null +++ b/PlotLine/Docs/Architecture/Phase5-MultiUser-Subscription-Architecture.md @@ -0,0 +1,262 @@ +# PlotWeaver Studio + +# Phase 5 -- Multi-User, Collaboration & Subscription Architecture + +Version: 1.0\ +Status: Approved Architecture Document\ +Date: June 2026 + +## Purpose + +Phase 5 introduces multi-user support, subscriptions, collaboration +capabilities, storage management, auditing, and monetisation foundations +to PlotWeaver Studio. + +The goal is to transform PlotWeaver Studio from a single-user authoring +platform into a secure SaaS application while preserving its core +philosophy as a planning and writing workspace for authors. + +## Core Principles + +- PlotWeaver Studio is an active workspace, not a permanent archive. +- Security takes precedence over convenience. +- Collaboration supports planning, not real-time writing. +- Subscription limits should be generous but prevent abuse. + +## Definitions + +### User + +Authenticated account holder within PlotWeaver Studio. + +### Project + +Highest-level container which may represent a standalone book or an +entire series. + +### Book + +A single book within a project. Subscription limits are enforced against +books. + +### Owner + +The user who created a project and manages collaborators. + +### Collaborator + +A user granted edit access to another user's project. + +### Subscription + +Defines usage limits and capabilities. + +## Security Architecture + +Project access shall be determined through ProjectUserAccess records. + +Access checks must answer: + +> Can this user access this project? + +Not: + +> Does this user own this project? + +### Access Roles + +#### Owner + +- Full project access +- Invite/remove collaborators +- Delete projects +- Export projects + +#### Collaborator + +- View projects +- Edit projects + +Restrictions: - Cannot delete projects - Cannot invite collaborators - +Cannot transfer ownership - Cannot manage subscriptions + +Viewer-only access is explicitly excluded from Phase 5. + +### ProjectUserAccess + +Fields: + +- ProjectUserAccessID +- ProjectID +- UserID +- AccessRole +- InvitedByUserID +- InvitedDateUTC +- AcceptedDateUTC +- IsActive + +All project-scoped operations must validate user access. + +Protected areas include: + +- Projects +- Books +- Chapters +- Scenes +- Timeline +- Characters +- Assets +- Locations +- Plot Lines +- Relationships +- Workspace +- Imports +- Exports +- Attachments + +## Subscription Levels + +### Draft Desk + +- Books: 2 +- Chapters per Book: 75 +- Scenes per Book: 300 +- Characters per Project: 75 +- Storage: 100 MB +- Collaborators: 0 + +### Writing Room + +- Books: 10 +- Chapters per Book: 150 +- Scenes per Book: 1000 +- Characters per Project: 250 +- Storage: 1 GB +- Collaborators: 1 + +### Story Forge + +- Books: 30 +- Chapters per Book: 200 +- Scenes per Book: 2000 +- Characters per Project: 500 +- Storage: 5 GB +- Collaborators: 3 + +### Author Studio + +- Books: Practical unlimited +- Chapters: Practical unlimited +- Scenes: Practical unlimited +- Characters: Practical unlimited +- Storage: 20 GB +- Collaborators: 10 + +## Collaboration Requirements + +Supported: + +- Invite collaborators +- Remove collaborators +- View collaborator lists + +Excluded: + +- Real-time editing +- Internal messaging +- Viewer-only roles +- Conflict resolution +- Ownership transfer + +## Audit Requirements + +Major entities should support: + +- CreatedByUserID +- CreatedDateUTC +- ModifiedByUserID +- ModifiedDateUTC + +Track activity for: + +- Projects +- Books +- Chapters +- Scenes +- Characters +- Assets +- Locations +- Plot Lines +- Relationships + +The audit system should answer: + +> Who changed what and when? + +## Storage Management + +- Storage tracked per user +- Limits enforced by subscription +- Restrict file types +- Resize uploaded images +- Convert images to WebP +- Remove unnecessary metadata + +Timeline and planning interfaces should remain fast and primarily +text-based. + +## Export and Archiving + +Projects should support export including: + +- Project data +- Images +- Attachments + +Archive workflow: + +1. Export project +2. Offer download +3. Remove from active workspace + +## Payment Integration + +Stripe will be introduced only after: + +- Security is complete +- Subscription infrastructure exists +- Limit enforcement is operational + +## Phase 5 Implementation Order + +1. Phase 5A -- Project Ownership & Security +2. Phase 5B -- Subscription Infrastructure +3. Phase 5C -- Subscription Limit Enforcement +4. Phase 5D -- Collaboration Foundation +5. Phase 5E -- Audit History & Activity Tracking +6. Phase 5F -- Storage Management +7. Phase 5G -- Export & Archiving +8. Phase 5H -- Subscription Management UI +9. Phase 5I -- Stripe Payment Integration + +## Out of Scope + +- Real-time collaborative editing +- Internal messaging systems +- Viewer-only roles +- AI collaboration workflows +- Team organisations +- Ownership transfer +- Conflict resolution systems + +## Success Criteria + +Phase 5 is complete when: + +- Project access is secure +- Subscription limits are enforced +- Collaboration functions safely +- Audit history is available +- Storage limits are operational +- Projects can be exported and archived +- Payment processing is integrated successfully