Problem: Word gloss selections need server-side storage for authenticated users, enabling cross-device sync and future export functionality. A RESTful API is needed for create, read, update, and delete operations.
Solution: A per-verse API endpoint that handles GET (load selections), POST (save/update a selection), and DELETE (remove a selection) for word gloss choices.
Not included: Batch operations across multiple verses, or a "get all selections for user" endpoint (needed for export — see Export Assembled Translation feature).
The API allows the interlinear popup to persist word gloss selections to the server for authenticated users.
Operations:
/api/word-selections/{bookId}/{chapter}/{verse} — returns all saved selections for that verse/api/word-selections/{bookId}/{chapter}/{verse} — saves or updates a selection (upsert by word position)/api/word-selections/{bookId}/{chapter}/{verse} — removes a selection for a specific word positionEdge cases:
No UI — this is a backend API consumed by the interlinear popup.
Endpoint: apps/web/src/routes/api/word-selections/[bookId]/[chapter]/[verse]/+server.ts
GET handler:
getWordSelections(userId, bookId, chapter, verse){wordPosition, selectedGloss}POST handler:
{wordPosition: number, selectedGloss: string}saveWordSelection() with upsert (onConflictDoUpdate on unique index)DELETE handler:
{wordPosition: number}word_selectionsDB table: word_selections — unique constraint on (userId, bookId, chapter, verse, wordPosition)
Query layer: apps/web/src/lib/server/queries/word-selections.ts
Files:
apps/web/src/routes/api/word-selections/[bookId]/[chapter]/[verse]/+server.tsapps/web/src/lib/server/queries/word-selections.tspackages/db/src/schema/bible.ts — wordSelections table definitionCurrent: IN_PROGRESS Milestone: v3 Priority: Medium — core API works, but missing bulk operations
What's done:
What remains:
Dependencies: