1. Front Matter
Title: Reviewers' Commenting System
Author: scorevi/dyorgie (Backend/Frontend)
Reviewers: scorevi/dyorgie (Backend/Frontend)
Created: February 2026
Status: Approved
References:
Issue: [7.1] Commenting System #51
Milestone: [7] Review Workflow
2. Introduction & Goals
Problem Summary: Reviewers need a structured way to leave actionable feedback on specific canvas nodes during quest review, with support for guest SME reviewers, notifications, and analytics.
Goals:
Threaded comments on canvas nodes
Guest SME review via secure invite links
Real-time notifications with badge counts
Bulk operations and CSV export
Comment analytics and heatmaps
Non-Goals:
In-line text editing suggestions
Video/audio comments
External integration (Slack, Teams)
Glossary:
Thread: Parent comment with nested replies
SME: Subject Matter Expert (guest reviewer)
Heatmap: Visual indicator of comment density per node
3. High-Level Architecture
System Diagram:

Technologies Used:
React Context - CommentingContext state
Supabase - Comments, invites, notifications
Zod - API validation schemas
crypto.randomBytes - Secure invite tokens
4. Detailed Design & Implementation
Data Model / Schema:
quest_commentsTable:Column
Type
Description
idUUID PK
Auto-generated
quest_idUUID FK
References
quests.idnode_idTEXT
Canvas node ID
parent_comment_idUUID FK
Self-reference for threading
app_user_idUUID FK
Authenticated author
guest_invite_idUUID FK
Guest author (alt to app_user_id)
contentTEXT
Comment text (max 5000 chars)
is_resolvedBOOLEAN
Resolution status
created_atTIMESTAMPTZ
Auto-set
Constraint:
chk_author_exists- Eitherapp_user_idORguest_invite_idrequiredquest_invitesTable:Column
Type
Description
idUUID PK
Auto-generated
quest_idUUID FK
References
quests.idaccess_tokenTEXT UNIQUE
128-bit secure token
emailTEXT
Invitee's email
display_nameTEXT
Guest's display name
statusTEXT
ACTIVE, REVOKED, EXPIRED
expires_atTIMESTAMPTZ
7-day expiry default
notificationsTable:Column
Type
Description
idUUID PK
Auto-generated
recipient_clerk_idTEXT
User receiving notification
typeTEXT
NEW_COMMENT, REPLY_RECEIVED, etc.
quest_idUUID FK
Related quest
is_readBOOLEAN
Read status
API Specification:
Comments:
GET /api/reviewer/comments- List threaded commentsPOST /api/reviewer/comments/create- Create comment/replyPATCH /api/reviewer/comments/[id]- Toggle resolvedDELETE /api/reviewer/comments/[id]- Delete commentPATCH /api/reviewer/comments/bulk-resolve- Batch resolveGET /api/reviewer/comments/export- CSV export
Invites:
GET /api/reviewer/invites- List invitesPOST /api/reviewer/invites- Generate inviteDELETE /api/reviewer/invites/[id]- Revoke invite
Notifications:
GET /api/notifications/get-notifications- List notificationsPATCH /api/notifications/mark-all-read- Mark all read
Logic & Workflows:
Guest SME Access:
/review/guest?token=<access_token>Guest Permissions:
View canvas - ✅
Post comments - ✅
Resolve comments - ❌
Delete comments - ❌
Rate Limit: 20 comments per token per hour
Key Files:
components/context/CommentingContext.tsx- State managementcomponents/reviewer/CommentPanel.tsx- Main sidebarcomponents/reviewer/CommentThread.tsx- Thread renderingcomponents/reviewer/CommentBadge.tsx- Node indicatorshared/schemas/commentsSchema.ts- Zod schemas
5. Infrastructure & Operations
Dependencies:
Supabase - Comments, invites, notifications
Clerk - User identification
Monitoring & Alerting:
Notification Types: NEW_COMMENT, COMMENT_RESOLVED, REPLY_RECEIVED
Analytics: Per-node heatmaps, resolution metrics
Deployment Plan:
Run migrations for all 3 tables
Deploy API routes
Deploy frontend components
Configure RLS policies
6. Testing & Quality Assurance
Test Strategy:
Manual: Comment CRUD, threading, notifications
Integration: Guest access, invite flow, bulk ops
Security: RLS policy validation
Known Limitations:
Max 5000 chars per comment
Guest rate limit: 20/hour
No rich text formatting
7. Maintenance & Support
Troubleshooting:
Guest token invalid → Check expiry, status in quest_invites
Comments not loading → Verify quest_id, check RLS
Notifications missing → Check recipient_clerk_id match
Changelog:
1.0 (Feb 2026): Initial implementation
1.1 (Feb 2026): Added bulk operations
1.2 (Feb 2026): Added analytics
Document Version
1.2 - Approved, Feature deployed to production, 02/28/2026