Summary
Enable semantic search and grounded Q&A across all documents in a user’s library (web, mobile, and VS Code extension). The feature indexes uploaded content into a vector store, supports filters (type, tags, date), and powers an “Ask Your Workspace” chat that returns cited answers with source snippets.
Motivation
- Users upload many files; today they must open each to find answers.
- RAG across the user’s corpus unlocks instant insights, better chat grounding, and stronger reuse of prior uploads.
- Pairs well with existing Redis/RabbitMQ infra for indexing and caching; exposes clean GraphQL/REST for all clients (web, mobile, extension).
Goals
- Semantic Search across a user’s entire library with filters (file type, tags, date range).
- Workspace Q&A: natural-language questions with answers grounded in top-k passages + inline citations.
- Citations UI: expandable snippets showing exact source, page/section, and quick-open.
- Indexing Pipeline: chunking, dedup (content hash), incremental updates on new/edited docs.
- Privacy & Isolation: strict per-user namespaces; no cross-tenant leakage.
- VS Code Extension integration: global search & “Ask Workspace” panel.
- Admin/Debug endpoints: reindex status, queue depth, last error.
Non-Goals (this issue): org-wide sharing, external drives sync, full OCR/table extraction (can be follow-ups).
Acceptance Criteria
- A global search bar (web) returns relevant results in <1.5s p95 for top-k=10 on a typical user library (≤ 500 docs).
- Clicking a result opens the doc page scrolled to the cited passage (or shows an inline snippet).
- “Ask Your Workspace” answers stream tokens and include at least 3 citations when available; if no sources found, return a clear “no sources” state (no hallucinated content).
- Filters: MIME (pdf/docx/txt), tags, created/updated date range.
- Works in dark/light modes; fully keyboard accessible (enter to search, arrows to navigate results).
- Extension exposes the same search & Q&A (no extra login beyond current app auth).
- Telemetry events emitted (see Analytics).
UX Notes
- Global Search in header; results list with snippet, confidence, tags, and file icon.
- Q&A Panel (ChatModal): a toggle “Search scope: current doc | all docs”. Answers include numbered citations [¹][²][³]; clicking jumps to snippet.
- Empty State: suggests uploading docs or widening filters.
API & GraphQL (proposed)
REST (Express):
POST /v1/search/semantic
body: { query: string, topK?: number, filters?: { mimeTypes?: string[], tags?: string[], dateFrom?: string, dateTo?: string } }
POST /v1/qa/workspace
body: { question: string, topK?: number, filters?: {...}, stream?: boolean }
GET /v1/index/status
POST /v1/index/reindex # optional: specific docIds or full user reindex
GraphQL:
type SearchHit {
docId: ID!
title: String!
snippet: String!
score: Float!
location: String # page/section/offset
mimeType: String
tags: [String!]
updatedAt: String
}
type QAChunk {
text: String!
citations: [SearchHit!]!
}
type Query {
workspaceSearch(query: String!, topK: Int, filters: FiltersInput): [SearchHit!]!
workspaceQA(question: String!, topK: Int, filters: FiltersInput): [QAChunk!]!
}
input FiltersInput {
mimeTypes: [String!]
tags: [String!]
dateFrom: String
dateTo: String
}
Response example:
{
"answer": "Project X uses a zero-downtime rollout via NGINX and Kubernetes.",
"citations": [
{ "docId": "abc123", "title": "kubernetes/README.md", "snippet": "NGINX as reverse proxy...", "location": "L45-L67" }
]
}
Indexing Pipeline
- Chunking: 800–1200 tokens, 150–200 overlap; include docId, page/section, content hash.
- Embeddings: pluggable provider; store dim in config (e.g., 1536).
- Vector Store: start with FAISS/pgvector (self-host) and adapter pattern for Pinecone/Weaviate later.
- Ingestion: PDFs/Docx → text; reuse existing upload flow; enqueue
index_document via RabbitMQ.
- Dedup: skip chunks with unchanged hash.
- Metadata: MongoDB holds doc + chunk metadata; Redis caches top-k for frequent queries.
Security & Privacy
- Verify Firebase/JWT at gateway; namespace vectors by
userId.
- Encrypt at rest when supported; redact secrets/PII heuristically (optional flag).
- Rate-limit search/QA to prevent abuse.
Performance
- Async indexing; UI shows per-doc index status.
- Redis cache for popular queries (TTL 15–60m).
- Stream answers over SSE/WebSocket.
- Observability: log recall@k on sampled queries to track quality.
Analytics / Events
workspace_search {queryLen, topK, filters, hits}
workspace_qa {questionLen, citedCount, latencyMs}
citation_click {docId, location}
- KPIs: time-to-first-answer, retention uplift for users who use search/QA, zero-result rate.
Rollout Plan
- Phase 1: Indexing + semantic search (web) with filters and citations.
- Phase 2: Workspace Q&A + streaming + VS Code extension integration.
- Phase 3: Mobile support + admin tools (reindex UI, queue health).
Tasks
Backend (Express)
GraphQL
Frontend (React)
VS Code Extension
Mobile (Expo)
Infra/CI
Docs
Open Questions
- Preferred default vector backend? (pgvector vs FAISS vs managed)
- Maximum library size before tiered indexing needed?
- OCR/table extraction scope now vs. follow-up issue?
- How should tags be managed (freeform vs predefined) for better filters?
Summary
Enable semantic search and grounded Q&A across all documents in a user’s library (web, mobile, and VS Code extension). The feature indexes uploaded content into a vector store, supports filters (type, tags, date), and powers an “Ask Your Workspace” chat that returns cited answers with source snippets.
Motivation
Goals
Non-Goals (this issue): org-wide sharing, external drives sync, full OCR/table extraction (can be follow-ups).
Acceptance Criteria
UX Notes
API & GraphQL (proposed)
REST (Express):
GraphQL:
Response example:
{ "answer": "Project X uses a zero-downtime rollout via NGINX and Kubernetes.", "citations": [ { "docId": "abc123", "title": "kubernetes/README.md", "snippet": "NGINX as reverse proxy...", "location": "L45-L67" } ] }Indexing Pipeline
index_documentvia RabbitMQ.Security & Privacy
userId.Performance
Analytics / Events
workspace_search{queryLen, topK, filters, hits}workspace_qa{questionLen, citedCount, latencyMs}citation_click{docId, location}Rollout Plan
Tasks
Backend (Express)
/v1/search/semantic,/v1/qa/workspace,/v1/index/*routes + validators.GraphQL
workspaceSearchandworkspaceQA.Frontend (React)
VS Code Extension
Mobile (Expo)
Infra/CI
workspace_search_enabled.Docs
README.md+openapi.yaml+ extension docs.Open Questions