Overview
GitaChat’s bookmark feature allows users to save meaningful verses from the Bhagavad Gita for future reference. Bookmarks are stored in Supabase and tied to your user account, making them accessible across sessions.How Bookmarks Work
Save Verses
Save any verse along with its translation and commentary for later
View Collection
Access all your bookmarked verses in chronological order
Remove Bookmarks
Delete bookmarks you no longer need
Duplicate Prevention
System prevents duplicate bookmarks automatically
API Endpoint
The bookmarks API is available at/api/bookmarks and supports three HTTP methods:
Get All Bookmarks
Retrieve all bookmarks for the authenticated user. Endpoint:GET /api/bookmarks
Authentication: Required (Clerk)
Rate Limit: 30 requests per minute per client
Response:
Save a Bookmark
Add a new verse to your bookmarks collection. Endpoint:POST /api/bookmarks
Authentication: Required (Clerk)
Rate Limit: 30 requests per minute per client
Request Body:
chapter: Integer between 1-18verse: Integer, valid for the specified chaptertranslation: String, max 5000 characterssummarized_commentary: String, max 5000 characters
Delete a Bookmark
Remove a verse from your bookmarks. Endpoint:DELETE /api/bookmarks?chapter=2&verse=47
Authentication: Required (Clerk)
Rate Limit: 30 requests per minute per client
Query Parameters:
chapter: Chapter number (1-18)verse: Verse number (valid for chapter)
Data Storage
Bookmarks are stored in thebookmarks table in Supabase with the following schema:
| Column | Type | Description |
|---|---|---|
id | UUID | Primary key |
user_id | String | Clerk user identifier |
chapter | Integer | Chapter number (1-18) |
verse | Integer | Verse number |
translation | Text | English translation of the verse |
summarized_commentary | Text | AI-generated commentary |
created_at | Timestamp | When bookmark was created |
user_id, chapter, and verse is unique, preventing duplicate bookmarks.
Implementation Details
The bookmark system is implemented in/app/api/bookmarks/route.ts:
Rate Limiting
30 requests per minute per client using Redis-based rate limiting
Authentication
Clerk authentication ensures only logged-in users can access bookmarks
Validation
Strict validation of chapter/verse numbers and text length
Error Handling
Graceful error handling with appropriate HTTP status codes
User Interface
Users can bookmark verses through the GitaChat interface:- Add Bookmark: Click the bookmark icon next to any verse
- View Bookmarks: Navigate to the bookmarks section to see all saved verses
- Remove Bookmark: Click the remove icon to delete a bookmark
- Ordered Display: Bookmarks are displayed in reverse chronological order (newest first)
Best Practices
Usage Tips
- Save verses that resonate with you for quick reference
- Use bookmarks to build a personal collection of favorite teachings
- Review your bookmarks regularly for spiritual growth
- The system prevents duplicates, so you can bookmark freely
Error Handling
Common error scenarios:| Error | Status | Description |
|---|---|---|
| Unauthorized | 401 | User not logged in |
| Already bookmarked | 409 | Verse already in bookmarks |
| Invalid chapter/verse | 400 | Chapter or verse out of valid range |
| Text too long | 400 | Translation or commentary exceeds 5000 chars |
| Too many requests | 429 | Rate limit exceeded |
| Database not configured | 503 | Supabase connection unavailable |