Overview
The notes feature allows you to add personal annotations, reflections, and insights to any verse in the Bhagavad Gita. Notes help you remember your thoughts and deepen your understanding of the teachings.How Notes Work
Personal Annotations
Add your own thoughts and reflections to any verse
Easy Editing
Update your notes anytime as your understanding grows
One Note Per Verse
Each verse can have one note that you can edit or replace
Retrieve Anytime
Fetch specific notes or browse all your notes at once
API Endpoint
The notes API is available at/api/notes and supports three HTTP methods:
Get Notes
Retrieve a specific note or all notes for the authenticated user. Endpoint:GET /api/notes
Authentication: Required (Clerk)
Query Parameters (Optional):
chapter: Chapter number to get a specific noteverse: Verse number to get a specific note
null if no note exists for that verse.
Example 2: Get All Notes
Create or Update Note
Add a new note or update an existing one for a verse. Endpoint:POST /api/notes
Authentication: Required (Clerk)
Request Body:
chapter: Integer between 1-18 (required)verse: Integer, valid for the specified chapter (required)note_text: String, max 10,000 characters (required)- Whitespace is trimmed automatically
- If no note exists for this verse, a new one is created
- If a note already exists, it’s updated with the new text
- The
updated_attimestamp is automatically refreshed
Delete Note
Remove a note from a specific verse. Endpoint:DELETE /api/notes?chapter=2&verse=47
Authentication: Required (Clerk)
Query Parameters:
chapter: Chapter number (required)verse: Verse number (required)
Data Storage
Notes are stored in theverse_notes table in Supabase:
| Column | Type | Description |
|---|---|---|
id | UUID | Primary key |
user_id | String | Clerk user identifier |
chapter | Integer | Chapter number (1-18) |
verse | Integer | Verse number |
note_text | Text | User’s note content (max 10,000 chars) |
created_at | Timestamp | When note was first created |
updated_at | Timestamp | When note was last modified |
user_id, chapter, and verse is unique, ensuring one note per verse per user.
Implementation Details
The notes system is implemented in/app/api/notes/route.ts:
Upsert Logic
POST endpoint uses upsert to create or update seamlessly
Flexible Retrieval
GET endpoint works for both single notes and all notes
Timestamp Tracking
Separate created_at and updated_at for version history
Text Length
Generous 10,000 character limit for detailed reflections
User Interface
The notes feature integrates throughout the GitaChat interface:- Add Note: Click the notes icon next to any verse
- Edit Note: Existing notes can be modified anytime
- View All Notes: Browse all your notes in one place
- Delete Note: Remove notes you no longer need
- Rich Text: Notes display with proper formatting
Use Cases
Personal Reflections
Record how a verse applies to your life
Study Journal
Document insights from your study sessions
Action Items
Note specific practices to implement
Questions
Write down questions for further exploration
Cross-References
Link verses to related teachings or scriptures
Progress Tracking
Document your spiritual growth over time
Best Practices
Note-Taking Tips
- Be Specific: Reference specific life situations
- Update Regularly: Revise notes as understanding deepens
- Keep It Personal: Focus on what resonates with you
- Use Clear Language: Write for your future self
- Combine with Bookmarks: Bookmark verses with important notes
Character Limits
| Field | Maximum Length | Purpose |
|---|---|---|
note_text | 10,000 characters | Allow detailed reflections |
| Other text fields | 5,000 characters | Bookmarks and commentary |
Error Handling
Common error scenarios:| Error | Status | Description |
|---|---|---|
| Unauthorized | 401 | User not logged in |
| Missing required fields | 400 | chapter, verse, or note_text missing |
| Invalid chapter/verse | 400 | Chapter or verse out of valid range |
| Note text too long | 400 | Exceeds 10,000 character limit |
| Database not configured | 503 | Supabase connection unavailable |
| Failed to save/delete | 500 | Server error occurred |
Validation Rules
The API validates all input before processing:- Authentication: User must be logged in via Clerk
- Required Fields: chapter, verse, and note_text are mandatory for POST
- Chapter Range: Must be between 1 and 18
- Verse Range: Must be valid for the specified chapter (varies by chapter)
- Text Length: note_text trimmed and must not exceed 10,000 characters
- Data Types: chapter and verse must be integers
Privacy
Your Notes are Private
- Only you can see your notes
- Notes are tied to your Clerk user ID
- No other users can access your personal reflections
- Data is stored securely in Supabase with proper authentication
Integration with Other Features
Notes work seamlessly with other GitaChat features:- Bookmarks: Add notes to bookmarked verses for enhanced reference
- History: Review notes on verses you’ve searched before
- Daily Verse: Add notes to your daily verse for ongoing reflection
- Search: Find verses, then add notes with your insights