Skip to content

Add batch scan processing endpoints#215

Draft
jakebromberg wants to merge 6 commits intofeature/scanner-gemini-integrationfrom
feature/scanner-batch-processing
Draft

Add batch scan processing endpoints#215
jakebromberg wants to merge 6 commits intofeature/scanner-gemini-integrationfrom
feature/scanner-batch-processing

Conversation

@jakebromberg
Copy link
Member

@jakebromberg jakebromberg commented Feb 28, 2026

Summary

  • Add POST /library/scan/batch endpoint for uploading multiple vinyl record images with a JSON manifest, returning 202 with a job ID for polling
  • Add GET /library/scan/batch/:jobId endpoint for checking job status with ownership-enforced access
  • Add scan_jobs and scan_results database tables with status enums, cascading deletes, and JSONB columns
  • Implement sequential background processing with partial failure handling (job completes if any item succeeds)
  • Validate batch limits: max 10 items, 5 images/item, 50 total images

Closes #214

Test plan

  • Unit tests for batch service (createBatchJob, getJobStatus, processJobItems) — 10 tests
  • Unit tests for controller handlers (validation, 202/400/404 responses) — 9 tests
  • Full test suite passes (204/204 tests)
  • Prettier formatting verified
  • ESLint clean (no new errors)
  • Migration SQL reviewed for correctness

Note: Depends on #213 (Gemini scanner integration). PR #217 depends on this PR.

Introduces POST /library/scan/batch and GET /library/scan/batch/:jobId
endpoints that let DJs upload multiple vinyl record images in one request,
get a job ID back immediately (202 Accepted), and poll for results as
each item processes asynchronously through Gemini.

Schema: scan_jobs and scan_results tables with status enums, cascading
deletes, and JSONB columns for context/extraction data.

Batch service: createBatchJob (insert + fire-and-forget background
processing), getJobStatus (ownership-checked polling), processJobItems
(sequential per-item processing with partial failure handling).

Validation: max 10 items, max 5 images per item, max 50 total images,
manifest image count must match uploaded files.
Jake Bromberg added 4 commits March 3, 2026 17:02
The 2.0-flash free tier quota is exhausted and the model is outdated. Gemini 3.1 Pro has better handwriting recognition, which is needed for reading handwritten album reviews and catalog stickers on vinyl records.
The gemini-3.1-pro-preview free tier quota is exhausted (limit: 0). Switch to gemini-3-flash-preview which has available free tier capacity.
Gemini now extracts artist_name and album_title alongside label, catalog number, review text, and UPC. Updated the system prompt, response parsing, and TypeScript types.
…ng fallbacks

Batch status responses now include full album details (artist, title, library code, genre, format, label) for matched items by joining library_artist_view, instead of only returning the album ID. Also fix catalog matching to use extracted artist name and album title as fallbacks instead of label name.
Mount the better-auth handler directly in the backend Express app so the iOS library-scanner only needs a single base URL for both auth and API calls. This simplifies the dev environment by eliminating the need for a separate auth service on Railway.

Changes:
- Import auth from @wxyc/authentication and toNodeHandler from better-auth/node
- Mount auth handler at /auth/{*path} (Express 5 path-to-regexp syntax)
- Add test helper endpoints (/auth/test/verification-token, /auth/test/expire-session)
- Add createDefaultUser() and syncAdminRoles() async startup functions
- Wrap server startup in async IIFE to run startup functions before listening
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