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
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
Everything runs in Docker:
docker compose up -d --build
curl http://localhost:8000/healthServices:
| 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 |
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 requirementsConfiguration lives in environment variables (see .env.example).