Skip to main content
The Electron main process owns the Moss client and the index; the renderer calls it over IPC to run queries. The index is queried in-process, so search is a local function call rather than a network request and works offline. The index persists to the user data directory and syncs in the background when a connection is available.

Architecture

  • Main process owns a Moss client
  • Renderer calls main via IPC for index/query
  • Index persisted to the user data directory

Example (main process)

// main.ts
import { app, ipcMain } from 'electron'
import { MossClient } from '@moss-dev/moss'

let client: MossClient
const INDEX = 'electron-docs'

app.whenReady().then(async () => {
  client = new MossClient(process.env.MOSS_PROJECT_ID!, process.env.MOSS_PROJECT_KEY!)
  await client.createIndex(INDEX, initialDocs, { modelId: 'moss-minilm' })
})

ipcMain.handle('search', async (_e, q: string) => {
  await client.loadIndex(INDEX)
  return client.query(INDEX, q, { topK: 5 })
})

Offline-first search

The retrieval pipeline in depth.

Local embeddings

Embed on-device for privacy.