How manish-9245/scalable-llm-search works
Purpose and Entry Points
Indriya AI is a local-first luxury-jewellery search, voice, and concierge backend with an administrative AI ingestion pipeline. The Fastify application starts in server.js, serves the browser UI from public/index.html and public/app.js, and exposes search, chat, transcription, ingestion, queue-admin, and health routes.
HTTP Coordination and Runtime Boundaries
server.js is the request coordinator: it accepts text/voice interactions, invokes local search and localization paths, and dispatches privileged ingestion work. It runs in Node.js/Fastify; static UI and local ONNX/WASM inference execute alongside the service. Deployment packaging is defined by Dockerfile and Railway settings in railway.json.
Query Understanding and Local Concierge
The local parsing layer converts raw customer wording into structured filters, including typo correction, jewellery terminology, vernacular mappings, price ranges, purity/color normalization, and exclusions. Core vocabulary and parsing logic are in src/utils/terminology.js, src/utils/slang.js, and src/utils/QueryBuilder.js. Multilingual template-based conversational output is configured in src/config/translations.js; this customer-facing path is intentionally independent of cloud LLM calls.
Adaptive Hybrid Search
src/services/searchService.js executes the primary retrieval flow: parsed filters become relational, GIN-array exclusion/tag, and pgvector semantic retrieval streams, then are merged through reciprocal-rank fusion. src/services/discoveryService.js supports discovery-oriented catalog access. Embeddings use local MiniLM/ONNX inference configured through src/config/llm.js, while database access is centralized in src/config/db.js. PostgreSQL/pgvector is the durable search boundary, with schema and indexes represented by schema.sql.
Caching, Sessions, and Live Pricing
Redis provides low-latency search/product caching and BullMQ backing, configured in src/config/redis.js and src/config/queue.js. Session continuity is handled by src/utils/sessionMerge.js. src/services/rateFetcherService.js periodically fetches Indriya’s public rate fragment, derives related metal rates, persists daily values, and invalidates affected Redis keys; it is the only material product-price external data dependency.
Administrative Ingestion Pipeline
Ingestion is separated from customer runtime. src/services/ingestionService.js submits or processes background catalog enrichment; src/mastra/agent.js and src/mastra/tools.js define the Mastra/Gemini-backed multimodal analysis boundary. Gemini is used only to create structured product dossiers, which are normalized and stored in PostgreSQL. Redis/BullMQ decouples upload/request handling from this potentially slow, retryable work.
Voice, Initialization, and Operations
The transcription route uses local Whisper ONNX/WASM with language routing; model assets are prepared during build/startup through src/config/pre_cache.js. Database initialization and ontology seeding begin at db_init.mjs, with base schema in schema.sql. Structured logging is provided by src/utils/logger.js; queue visibility is mounted by the server. Required infrastructure is PostgreSQL 16+ with pgvector, Redis 7+, and a Gemini API key solely for ingestion.
Main entry points: server.js Fastify server · searchService.js Hybrid search · db.js PostgreSQL + pgvector · ingestionService.js Ingestion service
Components 20
Customer Runtime
Local-first Fastify search and concierge path.
- Browser UI
public/index.html - Fastify server · Serves UI and coordinates HTTP routes.
server.js - Query parser · Builds normalized filters without cloud LLM calls.
src/utils/QueryBuilder.js - Jewellery vocabulary
src/utils/terminology.js - Conversation templates
src/config/translations.js - Local transcription · Language-routed voice transcription.
src/config/pre_cache.js - Session merge
src/utils/sessionMerge.js
Data & Retrieval
Catalog persistence, hybrid retrieval, and cache boundary.
- Hybrid search · Combines relational, exclusion/tag, and semantic results with reciprocal-rank fusion.
src/services/searchService.js - Catalog discovery
src/services/discoveryService.js - Local MiniLM embeddings
src/config/llm.js - PostgreSQL + pgvector · Durable catalog, vectors, and daily metal rates.
src/config/db.js - Schema and indexes
schema.sql - Redis · Search/product cache and BullMQ storage.
src/config/redis.js - Live rate fetcher · Fetches public rates, persists derived values, and invalidates cache.
src/services/rateFetcherService.js - Database initialization · Initializes database and seeds ontology.
db_init.mjs
Admin Ingestion
Asynchronous AI catalog enrichment pipeline.
- BullMQ queue · Decouples retryable ingestion from HTTP handling.
src/config/queue.js - Ingestion service
src/services/ingestionService.js - Mastra analysis agent · Creates structured product dossiers through Gemini.
src/mastra/agent.js - Gemini · Used only for administrative ingestion.
Other components
- Container deployment
Dockerfile
Connections 24
- Browser UI → Fastify server: HTTP and static UI
- Fastify server → Query parser: text query
- Query parser → Jewellery vocabulary: normalizes terms
- Fastify server → Conversation templates: localized replies
- Fastify server → Local transcription: voice transcription
- Fastify server → Session merge: conversation continuity
- Fastify server → Hybrid search: search request
- Query parser → Hybrid search: structured filters
- Hybrid search → Local MiniLM embeddings: semantic query vector
- Hybrid search → PostgreSQL + pgvector: hybrid retrieval
- Hybrid search → Redis: read/write cache
- Fastify server → Catalog discovery: discovery routes
- Catalog discovery → PostgreSQL + pgvector: catalog access
- Live rate fetcher → PostgreSQL + pgvector: persist daily rates
- Live rate fetcher → Redis: invalidate price keys
- Fastify server → Ingestion service: privileged ingestion
- Ingestion service → BullMQ queue: enqueue/process jobs
- BullMQ queue → Redis: job backing
- Ingestion service → Mastra analysis agent: product enrichment
- Mastra analysis agent → Gemini: multimodal dossier generation
- Ingestion service → PostgreSQL + pgvector: store normalized dossier
- Schema and indexes → PostgreSQL + pgvector: defines tables and indexes
- Database initialization → Schema and indexes: applies schema
- Container deployment → Fastify server: packages runtime