Educational demo: upload any file (text, image, PDF, audio, video, ZIP, RAR) and search them semantically using gemini-embedding-2 embeddings stored in MongoDB Atlas Local.
- Python 3.12+
- Docker (for MongoDB Atlas Local)
- ffmpeg (
apt install ffmpeg/brew install ffmpeg/winget install ffmpeg) - unrar (
apt install unrar/brew install rar/winget install RARLab.WinRAR) - Google Cloud SDK with
gcloud auth application-default logincompleted - A GCP project with Vertex AI API enabled
git clone https://github.com/sergiomarquezdev/gemini-embeddings-2-mongo-demo.git
cd gemini-embeddings-2-mongo-demo
python -m venv .venv
source .venv/bin/activate # Linux / macOS
# source .venv/Scripts/activate # Windows (Git Bash)
# .venv\Scripts\activate # Windows (PowerShell / cmd)
pip install -r requirements.txt
cp .env.example .env
# Edit .env and set GCP_PROJECT to your project ID
docker compose up -d mongo
gcloud auth application-default login
uvicorn app:app --reloadGET /healthreturns{mongo: "ok", dedup_index: "ready", vector_index: "ready", vertex: "configured"}- Upload 3 short
.txt(cats, soccer, JS), search"animales domésticos"→ top result is the cats file - Upload images (beach, dog, pizza), search
"comida italiana"→ top result is pizza - Upload a 4-page scanned PDF, search text only present in the scanned image → matches (OCR works)
- Upload a 15-page PDF → response shows
n_chunks: 5 - Upload the same
.txttwice → second response isstatus: "already_indexed" - Upload a ZIP with
.txt + .png + .pdf + .exe→ 3 ok, 1 skipped - Upload a 30-second
.mp3→ search text from the audio → matches - Upload an
.exedirectly → 415 with explicit error - Upload a corrupt PDF → 422
docker compose up -d mongo
.venv/Scripts/python.exe -m pytest -v # Windows
# or: pytest -v (after activating venv on Linux/Mac)Tests mock Vertex AI but use real MongoDB. They create disposable databases per test and clean up. One test (tests/test_archives_rar.py::test_extract_rar_with_text_file) skips automatically if unrar is not installed.
vector_index: "missing"— Atlas Local builds the index on first start; wait ~30s and retry/health.Vertex AI: 403—gcloud auth application-default loginnot completed, or Vertex AI API not enabled in the project.ffmpeg: not found— install ffmpeg system-wide; not pip-installable.unrar: not found— install via system package manager. Without it,.raruploads fail with 500 and the RAR test is skipped.vector_search: command not recognized— you ran the standardmongoimage instead ofmongodb/mongodb-atlas-local. Checkdocker-compose.yml.
- Design spec:
docs/superpowers/specs/2026-05-11-gemini-embedding-2-mongo-design.md - Implementation plan:
docs/superpowers/plans/2026-05-12-gemini-embedding-2-mongo-implementation.md