This document outlines the steps to set up and run the project locally.
- Python installed
- PostgreSQL server installed and running
- Redis server installed and running
- A local embedding generation model
(We used BAAI/bge-small-en) - Git installed
# Create a new virtual environment
python3 -m venv .venv
# Activate the environment (Linux/macOS)
source .venv/bin/activate
# Activate on Windows (PowerShell)
.venv\Scripts\Activate.ps1pip install --upgrade pip
pip install -r requirements.txt# Access PostgreSQL
psql postgres
# Create a new database and user
CREATE DATABASE your_db_name;
CREATE USER your_user_name WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE your_db_name TO your_user_name;Update your .env file with the correct database URL.
Example:
DATABASE_URL = "postgresql://your_user_name:your_password@localhost:5432/your_db_name"# Start Redis server (Linux/macOS)
redis-server
Update your .env file:
REDIS_URL = "redis://localhost:6379"- Download the BAAI/bge-small-en model.
- Save it locally (for example:
/home/user/models/bge-small-en). - Update your
.envfile:
MODEL_PATH = "/path/to/your/downloaded/model"Create or update a .env file at the project root:
# Example .env file
DATABASE_URL = "postgresql://your_user_name:your_password@localhost:5432/your_db_name"
REDIS_URL = "redis://localhost:6379"
MODEL_PATH = "/path/to/your/downloaded/model"Start the FastAPI server with live reload:
uvicorn main:app --reloadThe server will be accessible at:
http://localhost:8000
Important: You must reindex after each server restart.
Steps:
-
Open the FastAPI interactive docs at:
http://localhost:8000/docs#/ -
Find the
POST /product/reindex/endpoint. -
Click Try it out ➔ Execute (no request body needed).
- Open
search.htmlin your browser. - Enter a query and submit to view search results.