Python with FastAPI using Postgres & tsvector. Open Source, production ready Python FastAPI/Postgres app. GitHub | NX-AI onrender
Python with FastAPI using Postgres & tsvector.
Open Source, production ready Python FastAPI/Postgres app for NX
uvicorn app.main:app --reloadCreate an environment file and add Postgres credentials etc
cp .env.sample .env
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reloadThe API is at http://localhost:8000.
localhost | Public RESTful API
- Python 3.11+
- Postgres
- tsvector - Superfast full-text search (with GIN index)
The prospects table includes a search_vector column (type: tsvector) that is automatically computed from all text fields on insert. A GIN index is created for this column, enabling fast and scalable full-text search queries.
How it works:
- On every insert or update, the
search_vectoris computed from all text columns using PostgreSQL'sto_tsvector('english', ...). - The GIN index (
idx_prospects_search_vector) allows efficient search queries like:
SELECT * FROM prospects WHERE search_vector @@ plainto_tsquery('english', 'search terms');This makes searching across all text fields in the prospects table extremely fast, even for large datasets.
- FastAPI — RESTful API framework
- Uvicorn — ASGI server
- Pytest — testing framework
- HTTPX / TestClient
FastAPI automatically generates interactive documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
The /prospects/process endpoint is designed for robust, scalable ingestion of large CSV files (e.g., 1300+ rows, 300KB+). It follows the same normalization and insertion pattern as /prospects/seed, but is optimized for large files: