Skip to content

Repository files navigation

Search Typeahead

A search typeahead system with prefix suggestions, a distributed cache using consistent hashing, recency-aware trending, and batched writes.

  • Backend: FastAPI (Python 3.13), managed with uv
  • Primary store: PostgreSQL
  • Distributed cache: 3 Redis shards on a consistent-hash ring
  • Frontend: React (Vite) — coming soon

Architecture (high level)

React UI ──► FastAPI ──► consistent-hash ring ──► Redis shard (cache)
                              │ miss
                              ▼
                         Postgres (primary store, indexed prefix lookup)

POST /search ──► in-memory buffer + WAL ──► periodic batched UPSERT

Run it

Everything runs in Docker:

docker compose up -d --build
curl http://localhost:8000/health

Services:

Service URL / port Role
backend http://localhost:8000 API
postgres localhost:5432 primary store
redis-0 localhost:6379 cache node 0
redis-1 localhost:6380 cache node 1
redis-2 localhost:6381 cache node 2

Development

Dependencies are managed with uv:

cd backend
uv sync                              # install into .venv
uv add <pkg>                         # add a dependency
uv pip freeze > requirements.txt     # regenerate the Docker requirements

Configuration lives in environment variables (see .env.example).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages