Skip to content

Self hosting Comments Data - #24

Merged
yoen-velt merged 6 commits into
mainfrom
self-hosting-dashboard
Dec 19, 2025
Merged

yoen-velt merged 6 commits into
mainfrom
self-hosting-dashboard

Conversation

@yoen-velt

@yoen-velt yoen-velt commented Dec 18, 2025 •

Copy link
Copy Markdown
Contributor

Pull Request

Description

Type of Change

  • New demo application
  • Bug fix
  • Feature enhancement
  • Documentation update
  • Infrastructure/tooling change
  • Other (please describe):

Monorepo Structure Checklist

If adding a new demo, ensure you've followed the 5-level structure:

  • Placed in correct path: apps/<framework>/<document>/<type>/<implementation>/<library-or-solution>/<demo>/
  • Updated package.json with scoped name: @apps/<framework>-<document>-<library-or-solution>-<demo>
  • Created comprehensive README.md in the demo directory
  • Verified build passes: pnpm --filter <package-name> build
  • Verified dev server runs: pnpm --filter <package-name> dev

Deployment Checklist

If this demo should be deployed:

  • Added/updated Vercel project configuration
  • Updated GitHub Actions workflows (if applicable)
  • Verified deployment paths in CI/CD configs

Testing

  • Tested locally with pnpm -w install && pnpm -w build
  • Verified all affected apps still build
  • Tested dev servers for affected apps

Documentation

  • Updated relevant documentation (if needed)
  • Added demo to master-sample-app (if applicable)
  • Updated deployment docs (if applicable)

Related Issues

Screenshots/Videos

Additional Context


For Reviewers

Demo Location

Path: apps/<framework>/<document>/<type>/<implementation>/<library-or-solution>/<demo>/

Package name: @apps/<...>

How to Test

# Install dependencies
pnpm -w install

# Run the specific demo
pnpm --filter @apps/<package-name> dev

# Build the specific demo
pnpm --filter @apps/<package-name> build

Structure Verification

The demo follows the 5-level hierarchy:

  1. Framework:
  2. Document:
  3. Type:
  4. Implementation:
  5. Library/Solution:
  6. Demo:

Documentation: See README_MONOREPO.md and docs/structure.md for more details on the monorepo structure.


Note

Adds a MongoDB-backed self-hosted comments implementation with API routes and data provider for the dashboard demo, and removes the open-envoy demo.

  • Backend (Self-hosting):
    • Add MongoDB-backed store app/api/velt/comments/store.ts and Next.js API routes: comments/get, comments/save, comments/delete.
  • Frontend (Dashboard demo):
    • Wire self-hosted comment data via commentDataProvider in VeltProvider and integrate inline comments (VeltInlineCommentsSection, VeltCommentTool, VeltCommentBubble) with context metadata.
    • Add/adjust collaboration setup (VeltCollaboration, initialize document/user) and UI customizations.
  • App Structure:
    • New demo at apps/react/comments/dashboard/self-hosting/dashboard-mongo-db-demo with full layout, components, and styles.
  • Dependencies:
    • Add mongodb@^7 and related lockfile entries.
  • Cleanup:
    • Remove open-envoy-demo app and its files.

Written by Cursor Bugbot for commit 6032197. This will update automatically on new commits. Configure here.

@yoen-velt yoen-velt self-assigned this Dec 18, 2025
@vercel

vercel Bot commented Dec 18, 2025 •

Copy link
Copy Markdown


// [Velt] API key and auth token from environment variables
const NEXT_PUBLIC_VELT_API_KEY = "6xTcUFtlYAlCdh11zrKB";
const VELT_AUTH_TOKEN = "bd4d5226050470b6c658054fcdf1092a";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Hardcoded auth token exposes server credentials in source

The VELT_AUTH_TOKEN is a server-side secret that's hardcoded directly in the source code despite the comment stating these are "from environment variables." This auth token is used to authenticate API requests to Velt's servers and could allow unauthorized access if the repository is public or shared. The credentials are identical across both MongoDB and PostgreSQL demo files. Server-side secrets like auth tokens need to be read from environment variables at runtime, not committed to source control.

Additional Locations (1)

Fix in Cursor Fix in Web

} else {
// 3. Generate new document ID
docId = `doc-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
localStorage.setItem('velt-inline-comments-demo-doc-id', docId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Inconsistent localStorage keys break document persistence

Two different localStorage keys are used for document ID persistence, causing stored documents to be lost. When a URL contains a documentId parameter, the code stores to 'velt-demo-document-id' (line 48), but when checking for an existing document on subsequent visits, it reads from 'velt-inline-comments-demo-doc-id' (line 51). This mismatch means users who visit via a shared link will lose access to that document's comments on their next visit without the URL parameter, as a new document ID will be generated instead of retrieving the stored one.

Additional Locations (1)

Fix in Cursor Fix in Web

NEXT_PUBLIC_VELT_API_KEY=6xTcUFtlYAlCdh11zrKB
VELT_API_KEY=6xTcUFtlYAlCdh11zrKB
VELT_AUTH_TOKEN=bd4d5226050470b6c658054fcdf1092a
MONGODB_URI="mongodb+srv://yoen_db_user:eEtxXKvkpgFfYT4w@democluster.dhaarnp.mongodb.net/velt_comments?appName=DemoCluster"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Database credentials committed to version control

The .env.local files contain real credentials that are being committed to version control. The MongoDB file includes a connection string with plaintext username (yoen_db_user) and password (eEtxXKvkpgFfYT4w) for a MongoDB Atlas cluster, plus VELT_AUTH_TOKEN. The repository's .gitignore doesn't exclude .env.local files. These credentials should be removed from version control, rotated immediately, and a .env.example file with placeholder values used instead.

Additional Locations (1)

Fix in Cursor Fix in Web

// Extract documentId and organizationId from metadata
const documentId = metadata?.documentId;
const organizationId = metadata?.organizationId;
await saveComments(commentAnnotation, { documentId, organizationId });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Metadata extraction from request body will always be undefined

The save route handler extracts metadata from the top level of the request body, but according to the type definition in VeltCommentDataProvider.ts, the request structure only contains commentAnnotation at the top level—metadata is nested inside each individual annotation, not at the request root. This means metadata will always be undefined, causing documentId and organizationId to be undefined when passed to saveComments. The code relies on the fallback in store.ts (annotation.documentId), but if Velt doesn't populate these fields directly on annotations, comments won't be properly associated with their documents, breaking filtering and retrieval by documentIds.

Additional Locations (1)

Fix in Cursor Fix in Web

yoen-velt and others added 2 commits December 19, 2025 15:09
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

This branch had an error being deployed

1 failed (outdated) and 14 active deployments
Preview – sample-apps-ag-grid-single-tool — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – sample-apps-ag-grid-comment-aggregation — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – sample-apps-tiptap-comments-demo — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – sample-apps-tanstack-comment-aggregation — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – sample-apps-reactflow-demo — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – sample-apps-ag-grid-multiple-tools — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – sample-apps-tanstack-multiple-tools — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – sample-apps-tanstack-single-tool — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – sample-apps-codemirror-crdt-demo — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – sample-apps-tiptap-crdt-demo — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – sample-apps-lexical-comments-demo — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – sample-apps-dashboard-demo — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – sample-apps-slatejs-comments-demo — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – master-sample-app — 6032197b Deployed Dec 19, 2025 by vercel[bot]
Preview – dashboard-inline-comments-demo-1766173320708-ULNg — be3242ca Deployed Dec 19, 2025 by vercel[bot]
Preview – dashboard-inline-comments-demo — 29c16f88 Deployed Dec 19, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant