MemExLens is an intelligent browser history search and Q&A system powered by Gemini (Google Generative AI) and Pinecone vector database. It enables you to store, search, and ask questions about your browsing history using advanced embeddings and retrieval-augmented generation.
Click here to navigate to UI repository
- Store Browsing History: Ingest and embed scraped webpage text, storing it as semantic vectors in Pinecone.
- Semantic Search & Q&A: Ask natural language questions about your browsing history and get answers grounded in your actual visited content.
- User Isolation: All data and queries are isolated per user.
- FastAPI & Flask APIs: REST endpoints for ingestion and Q&A.
- Streamlit UI: Interactive web app for testing, uploading, and querying.
- Robust Environment Management: All credentials and configs via
.env. - Cloud Ready: Dockerized and deployable to Google Cloud Run.
- Chunk-based Processing: Large documents are split into manageable chunks with overlap for better context.
- Temporal Context: Results include timestamps showing when pages were visited.
- Efficient Storage: Uses vector embeddings for fast similarity search.
MemExLens_Server/
β
βββ VectorAgent/
β βββ vector.py # FastAPI server (Gemini + Pinecone)
β βββ embedding_service.py # Embedding & storage logic (Flask API)
β βββ qa_service.py # Q&A logic (Flask API)
β βββ test_gemini.py # Gemini API debug script
β βββ test_pinecone.py # Pinecone v7 test script
β βββ test_geminy_pineconeQA.py # Streamlit Q&A prototype
β βββ test_geminy_pineconeQA2.py # Streamlit JSON payload demo
β βββ delete_pinecone.py # Utility to clear Pinecone index
β
βββ app.py # Flask API server (production)
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker build file
βββ .env.example # Example environment config
βββ test_api.py # API test script
βββ .gitignore, .dockerignore # Ignore rules
βββ README.md # This file
Description:
- Text Extraction: Scraped text from visited web pages.
- Chunking: Splits large text into overlapping chunks for better context.
- Gemini Embedding API: Converts text chunks into semantic vectors (768-dim).
- Pinecone Vector DB: Stores vectors with metadata (user, URL, timestamp).
- Semantic Search & Retrieval: Finds relevant chunks for user queries.
- Q&A Generation: Gemini model generates answers grounded in retrieved content.
git clone https://github.com/yourusername/MemExLens_Server.git
cd MemExLens_ServerCopy the example and fill in your API keys:
cp .env.example .envEdit .env and set:
GEMINI_API_KEY(from Google MakerSuite)PINECONE_API_KEY(from Pinecone Console)PINECONE_ENVIRONMENT(e.g.,gcp-starterorus-central1)- (Optional) Adjust chunking and logging configs
It's recommended to use a virtual environment:
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install -r requirements.txtpython VectorAgent/test_gemini.py
python VectorAgent/test_pinecone.pypython app.py- Runs on
http://localhost:8080by default.
python VectorAgent/vector.py- Runs on
http://localhost:8000 - Interactive docs at
/docs
streamlit run VectorAgent/test_geminy_pineconeQA.pyor
streamlit run VectorAgent/test_geminy_pineconeQA2.pyStore a new browsing history entry.
Payload:
{
"timestamp": "2024-06-01T12:00:00Z",
"data": {
"userId": "user123",
"scrapedTextData": "Full text of the webpage...",
"url": "https://example.com/page"
}
}Ask a question about a user's browsing history.
Payload:
{
"userId": "user123",
"prompt": "What did I read about Python?"
}Health check endpoint.
Same as /api/data above.
Same as /api/data/user above.
Get stats for a user.
Service health and config info.
All sensitive info is loaded from .env. Example:
GEMINI_API_KEY=your-gemini-api-key
PINECONE_API_KEY=your-pinecone-api-key
PINECONE_ENVIRONMENT=gcp-starter
PINECONE_INDEX_NAME=browser-history-gemini
CHUNK_SIZE=1000
CHUNK_OVERLAP=200
EMBEDDING_BATCH_SIZE=100
LOG_LEVEL=INFOfrom VectorAgent.embedding_service import embed_and_store_in_pinecone
data = {
"userId": "user123",
"url": "https://example.com/article",
"scrapedTextData": "Full text content of the web page..."
}
embed_and_store_in_pinecone(data, "2024-01-15T10:30:00Z")from VectorAgent.qa_service import generate_answer
answer = generate_answer(
user_id="user123",
prompt="What did I read about machine learning last week?"
)
print(answer)The Q&A service returns markdown-formatted responses:
# Summary
Based on your browsing history, you read several articles about machine learning...
# Visited Links
- [https://example.com/ml-basics](https://example.com/ml-basics) β *January 10, 2024 at 2:30 PM UTC*
- [https://blog.ai/neural-networks](https://blog.ai/neural-networks) β *January 12, 2024 at 9:15 AM UTC*EMBED_DIM: 768 (dimension of Gemini embeddings)CHUNK_SIZE: 6000 characters per chunk (default, configurable)CHUNK_OVERLAP: 300 characters overlap between chunks (default, configurable)
top_k: Number of similar chunks to retrieve (default: 10)- Model: Gemini 1.5 Flash for answer generation
test_api.py: CLI script to test API endpoints.delete_pinecone.py: Delete all vectors from Pinecone index.test_gemini.py: Debug Gemini API connectivity.test_pinecone.py: Debug Pinecone v7 connectivity.
docker build -t memexlens-server .
docker run -p 8080:8080 --env-file .env memexlens-serverYou can deploy MemExLens Server to Google Cloud Run for scalable, serverless hosting. The project includes a GitHub Actions workflow for automated CI/CD.
-
Create a Google Cloud Project
- Enable Cloud Run, Artifact Registry, and IAM APIs.
-
Create Artifact Registry
- Example:
gcloud artifacts repositories create memexlens-server --repository-format=docker --location=us-east1
- Example:
-
Build and Push Docker Image
- Authenticate Docker with GCP:
gcloud auth configure-docker us-east1-docker.pkg.dev
- Build and push:
docker build -t us-east1-docker.pkg.dev/<PROJECT_ID>/memexlens-server/memexlens-server:latest . docker push us-east1-docker.pkg.dev/<PROJECT_ID>/memexlens-server/memexlens-server:latest
- Authenticate Docker with GCP:
-
Deploy to Cloud Run
- Deploy the image:
gcloud run deploy memexlens-server \ --image us-east1-docker.pkg.dev/<PROJECT_ID>/memexlens-server/memexlens-server:latest \ --region us-east1 \ --set-env-vars GEMINI_API_KEY=... \ --set-env-vars PINECONE_API_KEY=... \ --set-env-vars PINECONE_ENVIRONMENT=... \ --set-env-vars PINECONE_INDEX_NAME=...
- Deploy the image:
-
Access the Service
- After deployment, Cloud Run will provide a public HTTPS URL.
This project uses a GitHub Actions workflow (.github/workflows/deploy.yaml) to automate deployment to Cloud Run on every push to the main branch.
-
Checkout Code
- Uses
actions/checkoutto pull the latest code.
- Uses
-
Authenticate with Google Cloud
- Uses
google-github-actions/authwith a service account key stored in GitHub Secrets.
- Uses
-
Set Up Cloud SDK
- Installs and configures the Google Cloud SDK.
-
Configure Docker for Artifact Registry
- Enables Docker to push images to GCP Artifact Registry.
-
Build Docker Image
- Builds the Docker image using the provided
Dockerfile.
- Builds the Docker image using the provided
-
Push Docker Image
- Pushes the built image to Artifact Registry.
-
Deploy to Cloud Run
- Deploys the new image to Cloud Run, passing all required environment variables (API keys, config).
-
Output Service URL
- Prints the deployed Cloud Run service URL for reference.
GEMINI_API_KEY,PINECONE_API_KEY,PINECONE_ENVIRONMENT, etc. are securely passed from GitHub Secrets/Variables.- The workflow uses a service account with permissions for Cloud Run and Artifact Registry.
- Push to
mainbranch triggers deployment. - Update secrets and variables in your GitHub repository settings as needed.
- See
.github/workflows/deploy.yamlfor full details.
- User data is isolated by
userIdfiltering. - Each user can only query their own browsing history.
- Chunk IDs are generated using MD5 hashing for uniqueness.
- Never commit your real
.envfile.
- Failed embeddings default to zero vectors to prevent data loss.
- Service continues processing even if individual chunks fail.
- Q&A service returns graceful error messages if generation fails.
- Maximum chunk size of 6000 characters may split important context.
- Requires active internet connection for API calls.
- Vector search may miss exact keyword matches.
- Storage costs scale with browsing history volume.
- Add date range filtering for queries.
- Implement incremental updates for changed pages.
- Add support for multimedia content extraction.
- Enable cross-user knowledge sharing (with permissions).
- Implement local caching for frequently accessed data.
- Embeddings: Uses Gemini's
models/embedding-001(768-dim). - Vector DB: Pinecone v7 (Serverless, GCP region).
- Chunking: Configurable chunk size and overlap for long texts.
- User Isolation: All vectors are tagged with
userId.
MIT License. See LICENSE for details.
- Q: My API key doesn't work!
- A: Check
.env, ensure no whitespace, and that your key is active.
- A: Check
- Q: Pinecone index not found?
- A: The service will auto-create it if missing.
- Q: Can I use this for multiple users?
- A: Yes, all data is isolated by
userId.
- A: Yes, all data is isolated by
Pull requests welcome! Please open issues for bugs or feature requests.
For questions, reach out via GitHub Issues or email the maintainers sarthakd.work@gmail.com, kartikraut023@gmail.com, aadityakasbekar@gmail.com


