Skip to main content

FLAMEHAVEN FileSearch - Open source semantic document search powered by Google Gemini

Project description

๐Ÿ”ฅ FLAMEHAVEN FileSearch

Open-source semantic document search you can self-host in minutes.

CI/CD PyPI Python Versions License: MIT

The lightweight RAG stack that makes your documents searchable in minutes

Quick Start โ€ข Features โ€ข Documentation โ€ข API Reference โ€ข Examples


๐ŸŽฏ Why Flamehaven?

โšก Fast

From zero to production in under 5 minutes. No complex infrastructure.

๐Ÿ”’ Private

100% self-hosted. Your data never leaves your servers.

๐Ÿ’ฐ Affordable

Leverages Gemini's generous free tier. Process thousands of docs free.

๐Ÿ†š Comparison with Alternatives

Feature Flamehaven Pinecone Weaviate Custom RAG
Setup Time < 5 min ~20 min ~30 min Days
Self-Hosted โœ… โŒ โœ… โœ…
Free Tier Generous Limited Yes N/A
Code Complexity Low Medium High Very High
Maintenance Minimal None Medium High
Best For Quick POCs, SMBs Enterprise scale ML teams Full control

โœจ Features

Feature Description
๐Ÿ“„ Multi-Format PDF, DOCX, TXT, MD files up to 50MB
๐Ÿ” Semantic Search Natural language queries with AI-powered answers
๐Ÿ“Ž Source Citations Every answer links back to source documents
๐Ÿ—‚๏ธ Store Management Organize documents into separate collections
๐Ÿ”Œ Dual Interface Python SDK + REST API with Swagger UI
๐Ÿณ Docker Ready One-command deployment with persistence

๐Ÿ†• New in v1.1.0 (Production-Ready)

Feature Description Impact
โšก LRU Caching 1-hour TTL, 1000 items 99% faster on cache hits (<10ms)
๐Ÿ›ก๏ธ Rate Limiting Per-endpoint limits 10/min uploads, 100/min searches
๐Ÿ“Š Prometheus Metrics 17 metrics exported Real-time monitoring & alerting
๐Ÿ”’ Security Headers OWASP-compliant CSP, HSTS, X-Frame-Options
๐Ÿ“ JSON Logging Structured logs ELK/Splunk compatible
๐ŸŽฏ Request Tracing X-Request-ID headers Distributed tracing support

v1.1.0 Highlights: 40-60% cost reduction โ€ข Zero critical vulnerabilities โ€ข SIDRCE Certified (0.94) โ†’ Full Changelog


โšก Quick Start

1๏ธโƒฃ Install

pip install flamehaven-filesearch[api]  # ~30 seconds

2๏ธโƒฃ Set API Key

export GEMINI_API_KEY="your-google-gemini-key"

๐Ÿ’ก Get your free key at Google AI Studio (2 min signup)

3๏ธโƒฃ Start Searching

Option A: Python SDK

from flamehaven_filesearch import FlamehavenFileSearch

fs = FlamehavenFileSearch()
fs.upload_file("company-handbook.pdf")

result = fs.search("What is our vacation policy?")
print(result["answer"])
# Expected: "Employees receive 15 days of paid vacation annually..."
print(f"๐Ÿ“Ž Sources: {result['sources'][0]['filename']}, page {result['sources'][0]['page']}")

Option B: REST API

# Start server
flamehaven-api

# Upload (in new terminal)
curl -X POST "http://localhost:8000/upload" -F "file=@handbook.pdf"

# Search
curl "http://localhost:8000/search?q=vacation+policy"

๐ŸŒ Interactive Docs: Visit http://localhost:8000/docs

โš ๏ธ Troubleshooting:

  • ModuleNotFoundError: Run pip install -U pip first
  • API errors: Check your key has no spaces
  • More solutions โ†’

๐Ÿ’ก Usage Examples

Organize Documents by Type

fs = FlamehavenFileSearch()

# Separate stores for different contexts
fs.create_store("hr-docs")
fs.create_store("engineering")

fs.upload_file("handbook.pdf", store="hr-docs")
fs.upload_file("api-spec.md", store="engineering")

# Search specific context
result = fs.search("PTO policy", store="hr-docs")

Batch Upload Directory

import glob

for pdf in glob.glob("./documents/*.pdf"):
    print(f"๐Ÿ“ค {pdf}...")
    fs.upload_file(pdf, store="company-docs")

โš™๏ธ Configuration

Configure via environment variables or .env file:

Variable Default Description
GEMINI_API_KEY required Your Google Gemini API key
ENVIRONMENT production Logging mode: production (JSON) or development (readable)
DATA_DIR ./data Document storage location
MAX_FILE_SIZE_MB 50 Maximum file size (Gemini limit)
MAX_SOURCES 5 Number of source citations
DEFAULT_MODEL gemini-2.5-flash Gemini model to use
HOST 0.0.0.0 API server host (v1.1.0+)
PORT 8000 API server port (v1.1.0+)
WORKERS 1 Number of workers (v1.1.0+)

Example .env:

GEMINI_API_KEY=AIza...your-key-here
ENVIRONMENT=production        # JSON logs for production
DATA_DIR=/var/flamehaven/data
MAX_SOURCES=3
WORKERS=4                     # Production deployment

โ†’ Complete configuration reference


๐Ÿ“ฆ Installation

Prerequisites

  • Python 3.8 or higher
  • Google Gemini API key (Get it free)

Install from PyPI

# Basic installation
pip install flamehaven-filesearch

# With API Server
pip install flamehaven-filesearch[api]

Development Setup

git clone https://github.com/flamehaven01/Flamehaven-Filesearch.git
cd Flamehaven-Filesearch
pip install -e .[dev,api]
pytest tests/

๐Ÿณ Docker Deployment

Quick Start:

docker run -e GEMINI_API_KEY="your-key" \
  -p 8000:8000 \
  -v flamehaven-data:/app/data \
  flamehaven/filesearch:latest

Docker Compose:

version: '3.8'
services:
  flamehaven:
    image: flamehaven/filesearch:latest
    ports:
      - "8000:8000"
    environment:
      - GEMINI_API_KEY=${GEMINI_API_KEY}
    volumes:
      - ./data:/app/data
    restart: unless-stopped

โ†’ Production deployment guide


๐Ÿ“ก API Reference

Core Endpoints

POST /upload

Upload a document to a store.

Request:

curl -X POST "http://localhost:8000/upload" \
  -F "file=@report.pdf" \
  -F "store=default"

Response:

{
  "filename": "report.pdf",
  "store": "default",
  "file_id": "abc123...",
  "status": "uploaded"
}

GET /search

Search documents with natural language.

Request:

curl "http://localhost:8000/search?q=vacation+policy&store=default&max_sources=3"

Response:

{
  "answer": "Employees receive 15 days of paid vacation annually...",
  "sources": [
    {
      "filename": "handbook.pdf",
      "page": 42,
      "excerpt": "Vacation Policy: All full-time employees..."
    }
  ],
  "query": "vacation policy",
  "model": "gemini-2.5-flash"
}

GET /stores | DELETE /stores/{name}

Manage document stores.

GET /prometheus (v1.1.0+)

Prometheus metrics endpoint for monitoring.

Exported Metrics:

  • HTTP requests, duration, active requests
  • Upload/search counts, duration, results
  • Cache hits/misses, size
  • Rate limit exceeded events
  • System metrics (CPU, memory, disk)

Setup Prometheus scraping:

scrape_configs:
  - job_name: 'flamehaven'
    static_configs:
      - targets: ['localhost:8000']
    metrics_path: /prometheus

GET /metrics (Enhanced in v1.1.0)

Service metrics with cache statistics.

Response:

{
  "stores_count": 3,
  "uptime_seconds": 3600,
  "system": {"cpu_percent": 25.3, "memory_percent": 45.2},
  "cache": {
    "search_cache": {
      "hits": 89,
      "misses": 42,
      "hit_rate_percent": 67.94,
      "current_size": 127,
      "max_size": 1000
    }
  }
}

Error Handling

All errors return:

{
  "error": "Error message",
  "code": "ERROR_CODE"
}
Code Status Solution
FILE_TOO_LARGE 413 Reduce file size or increase limit
INVALID_API_KEY 401 Check your Gemini API key
STORE_NOT_FOUND 404 Create store first
RATE_LIMIT_EXCEEDED 429 Wait or upgrade API plan

Python SDK

from flamehaven_filesearch import FlamehavenFileSearch

fs = FlamehavenFileSearch(
    api_key="your-key",        # Optional if env var set
    data_dir="./data",         # Custom storage
    max_file_size_mb=100       # Override defaults
)

# API methods
fs.create_store(name)
fs.list_stores()
fs.delete_store(name)
fs.upload_file(path, store="default")
fs.search(query, store="default", max_sources=5)

โ†’ Complete API documentation


๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Client     โ”‚
โ”‚ (SDK/REST)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  FlamehavenFileSearch Core          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚  Document Processor            โ”‚ โ”‚
โ”‚  โ”‚  โ†’ PDF/DOCX/TXT/MD parsing     โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚               โ–ผ                      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚  Google Gemini API             โ”‚ โ”‚
โ”‚  โ”‚  โ†’ Embedding & Generation      โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚               โ–ผ                      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚  Store Manager                 โ”‚ โ”‚
โ”‚  โ”‚  โ†’ SQLite + File System        โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ†’ Detailed architecture docs


๐Ÿ“Š Performance

Test Environment: Ubuntu 22.04, 2 vCPU, 4GB RAM, SSD

Operation Time (v1.0.0) Time (v1.1.0) Improvement
Upload 10MB PDF ~5s ~5s Same (no cache)
Search query (first) ~2-3s ~2-3s Same (cache miss)
Search query (repeat) ~2-3s <10ms 99% faster โšก
Batch 3ร—5MB ~12s ~12s Same (sequential)

v1.1.0 Caching Impact:

  • Cache Hit Rate: 40-60% (typical usage)
  • Response Time (P50): <100ms (down from 2-3s)
  • API Cost Reduction: 40-60% fewer Gemini calls
  • Throughput: ~100 cached searches/sec (vs ~10 non-cached)

Throughput: ~100 cached searches/sec โ€ข ~10 API searches/sec โ€ข ~2MB/s processing โ†’ Detailed benchmarks


๐Ÿ”’ Security

v1.1.0 Security Features

  • โœ… Path Traversal Protection: File upload sanitization with os.path.basename()
  • โœ… Rate Limiting: Per-endpoint limits prevent abuse (10/min uploads, 100/min searches)
  • โœ… OWASP Security Headers: CSP, HSTS, X-Frame-Options, X-Content-Type-Options
  • โœ… Input Validation: XSS/SQL injection detection, filename sanitization
  • โœ… Request Tracing: X-Request-ID headers for audit trails
  • โœ… Zero Critical CVEs: Patched CVE-2024-47874, CVE-2025-54121 (Starlette)

Best Practices

  • API Keys: Use environment variables, never commit to git
  • Data Privacy: All documents stored locally in DATA_DIR
  • Network: Run behind reverse proxy with SSL in production
  • Encryption: Implement encryption at rest for sensitive docs
  • Monitoring: Track rate_limit_exceeded and errors_total Prometheus metrics

โ†’ Security guide โ€ข Security audit results


โ“ Troubleshooting

Common issues:

Problem Solution
ModuleNotFoundError pip install flamehaven-filesearch[api]
"API key invalid" Verify key: echo $GEMINI_API_KEY
Slow uploads Check file size, enable debug logs
Irrelevant results Reduce max_sources, lower temperature

Debug Mode:

export FLAMEHAVEN_DEBUG=1
flamehaven-api

โ†’ Full troubleshooting guide


๐Ÿ—บ๏ธ Roadmap

v1.1.0 (Released 2025-11-13): โœ… Caching โ€ข Rate limiting โ€ข Security fixes โ€ข Monitoring v1.2.0 (Q1 2025): Authentication โ€ข Batch API โ€ข WebSocket streaming v2.0.0 (Q2 2025): Multi-language โ€ข Analytics โ€ข Custom embeddings

Recent Releases:

  • v1.1.0: Production-ready with caching, rate limiting, Prometheus metrics
  • v1.0.0: Initial release with core file search capabilities

โ†’ Full changelog โ€ข Roadmap & voting


๐Ÿค Contributing

We welcome contributions!

Quick start:

  1. Fork & clone the repo
  2. Install: pip install -e .[dev,api]
  3. Create branch: git checkout -b feature/amazing
  4. Add tests & commit changes
  5. Open Pull Request

โ†’ Contributing guidelines โ€ข Good first issues


๐Ÿ“š Resources

Documentation

  • Wiki - Guides, recipes, best practices
  • API Docs - Interactive Swagger UI
  • Examples - Code samples & use cases

Community

Contact


๐Ÿ™ Acknowledgments

Built with: FastAPI โ€ข Google Gemini API โ€ข PyPDF2 โ€ข python-docx


๐Ÿ“„ License

MIT License - see LICENSE for details.


If Flamehaven helps you, please โญ the repo!

Made with โค๏ธ by the Flamehaven Team

โฌ†๏ธ Back to Top

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flamehaven_filesearch-1.1.0.tar.gz (40.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flamehaven_filesearch-1.1.0-py3-none-any.whl (40.5 kB view details)

Uploaded Python 3

File details

Details for the file flamehaven_filesearch-1.1.0.tar.gz.

File metadata

  • Download URL: flamehaven_filesearch-1.1.0.tar.gz
  • Upload date:
  • Size: 40.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flamehaven_filesearch-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e86223660a837d58c258aef775c6171bd49f68261833897104dabd6143c34e53
MD5 4f4977ec49a0d79ac1f72af7de028a9c
BLAKE2b-256 94ee4b01a22452b548add372705e2c3aa1109e975e8023038164750f62aa1245

See more details on using hashes here.

Provenance

The following attestation bundles were made for flamehaven_filesearch-1.1.0.tar.gz:

Publisher: publish.yml on flamehaven01/Flamehaven-Filesearch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flamehaven_filesearch-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flamehaven_filesearch-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6b19c1829a45dfee5f0cca81edde7baa5daa7a8813c11cb8492b68d4479a6a6
MD5 791a639baf494290bc14dc4fea04411b
BLAKE2b-256 47b739cb6bbaa27d8f2277c3eea5cfdf9c4b1e8edf88066d373356c94ea56a07

See more details on using hashes here.

Provenance

The following attestation bundles were made for flamehaven_filesearch-1.1.0-py3-none-any.whl:

Publisher: publish.yml on flamehaven01/Flamehaven-Filesearch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page