Skip to content
tejas-gkPublic

About

A search engine built from scratch, including web crawling, indexing, ranking, and full-text search, with a Go-based backend and Meilisearch.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Google Distributed Search Stack

This repository contains a distributed crawl -> process -> route -> embed -> search pipeline with a web UI.

What This System Does

  1. go-crawler crawls and publishes crawl events.
  2. go-processor cleans/enriches pages, writes MongoDB, indexes Meilisearch, and emits process events.
  3. go-pipeline routes Kafka topics with Redis dedupe:
    • crawl-events -> process-events
    • process-events -> embed-events
  4. embed/embed_worker.py consumes embed-events and writes embeddings to MongoDB.
  5. go-search serves search APIs (/search, /search/images, /knowledge, /faq).
  6. search-ui serves the frontend.

Prerequisites

  • Docker Desktop (running)
  • Go 1.22+
  • Node.js 20+
  • npm 10+
  • Python 3.13 or 3.14

Recommended on Windows:

  • Use Python 3.13 for embed_server.py because older Torch pins may not support Python 3.14.
  • embed_worker.py can run on Python 3.14 with current compatible packages.

Repository Layout

  • docker-compose.yml -> local infra
  • go-crawler/ -> crawler service
  • go-processor/ -> cleaner/indexer service
  • go-pipeline/ -> Kafka router/dedupe service
  • go-search/ -> search API service
  • embed/ -> embedding server + embedding worker
  • search-ui/ -> Next.js frontend

One-Time Setup

1) Start infrastructure

From repo root:

docker compose up -d redis redpanda mongodb meilisearch

Validate broker health:

docker exec redpanda rpk cluster health

Create app topics (safe to run repeatedly):

docker exec redpanda rpk topic create crawl-events process-events embed-events feedback-events --partitions 1 --replicas 1

2) Install Go dependencies

cd go-crawler; go mod tidy
cd ..\go-processor; go mod tidy
cd ..\go-pipeline; go mod tidy
cd ..\go-search; go mod tidy

3) Install frontend dependencies

cd ..\search-ui
npm install

4) Setup Python for embedding services

Option A (recommended): Python 3.13 virtual env for server + worker

cd ..\embed
py -3.13 -m venv .venv313
.\.venv313\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements.txt

Option B: Python 3.14 worker-only quick setup

If Torch install fails on 3.14, run worker-only dependencies:

cd embed
py -m pip install kafka-python redis requests pymongo

How To Run (Normal Development)

One command with all logs

From repo root in PowerShell:

.\run.ps1

This starts Docker infrastructure, creates Kafka topics, starts the always-on app services, and streams Docker + app logs in one terminal with service prefixes. Open:

  • http://localhost:3000

Optional data build jobs:

.\run.ps1 -WithCrawler
.\run.ps1 -WithProcessor
.\run.ps1 -WithCrawler -WithProcessor

Useful launcher flags:

  • -Build -> rebuild Docker infrastructure images before starting.
  • -SkipInfra -> skip Docker startup/topic creation when infra is already running.
  • -CpuThreads 2 -> raise the default low-CPU thread limit.

Press Ctrl+C to stop app processes. Docker infrastructure remains running.

Manual terminals

Open separate terminals.

Terminal 1: Embed server

cd D:\work\org\google\embed
py .\embed_server.py

Expected:

  • model loading logs
  • server starts on http://localhost:5000

Terminal 2: Pipeline router

cd D:\work\org\google\go-pipeline
$env:KAFKA_BROKERS="localhost:9092"
$env:REDIS_ADDR="localhost:6379"
go run .

Expected:

  • Pipeline router starting mode=all
  • routing lines for both routes

Terminal 3: Embedding worker

cd D:\work\org\google\embed
py .\embed_worker.py

Expected:

  • Starting embed worker topic=embed-events brokers=['localhost:9092']

Terminal 4: Search API

cd D:\work\org\google\go-search
go run .

Expected:

  • API running on :8080
  • inverted index ready message

Terminal 5: Frontend

cd D:\work\org\google\search-ui
npm run dev

Open:

  • http://localhost:3000

Data Build / Refresh Workflow

Run these when you want fresh crawl/index data.

A) Crawl new pages

cd D:\work\org\google\go-crawler
$env:MONGO_URI="mongodb://admin:securepassword@localhost:27017"
go run .

B) Process + index pages

If running embed server during processing:

cd D:\work\org\google\go-processor
$env:MONGO_URI="mongodb://admin:securepassword@localhost:27017"
$env:SKIP_EMBEDDINGS="0"
go run .

If embedding should be fully event-driven through embed_worker.py:

cd D:\work\org\google\go-processor
$env:MONGO_URI="mongodb://admin:securepassword@localhost:27017"
$env:SKIP_EMBEDDINGS="1"
go run .

When To Run What

  • go-crawler: when you need to discover/fetch new pages.
  • go-processor: after crawl, to clean/rank/index pages.
  • go-pipeline: whenever distributed event routing is needed (usually always-on in dev).
  • embed_worker.py: when embed-events are used for async embeddings.
  • embed_server.py: required if any component requests local embedding API.
  • go-search: always needed for API endpoints.
  • search-ui: always needed for browser interface.

Health Checks

Kafka / Redpanda

docker exec redpanda rpk cluster health
docker exec redpanda rpk topic list

Search API

curl "http://localhost:8080/search?q=example"
curl "http://localhost:8080/knowledge?q=example"
curl "http://localhost:8080/faq?q=example"

Troubleshooting

1) Group Coordinator Not Available in go-pipeline

Cause:

  • broker not running yet, or topic/coordinator not ready.

Fix:

docker compose up -d redpanda
docker exec redpanda rpk cluster health
docker exec redpanda rpk topic create crawl-events process-events embed-events feedback-events --partitions 1 --replicas 1
cd D:\work\org\google\go-pipeline
go run .

2) ModuleNotFoundError: No module named 'kafka'

Fix:

cd D:\work\org\google\embed
py -m pip install kafka-python redis requests pymongo

3) No matching distribution found for torch==2.1.1

Cause:

  • Torch pin may not support your Python version (commonly Python 3.14).

Fix:

  • use Python 3.13 venv for embed_server.py, or
  • upgrade Torch pins in requirements to versions supporting your runtime.

4) embeddings.position_ids | UNEXPECTED

Meaning:

  • common model-load warning when loading from a related architecture/task.
  • often safe if model runs and output quality is acceptable.
  • not safe only if you require exact architecture weight parity.

5) Hugging Face 307 Temporary Redirect and 404 on optional paths

Meaning:

  • 307 on model files is normal CDN redirect behavior.
  • 404 for optional paths like additional_chat_templates is usually harmless.

6) CLIP not available: No module named 'clip'

Meaning:

  • image embedding falls back to text-only mode.

Fix (optional):

cd D:\work\org\google\embed
py -m pip install openai-clip

If CLIP still fails, keep running text-only mode for images.

Useful Script

Windows interactive helper:

cd D:\work\org\google
.\pipeline.bat

This script can run crawl/process/debug flows and starts MongoDB if needed.

About

A search engine built from scratch, including web crawling, indexing, ranking, and full-text search, with a Go-based backend and Meilisearch.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages