Skip to content

Latest commit

 

History

History
75 lines (47 loc) · 2.17 KB

File metadata and controls

75 lines (47 loc) · 2.17 KB

Python

Production-ready, open-source FastAPI application with PostgreSQL and blazing-fast full-text search.

Project Overview

This project provides a scalable API backend using FastAPI and PostgreSQL, featuring:

  • Automatic full-text search on all text fields (via tsvector)
  • Endpoints for health checks, product management, prompt handling, and prospect management
  • Efficient ingestion and processing of large CSV files

🚀 Features

  • Python 3.11+
  • FastAPI — Modern, high-performance REST API
  • PostgreSQL — Robust relational database
  • tsvector + GIN — Superfast full-text search
  • Uvicorn — Lightning-fast ASGI server
  • Pytest — Comprehensive testing

Getting Started

1. Clone & Setup Environment

git clone <repo-url>
cd python
cp .env.sample .env  # Add your Postgres credentials and settings
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

2. Run the App

uvicorn app.main:app --reload

Visit localhost:8000 or onrender

API Documentation

FastAPI auto-generates interactive docs:

Full-Text Search (tsvector)

The prospects table includes a search_vector column (type: tsvector) computed from all text fields on insert/update. A GIN index enables fast, scalable full-text search:

SELECT * FROM prospects WHERE search_vector @@ plainto_tsquery('english', 'search terms');

How it works:

  • On every insert/update, search_vector is computed using PostgreSQL's to_tsvector('english', ...).
  • The GIN index (idx_prospects_search_vector) enables efficient search across large datasets.

Processing Large CSV Files

The /prospects/process endpoint supports robust ingestion of large CSVs (e.g., 1300+ rows, 300KB+), following the same normalization and insertion pattern as /prospects/seed but optimized for scale.

Contributing

Contributions welcome. Please open issues or submit pull requests.

License

This project is licensed under the MIT License. See LICENSE for details.