Skip to content

Elastic + Vertex AI hybrid search and labeling agent that fuses BM25 + vector retrieval with Gemini reasoning for intelligent enterprise discovery.

License

Notifications You must be signed in to change notification settings

MrigankJaiswal-hub/SearchSphere-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

38 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” SearchSphere Agent

An AI-powered hybrid search and labeling assistant that fuses Elastic Cloud BM25 + kNN retrieval with Google Vertex AI Gemini 2.0 reasoning โ€” built to revolutionize enterprise knowledge search and evaluation.


๐Ÿ“˜ Table of Contents

  1. Overview
  2. Features
  3. Architecture
  4. Tech Stack
  5. Installation
  6. Environment Variables
  7. Running Locally
  8. Deployment
  9. Usage
  10. Project Structure
  11. Evaluation Metrics
  12. Future Upgrades
  13. Contributors
  14. License

๐Ÿงญ Overview

SearchSphere Agent is a full-stack AI search platform that integrates Elastic Cloud hybrid retrieval (BM25 + vector search) with Google Vertex AI Gemini 2.0 for contextual reasoning, evaluation, and dataset labeling.

It helps teams and enterprises find smarter, label faster, and evaluate efficiently โ€” a complete foundation for AI-powered RAG systems.


โš™๏ธ Features

  • ๐Ÿ” Hybrid Search โ€” Combines Elastic BM25 (lexical) + kNN (semantic) for deep understanding.
  • ๐Ÿค– Gemini Reasoning โ€” Uses Vertex AI Gemini-2.0-Flash for summaries and responses.
  • ๐Ÿงฉ Label Assist โ€” Create ground-truth JSONs interactively for model evaluation.
  • ๐Ÿ“Š Metrics Dashboard โ€” Live precision@K and latency stats (p50/p95).
  • ๐Ÿ’ฌ Conversational Refinement โ€” Natural chat-style interface for query reasoning.
  • ๐Ÿ” Cloud Ready โ€” Dockerized backend, deployed via Google Cloud Run + Netlify.

๐Ÿ—๏ธ Architecture


Frontend (Next.js 14, TypeScript, Tailwind)
โ”‚
โ–ผ
Next.js API routes (proxy)
โ”‚
โ–ผ
Backend (FastAPI)
โ”œโ”€โ”€ Elastic Cloud (BM25 + kNN)
โ”œโ”€โ”€ Vertex AI (Gemini + Embeddings)
โ”œโ”€โ”€ Evaluation Engine
โ””โ”€โ”€ Label Assist Service


๐Ÿงฐ Tech Stack

Layer Technology
Frontend Next.js 14, React 18, Tailwind CSS, Recharts
Backend FastAPI (Python 3.11), Elastic Cloud, Vertex AI
Deployment Google Cloud Run (backend), Netlify (frontend)
Database Elastic Cloud index (searchsphere_docs)
CI/CD GitHub Actions, Docker

๐Ÿ’ป Installation

1๏ธโƒฃ Clone the repository

git clone https://github.com/MrigankJaiswal-hub/SearchSphere-Agent.git
cd SearchSphere-Agent

2๏ธโƒฃ Backend setup

cd backend
python -m venv .venv
.venv\Scripts\activate   # (Windows)
pip install -r requirements.txt

3๏ธโƒฃ Frontend setup

cd ../web
npm install

๐Ÿ” Environment Variables

Backend .env

ELASTIC_CLOUD_ID=your_elastic_cloud_id
ELASTIC_API_KEY=your_elastic_api_key
ELASTIC_INDEX=searchsphere_docs
VERTEX_LOCATION=us-central1
GCP_PROJECT_ID=searchsphere-ai
VERTEX_EMBED_MODEL=text-embedding-005
VERTEX_CHAT_MODEL=gemini-2.0-flash-001
ES_KNN_NUM_CANDIDATES=120
CORS_ORIGIN=*

Frontend .env.local

NEXT_PUBLIC_API_BASE=http://127.0.0.1:8080

โ–ถ๏ธ Running Locally

Start backend

cd backend
uvicorn app:app --reload --port 8080

Start frontend

cd web
npm run dev

Visit ๐Ÿ‘‰ http://localhost:3000


โ˜๏ธ Deployment

Google Cloud Run (Backend)

gcloud run deploy searchsphere-backend \
  --source . \
  --region us-central1 \
  --set-env-vars "CORS_ORIGIN=https://your-frontend-url.netlify.app"

Netlify (Frontend)

  1. Import /web directory from GitHub.

  2. Add Environment Variable:

    NEXT_PUBLIC_API_BASE=https://<your-cloudrun-url>
    
  3. Deploy site.


Demo Workflow

  1. Visit your deployed frontend.

  2. Enter a natural language query (e.g., โ€œWhat is hybrid search?โ€).

  3. Observe semantic + lexical search fusion results.

  4. View real-time precision and latency metrics.

  5. Go to Label Assist, input a query, and export groundtruth.json.

  6. Upload groundtruth.json in Run Evaluation to compute P@K.


โœ… Files checklist

Folder/File Purpose Status
/backend FastAPI backend โœ…
/web Next.js frontend โœ…
/docs Documentation (README, credits, architecture, eval_matrix.xlsx) โœ…
/docs/credits.txt Acknowledgments โœ…
/docs/evaluation_matrix.xlsx Metrics template โœ…
/docs/diagram.png Architecture diagram (export from draw.io / Lucidchart) โœ…
.github/workflows/ Optional CI/CD Optional โœ…
.env.example Example env vars โœ…
LICENSE MIT License โœ…
README.md Overview โœ…

๐Ÿง  Usage

  • / โ†’ Main chat & hybrid search page
  • /metrics โ†’ Live latency & precision dashboard
  • /label โ†’ Label Assist tool for dataset generation

To test evaluation manually:

curl -X POST "$URL/api/eval/precision" \
-H "Content-Type: application/json" \
-d '{"query":"hybrid search","k":10}'

๐Ÿ“‚ Project Structure

SearchSphere-Agent/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ app.py
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ requirements.txt
โ”‚
โ”œโ”€โ”€ web/
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ tailwind.config.ts
โ”‚
โ”œโ”€โ”€ scripts/
โ”œโ”€โ”€ assets/
โ””โ”€โ”€ README.md

๐Ÿ“Š Evaluation Metrics

  • Precision@K: Evaluates top-K relevance.
  • Latency Tracking: p50/p95 in milliseconds.
  • Label Assist: Exports groundtruth.json for retraining.

Example output:

p50: 730 ms | p95: 1100 ms | Precision@10: 0.86

๐Ÿ”ฎ Future Upgrades

  • Multi-modal retrieval (text, images, audio, video).
  • Auth & multi-tenant support (Firebase/Cognito).
  • Feedback-driven fine-tuning of hybrid fusion weights.
  • Enhanced real-time dashboards and analytics.

๐Ÿ‘จโ€๐Ÿ’ป Contributors

Mrigank Jaiswal B.Tech

๐Ÿ–ฅ๏ธ Built full-stack architecture, Elastic-Vertex integration, frontend UI, and deployment automation.


๐Ÿชช License

This project is licensed under the MIT License. ยฉ 2025 Mrigank Jaiswal