Prompt
How do I build a documentation portal with approvals and comments?
Latest observation
To build a documentation portal with approvals and comments, think of it as 4 core parts:
- Content management
- Workflow / approvals
- Collaboration / comments
- Search, permissions, and publishing
Here’s a practical way to design it.
1) Define the core user roles
Typical roles:
- Author: creates and edits docs
- Reviewer: comments and approves/rejects
- Approver: final sign-off
- Admin: manages users, permissions, workflows
- Reader: views published docs
You can keep this simple at first with just:
- Draft
- In review
- Approved
- Published
- Rejected
2) Model the document workflow
A good document lifecycle:
-
Draft
- Author creates or edits content
- Comments allowed
- Not visible to everyone
-
Submitted for review
- Locks or soft-locks the doc version
- Reviewer can comment
- Approver can approve/reject
-
Approved
- Version is marked approved
- Can be published automatically or manually
-
Published
- Visible in the portal
- Previous versions remain available if needed
-
Rejected / Needs changes
- Returned to author with reviewer comments
Important: approvals should be tied to a specific version, not just the document generally.
3) Design the data model
At minimum, you’ll want these entities:
Document
idtitleslugcurrentVersionIdstatusownerIdcreatedAtupdatedAt
DocumentVersion
iddocumentIdversionNumbercontentcreatedBycreatedAtstatus(draft, in_review, approved, published, rejected)
Comment
iddocumentVersionIduserIdbodyanchor/location(optional: paragraph, line, section)parentCommentId(for threads)createdAtresolvedAtisResolved
Approval
iddocumentVersionIdapproverIddecision(approved, rejected, pending)reasoncreatedAt
User / Role / Permission
UserRolePermission- optionally
DocumentAccessif permissions vary by doc/team
4) Build the approval workflow
A simple approval system:
- Author clicks Submit for review
- Reviewers/approvers are assigned
- They can:
- approve
- reject
- comment
- request changes
Useful rules:
- Approval can require 1 of N, all of N, or sequential approval
- Only the latest version can be approved
- If content changes after approval, set status back to draft or in review
- Keep audit history of who approved what and when
5) Add commenting support
Two common comment types:
A. General document comments
Comments on the whole document.
B. Inline comments
Comments attached to specific text or sections.
For inline comments, store:
- section ID
- paragraph index
- character offsets
- block ID
- or a DOM anchor if using a rich text editor
Features to include:
- threaded replies
- resolve/unresolve
- mention users with
@name - notifications on reply/mention
- audit log of comment changes
6) Choose a content editor
For docs, use a rich text or markdown editor depending on your needs.
Good options:
- Markdown editor if docs are technical and text-heavy
- Rich text editor if you need formatting similar to Word/Confluence
Popular editors:
- TipTap
- CKEditor
- ProseMirror
- Slate
- Quill
If you want inline comments, pick an editor that supports:
- document structure
- stable node IDs
- selection anchoring
7) Implement permissions carefully
Common access rules:
- Authors can edit drafts they own
- Reviewers can comment on submitted docs
- Approvers can approve/reject
- Readers can only view published docs
Add document-level permissions if needed:
- private docs
- team-only docs
- department-specific docs
Always check permissions on both:
- the API
- the UI
8) Build the backend APIs
Typical endpoints:
Documents
POST /documentsGET /documentsGET /documents/:idPUT /documents/:idDELETE /documents/:id
Versions
POST /documents/:id/versionsGET /documents/:id/versionsGET /versions/:versionId
Workflow
POST /versions/:id/submitPOST /versions/:id/approvePOST /versions/:id/rejectPOST /versions/:id/publish
Comments
POST /versions/:id/commentsGET /versions/:id/commentsPOST /comments/:id/repliesPATCH /comments/:id/resolve
Notifications
GET /notificationsPOST /notifications/read
9) Add audit logs
For approval-heavy systems, audit logs are important.
Track:
- who edited
- who commented
- who approved/rejected
- status changes
- timestamps
- old/new values
This helps with accountability and compliance.
10) Add search and version history
A docs portal is much more useful with:
- full-text search
- filter by category, status, owner, tag
- version history
- diff view between versions
- restored previous versions
Search can be done with:
- PostgreSQL full-text search for small/medium apps
- Elasticsearch/OpenSearch for larger portals
11) Suggested architecture
A common stack:
Frontend
- React / Next.js
- Rich text editor
- Comment sidebar
- Review/approval controls
Backend
- Node.js / NestJS / Express
- REST or GraphQL API
- PostgreSQL
Storage
- PostgreSQL for docs metadata and workflow
- S3 or blob storage if attachments are allowed
Optional
- Redis for notifications / queues
- Search engine for document search
- WebSocket or SSE for live comment updates
12) Example workflow in the UI
For an author:
- Create document
- Edit content
- Save draft
- Submit for review
For a reviewer:
- Open doc in review mode
- Leave inline comments
- Resolve threads
- Approve or request changes
For a reader:
- Browse published docs
- Search
- View version history
13) Things people often miss
A few important details:
- Version immutability after approval
- Comment anchoring that survives edits
- Notifications for review requests and replies
- Draft autosave
- Draft locking or conflict resolution for multiple editors
- Soft delete for audit/compliance
- Published vs approved are not always the same thing
- Backups and access control if docs are sensitive
14) A simple MVP plan
If you want to build this quickly, start with:
MVP features
- create/edit docs
- versioning
- submit for review
- approve/reject
- basic comments
- published/unpublished status
- role-based access
Later improvements
- inline comments
- threaded discussions
- notifications
- search
- diff viewer
- analytics
- templates
15) Recommended implementation order
- Authentication and roles
- Document CRUD
- Versioning
- Approval workflow
- Commenting
- Publishing
- Search
- Audit logs
- Notifications
- Inline comments and advanced workflow
If you want, I can also provide:
- a database schema
- a system architecture diagram
- a sample API design
- or a Next.js + Node.js starter implementation