feat: PII Export & Delete Workflow (GDPR-ready) (#76)#464
Open
qiridigital wants to merge 1 commit intorohitdash08:mainfrom
Open
feat: PII Export & Delete Workflow (GDPR-ready) (#76)#464qiridigital wants to merge 1 commit intorohitdash08:mainfrom
qiridigital wants to merge 1 commit intorohitdash08:mainfrom
Conversation
- Backend: services/privacy.py with export_user_data() collecting all
user records (profile, categories, expenses, recurring, bills, reminders,
subscriptions, audit logs) and delete_user_data() for irreversible
account deletion with anonymised audit trail
- Backend:
outes/privacy.py with:
- GET /privacy/export – GDPR Art. 20 data portability
- POST /privacy/delete – GDPR Art. 17 right to erasure (requires
explicit {confirm: true} in body)
- Frontend: �pi/privacy.ts typed API client
- Frontend: Account page updated with Data Privacy section:
- Export My Data button (downloads JSON file)
- Delete My Account with two-step confirmation
- Clears auth tokens and redirects to sign-in on deletion
- Tests: est_privacy.py with 8 tests covering export (empty, seeded,
auth), delete (confirmation required, no body, full delete, auth,
irreversibility)
- Blueprint registered at /privacy prefix
- Cache invalidation on delete
Closes rohitdash08#76
There was a problem hiding this comment.
Pull request overview
Implements a GDPR-oriented “export my data” and “delete my account” workflow across backend + frontend, with automated tests to validate expected behaviors.
Changes:
- Added backend privacy service + routes for PII export (
GET /privacy/export) and irreversible deletion (POST /privacy/delete). - Added frontend API helpers and Account page UI for exporting a JSON file and performing a confirmed delete.
- Added backend test suite coverage for export/delete scenarios.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/backend/app/services/privacy.py | Implements cross-model export + user data deletion with audit logging. |
| packages/backend/app/routes/privacy.py | Exposes authenticated privacy endpoints and cache invalidation on delete. |
| packages/backend/app/routes/init.py | Registers the new /privacy blueprint. |
| packages/backend/tests/test_privacy.py | Adds tests covering export correctness, auth requirements, and deletion behavior. |
| app/src/api/privacy.ts | Adds frontend API calls for export/delete. |
| app/src/pages/Account.tsx | Adds “Data Privacy” UI section with export + two-step delete confirmation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return jsonify(error="user not found"), 404 | ||
|
|
||
| # Invalidate all cached data for this user | ||
| cache_delete_patterns([f"user:{uid}:*"]) |
| return jsonify(error="user not found"), 404 | ||
|
|
||
| # Invalidate all cached data for this user | ||
| cache_delete_patterns([f"user:{uid}:*"]) |
Comment on lines
+80
to
+81
| a.click(); | ||
| URL.revokeObjectURL(url); |
Comment on lines
+12
to
+21
| from ..models import ( | ||
| AuditLog, | ||
| Bill, | ||
| Category, | ||
| Expense, | ||
| RecurringExpense, | ||
| Reminder, | ||
| User, | ||
| UserSubscription, | ||
| ) |
Comment on lines
+160
to
+167
| # Delete child records explicitly for databases without CASCADE support | ||
| Reminder.query.filter_by(user_id=user_id).delete() | ||
| Expense.query.filter_by(user_id=user_id).delete() | ||
| RecurringExpense.query.filter_by(user_id=user_id).delete() | ||
| Bill.query.filter_by(user_id=user_id).delete() | ||
| Category.query.filter_by(user_id=user_id).delete() | ||
| UserSubscription.query.filter_by(user_id=user_id).delete() | ||
| AuditLog.query.filter_by(user_id=user_id).delete() |
Comment on lines
+155
to
+157
| # Log the deletion request before wiping data | ||
| db.session.add( | ||
| AuditLog(user_id=None, action=f"GDPR_DELETE:user_id={user_id}") |
Comment on lines
+161
to
+167
| Reminder.query.filter_by(user_id=user_id).delete() | ||
| Expense.query.filter_by(user_id=user_id).delete() | ||
| RecurringExpense.query.filter_by(user_id=user_id).delete() | ||
| Bill.query.filter_by(user_id=user_id).delete() | ||
| Category.query.filter_by(user_id=user_id).delete() | ||
| UserSubscription.query.filter_by(user_id=user_id).delete() | ||
| AuditLog.query.filter_by(user_id=user_id).delete() |
Comment on lines
+48
to
+51
| categories = [ | ||
| {"id": c.id, "name": c.name, "created_at": _serialize_date(c.created_at)} | ||
| for c in Category.query.filter_by(user_id=user_id).all() | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the GDPR PII Export & Delete Workflow as described in #76.
Acceptance Criteria
Backend
services/privacy.py
routes/privacy.py
Frontend
api/privacy.ts
Account Page Updates
Tests (test_privacy.py)
8 tests covering:
/claim #76