PlotDirector/PlotLine/Docs/Features/Hard_Deletion_Requirements.md
2026-06-11 19:15:12 +01:00

248 lines
5.9 KiB
Markdown

# Feature Specification: Hard Deletion of Projects and User Accounts
## Overview
PlotDirector currently supports archiving projects, allowing users to temporarily remove projects from their active workspace while retaining the ability to restore them later.
Archived projects continue to count towards the user's subscription allowance because they remain fully recoverable.
This feature introduces two related capabilities:
1. Permanent deletion of archived projects
2. Permanent deletion of user accounts
Both features are designed to:
- Comply with UK GDPR "right to erasure" expectations.
- Reduce unnecessary storage usage.
- Give users confidence that they maintain control over their data.
- Simplify account management.
## Permanent Project Deletion
### Current Behaviour
- Projects can be archived.
- Archived projects can be restored.
- Archived projects continue to count towards subscription limits.
- No mechanism exists to permanently remove projects.
### New Requirement
Users must be able to permanently delete archived projects.
Deletion is irreversible.
Once deleted:
- The project cannot be restored.
- All associated data must be removed.
- Subscription project counts should update immediately.
### Preconditions
Projects may only be permanently deleted if:
`Project.Status == Archived`
Users must archive a project before deleting it.
| State | Meaning |
|--------|----------|
| Active | Normal working project |
| Archived | Hidden but recoverable |
| Deleted | Permanently removed |
### User Interface Requirements
Within the Archived Projects page:
- Add a **Delete Permanently** button.
- Use danger styling.
- Require explicit confirmation.
### Confirmation Modal
Display:
> Permanently delete this project?
>
> This will permanently remove the project and all associated data including books, chapters, scenes, characters, locations, assets, plot threads, notes, metrics, attachments and uploaded files.
>
> This action cannot be undone.
Require the user to type the project name before enabling deletion.
### Data Deletion Requirements
Delete all database records associated with the project including future child entities.
Delete all project-related files including:
- Uploaded images
- Attachments
- Documents
- Export files
- Generated assets
- Project storage folders
### Subscription Impact
Following successful deletion:
- Project counts must be recalculated immediately.
- The deleted project should no longer count against subscription allowances.
### Technical Recommendation
Implement:
```csharp
Task HardDeleteProjectAsync(int projectId, string userId);
```
Responsibilities:
1. Verify ownership.
2. Verify project is archived.
3. Delete physical files.
4. Delete database records.
5. Update subscription/project counts.
6. Log deletion activity.
---
## User Account Deletion
### Overview
Users must be able to permanently close their PlotDirector account.
Account deletion is irreversible.
The process must remove all user-generated content from PlotDirector systems.
### Subscription Rules
Users cannot delete their account while an active paid subscription exists.
Display:
> You currently have an active paid subscription.
>
> Please cancel your subscription from the Subscription page before closing your account.
>
> Once your subscription has ended and your account has returned to trial or free access, you may permanently delete your account.
Provide a Manage Subscription link.
### Trial Users
PlotDirector does not create Stripe subscriptions for trial users.
Users may delete their account immediately if they are using:
- Free tier
- Active trial
- Expired trial
- Cancelled subscription state
- Expired subscription state
### Allowed Deletion States
- TrialActive
- TrialExpired
- Free
- Cancelled
- Expired
- Inactive
- PaymentFailedCancelled
### Blocked Deletion States
- ActivePaidSubscription
- PastDue
- CancellationPending
### User Interface Requirements
Within Account Settings add a Danger Zone section.
Display:
> Permanently close your PlotDirector account.
>
> This action cannot be undone.
>
> All projects, files and account information will be permanently removed.
Provide a Delete Account button.
### Confirmation Modal
Display:
> Permanently close your account?
>
> This will:
> - Delete all projects
> - Delete all uploaded files
> - Delete all account information stored by PlotDirector
> - End any active trial access
>
> This action cannot be undone.
Require users to type their email address before continuing.
### Account Deletion Process
1. Verify no active paid subscription exists.
2. Retrieve all user projects.
3. Execute `HardDeleteProjectAsync(...)` for each project.
4. Remove remaining user-owned records:
- Subscription records
- Trial information
- Preferences/settings
- Notifications
- Tokens
- API keys (future)
5. Delete ASP.NET Identity user record.
6. Sign the user out.
### Stripe Considerations
Stripe records relating to completed commercial transactions may continue to exist within Stripe for legal, accounting and tax purposes.
These records are external to PlotDirector and do not prevent local account deletion.
PlotDirector should retain no personally identifiable user data after deletion unless legally required.
## Design Principles
### Archive ≠ Delete
Archive means:
- Hidden
- Recoverable
- Counts towards subscription limits
Delete means:
- Permanent
- Irrecoverable
- Removes subscription usage
### Account Deletion Philosophy
The process should be:
- Clear
- Explicit
- Difficult to trigger accidentally
- Simple to understand
Users should have confidence that choosing to leave PlotDirector genuinely removes their data.
## Future Considerations
Potential enhancements:
- 30-day deletion grace period
- Export project data before deletion
- Email confirmation before account closure
- Administrative deletion tools
- Background processing for very large deletions
These enhancements are not required for the initial implementation.