This is the backend API service for the Dell Pro AI Studio Chat PWA's vector database functionality. It provides endpoints for accessing and searching vector databases such as PostgreSQL with pgvector extension.
- Python 3.8+
- PostgreSQL with pgvector extension (for local PGVector)
- Podman and Podman Compose (recommended for containerized setup)
- Create a Python virtual environment:
python -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create a
.envfile from the example:
cp .env.example .env-
Edit the
.envfile to configure your vector database connections. -
Run the API server:
python run.pyThe API will be available at http://localhost:8000
- Configure environment variables (optional):
cp .env.example .env
# Edit .env as needed- Start the services with Podman Compose:
podman-compose up -dThe API will be available at http://localhost:8000
The backend includes scripts to load NASA Apollo mission transcripts into the PGVector database:
# Start the backend if it is not already started
yarn backend:start
# Clear existing data
python scripts/clear_vector_db.py --clear-collections
# Load all collections from mission_collections.json
python scripts/load_mission_collections.py
# Load a specific collection (Apollo 11 only)
python scripts/load_mission_collections.py --collections-file scripts/apollo11_only.jsonOr use the npm scripts from the root of the repository:
# Clear existing data and load NASA Apollo mission transcripts
yarn backend:load-data
# Or load only the mission data
yarn backend:load-missions
# To clear the database without loading new data
yarn backend:clear-dataFor more details about loading data, see the Data Loading Scripts README.
GET /health- Health check endpointGET /vector-stores- List all available vector storesGET /collections- List all available document collectionsGET /search- Search for documents
See the API documentation at http://localhost:8000/docs for detailed endpoint specifications.
Run the tests with pytest:
pytestOr run a specific test file:
pytest app/tests/test_health.pyRun the integration test:
pytest app/tests/test_integration.py -vUpdate the frontend settings to point to this API:
- In the application settings, set the API Base URL to http://localhost:8000
- The frontend will automatically use this service for vector store operations
The main repository includes several npm scripts to manage the backend:
# Start the backend with podman-compose
yarn backend:start
# Stop the backend services
yarn backend:stop
# View backend logs
yarn backend:logs
# Restart the backend services
yarn backend:restart
# Setup local venv (only need to run this once)
yarn backend:setup-venv
# Run backend tests
yarn backend:test
# Run only backend unit tests
yarn backend:test:unit
# Run only backend integration tests
yarn backend:test:integration- The API is built with FastAPI
- Run the server with
uvicorn app.main:app --reloadfor development with auto-reload - Use
podman-compose up -dto start the entire stack including PostgreSQL with pgvector
If you see an error about port 8000 being in use, this could be because:
- The API server is already running
- Another application is using port 8000
To resolve this:
# Find processes using port 8000
lsof -i :8000
# Stop the process (replace PID with the actual process ID)
kill PIDIf you encounter issues with the vector database connection:
- Verify that PostgreSQL is running properly:
podman ps | grep postgres- Check the PostgreSQL logs:
podman logs backend-postgres-1- Run the connection test script:
python test_connection.pyThis script will attempt to connect to the database and verify that the pgvector extension is properly installed.