import { Module } from '@nestjs/common'; import { ProductsModule } from '@/modules/products/products.module'; import { PostgresSearchProvider } from './postgres-search.provider'; import { SearchIndexSubscriber } from './search-index.subscriber'; import { SearchIndexerService } from './search-indexer.service'; import { SearchController } from './search.controller'; import { SEARCH_PROVIDER } from './search.provider'; import { SearchService } from './search.service'; /** * SearchModule — owns `search_documents`, a pure projection of the catalog. * * The projection can be rebuilt from scratch at any moment, which is what makes * losing it survivable and makes this module a genuine EXTRACTION CANDIDATE: * nothing else reads its table, and it returns ids rather than product payloads * so it never learns what a product looks like. * * `SEARCH_PROVIDER` is the seam from ADR-0012 — swapping PostgreSQL for * OpenSearch replaces one binding here. */ @Module({ imports: [ProductsModule], controllers: [SearchController], providers: [ SearchService, SearchIndexerService, SearchIndexSubscriber, PostgresSearchProvider, { provide: SEARCH_PROVIDER, useExisting: PostgresSearchProvider }, ], exports: [SearchService, SearchIndexerService], }) export class SearchModule {}