Skip to content

feat(artist): search service for artists#53

Merged
alikia2x merged 8 commits intodevelopfrom
feat/artists-search
Apr 26, 2026
Merged

feat(artist): search service for artists#53
alikia2x merged 8 commits intodevelopfrom
feat/artists-search

Conversation

@alikia2x
Copy link
Copy Markdown
Contributor

@alikia2x alikia2x commented Apr 26, 2026

Artist Search Service Implementation

  • Added new artistSearchHandler endpoint (GET /artists) with query parameter validation and full-text search capabilities
  • Created ArtistSearchService with sync and search methods for indexing and querying artist data across multiple languages
  • Integrated artist search with embedding-based hybrid search using Meilisearch
  • Extended search index configuration to include artist-specific searchable fields and embedder settings

Outbox-Based Event Processing Architecture

  • Introduced comprehensive outbox infrastructure for asynchronous event handling:
    • New Outbox Prisma model with status tracking (PENDING, PROCESSING, PROCESSED, FAILED) and retry management
    • OutboxRepository and OutboxService for creating, querying, and managing outbox entries
    • BullMQ-based queue with Redis backing for job scheduling and worker processing
    • OutboxProcessor that dispatches events to appropriate search services (song and artist) for index synchronization
  • Refactored ArtistService and SongService to use outbox events instead of direct search index updates
  • Added graceful shutdown handlers for outbox infrastructure in backend entrypoint

Test Infrastructure Refactoring

  • Removed Prisma lifecycle management (beforeAll/afterAll hooks) from integration test files
  • Simplified test setup by eliminating explicit database connection/disconnection and state cleanup
  • Introduced test:reset scripts for database state reset prior to test execution
  • Added comprehensive test coverage for new outbox functionality and artist search features

Configuration and Dependencies

  • Added redis service to Docker Compose setup with persistent volume
  • Extended environment configuration to support REDIS_URL with default local Redis connection
  • Added bullmq and ioredis runtime dependencies to core package
  • Updated Turbo configuration with new test:reset tasks for database and core packages

Search Index Enhancements

  • Created cleanUpSearchIndex.ts script for search index rebuild across multiple languages
  • Enhanced SearchManager with clearAllIndex and createIndex methods for index administration
  • Updated SongSearchIndex to support nullable embedding vectors for resilience to embedding failures

Replace fire-and-forget search index synchronization with a transactional
outbox pattern to guarantee eventual consistency between the database and
search index.

Previously, ArtistService and SongService called search.sync() directly
after write operations. If the search service was unavailable, the sync
would fail silently and the index would become stale.

With this change:
- Write operations now create outbox entries inside Prisma transactions
- A BullMQ worker processes outbox jobs asynchronously to sync the index
- Redis is added as the BullMQ backing store
- Graceful shutdown handlers ensure in-flight jobs complete on exit

New modules:
- packages/core/src/modules/outbox/ (repository, service, DTOs)
- packages/core/src/outbox/ (BullMQ queue and processor)
- packages/db/prisma/models/meta/outbox.prisma (schema)
- Add BaseRepository with `query()` helper that wraps traceTask +
  transformPrismaResult, removing callback nesting from all repository
  methods
- Migrate ArtistRepository, SongRepository, and EngineRepository to
  extend BaseRepository; method bodies are now fully flat
- Remove traceTask from ArtistService and SongService, leaving only
  `$transaction` as the single nesting layer
- Split OutboxService.createEntry into write-only (tx-bound) and
  enqueue (post-tx queue dispatch) to guarantee data consistency
- Fix SongService unit test mock to include the new enqueue method
Add unit and integration tests for artist and engine modules.
Add search index cleanup script for test isolation.
Refactor catalog module imports to avoid barrel dependency issues.
Refactor outbox processor into a DI-based factory and inject queue into
OutboxService to enable unit testing.
Cover outbox service, processor, repository, artist search, and search
manager with unit/integration tests.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 26, 2026

Warning

Rate limit exceeded

@alikia2x has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 59 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 54 minutes and 59 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 829e1f90-ea6b-47ed-9b26-82e385a98e93

📥 Commits

Reviewing files that changed from the base of the PR and between 754117c and e7f0b58.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (60)
  • apps/backend/src/handlers/catalog/artist/index.ts
  • apps/backend/src/handlers/catalog/artist/search.ts
  • apps/backend/src/index.ts
  • apps/backend/tests/artist.test.ts
  • apps/backend/tests/auth.test.ts
  • apps/backend/tests/engine.test.ts
  • apps/backend/tests/song.test.ts
  • apps/backend/tests/songLyrics.test.ts
  • docker-compose.yml
  • locale/modules/backend/messages/en.json
  • locale/modules/backend/messages/zh.json
  • package.json
  • packages/core/bunfig.toml
  • packages/core/package.json
  • packages/core/scripts/cleanUpSearchIndex.ts
  • packages/core/src/index.ts
  • packages/core/src/modules/catalog/artist/container.ts
  • packages/core/src/modules/catalog/artist/repository.ts
  • packages/core/src/modules/catalog/artist/service.ts
  • packages/core/src/modules/catalog/engine/repository.ts
  • packages/core/src/modules/catalog/engine/service.ts
  • packages/core/src/modules/catalog/song/container.ts
  • packages/core/src/modules/catalog/song/repository.ts
  • packages/core/src/modules/catalog/song/service.ts
  • packages/core/src/modules/index.ts
  • packages/core/src/modules/outbox/container.ts
  • packages/core/src/modules/outbox/dto.ts
  • packages/core/src/modules/outbox/index.ts
  • packages/core/src/modules/outbox/repository.interface.ts
  • packages/core/src/modules/outbox/repository.ts
  • packages/core/src/modules/outbox/service.ts
  • packages/core/src/outbox/index.ts
  • packages/core/src/outbox/processor.ts
  • packages/core/src/outbox/queue.ts
  • packages/core/src/search/catalog/artist.ts
  • packages/core/src/search/catalog/index.ts
  • packages/core/src/search/catalog/song.ts
  • packages/core/src/search/config.ts
  • packages/core/src/search/manager.ts
  • packages/core/src/utils/BaseRepository.ts
  • packages/core/src/utils/index.ts
  • packages/core/tests/integration/ArtistRepository.test.ts
  • packages/core/tests/integration/EngineRepository.test.ts
  • packages/core/tests/integration/OutboxRepository.test.ts
  • packages/core/tests/integration/SongRepository.test.ts
  • packages/core/tests/integration/SongSearchService.test.ts
  • packages/core/tests/unit/ArtistSearchService.test.ts
  • packages/core/tests/unit/ArtistService.test.ts
  • packages/core/tests/unit/EngineService.test.ts
  • packages/core/tests/unit/OutboxProcessor.test.ts
  • packages/core/tests/unit/OutboxService.test.ts
  • packages/core/tests/unit/SearchManager.test.ts
  • packages/core/tests/unit/SongSearchService.test.ts
  • packages/core/tests/unit/SongService.test.ts
  • packages/db/package.json
  • packages/db/prisma/models/meta/outbox.prisma
  • packages/db/src/index.ts
  • packages/embedding/src/embedding.ts
  • packages/env/src/index.ts
  • turbo.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/artists-search

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@alikia2x alikia2x merged commit fff3b11 into develop Apr 26, 2026
2 checks passed
@alikia2x alikia2x deleted the feat/artists-search branch April 26, 2026 09:21
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