Skip to main content

Author

Pranav Verma

Firebase RAG CLI (Firestore Natural Language Query Engine)

A Retrieval-Augmented Generation (RAG) system that allows you to query Firebase Firestore using natural language prompts, powered by Llama 3 via Ollama.

This tool converts plain English questions into structured Firestore queries and returns results directly from your database.


Features

  • Natural language querying for Firestore
  • Schema-aware query generation (required)
  • Powered by Llama 3 via Ollama
  • CLI-based initialization
  • Firebase Admin SDK integration
  • Fully local execution (no cloud dependency for query processing)
  • Private key remains local to your machine during execution
  • Simple setup and execution

Security & Privacy

This tool is designed with a local-first architecture:

  • All query processing happens locally on your machine
  • Llama 3 runs locally via Ollama
  • Firebase service account key (firebase-key.json) is used only locally by Firebase Admin SDK
  • The private key is never sent to any external server by this library
  • Users provide their own credentials, and all database access happens from their local environment
  • No user queries, schema data, or Firestore results are transmitted to third-party services by this tool

Note: The Firebase private key is used locally to authenticate requests with Firebase Admin SDK. It is not exposed to the internet by this library.


Prerequisites

1. Install Ollama and Llama 3

pip install ollama
ollama pull llama3

Make sure Ollama is installed and running on your system.


2. Firebase Setup

You must have a Firebase project and a service account key file.

Download your firebase-key.json from Firebase Console.


Installation

pip install pranavfirebase-rag

Initialization

After installing the package, run:

my-library init

This command will generate the following files in your project directory:

schema.json
firebase-key.json
rag.py

Configuration

1. schema.json (Required)

You must define your Firestore schema in this file.

Example:

{
  "users": {
    "Age": "int",
    "Name": "string",
    "Department": "string",
    "Salary": "int"
  }
}

This schema is mandatory and used for query parsing and structured retrieval.


2. firebase-key.json

Paste your Firebase service account credentials into this file.

Important:

  • The private key is stored locally on your machine
  • It is only used by Firebase Admin SDK for authentication
  • This library does not transmit it anywhere

Example structure:

{
  "type": "service_account",
  "project_id": "your-project-id",
  "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
  "client_email": "your-client-email"
}

3. rag.py

This file is the main chatbot entry point.

Important:

  • Replace the default collection name (e.g. employees) with your Firestore collection name
  • Do not modify internal logic unless required

Usage

Run the chatbot:

python rag.py

You will enter an interactive terminal where you can query your database.


Example Queries

  • Show all users above 25
  • List employees in AI department
  • Get users with salary greater than 100000
  • Find all names in the users collection
  • Show users younger than 30

How It Works

User Input → Llama 3 (Ollama) → Schema Parser → Query Builder → Firestore (Firebase Admin SDK) → Response Output


Architecture

User Input → Llama 3 (Ollama) → Schema Parser → Query Builder → Firestore → Response Output


Notes

  • Schema definition is required (not optional)
  • Firebase credentials must be valid
  • Ollama + Llama 3 must be installed and running before execution
  • Collection name must be correctly set in rag.py

Requirements

  • Python 3.8+
  • Firebase Admin SDK
  • Ollama
  • Llama 3 model

Release files for pranavfirebase-rag 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pranavfirebase-rag 0.1.4
File Size Uploaded
pranavfirebase_rag-0.1.4.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pranavfirebase-rag 0.1.4
File Interpreter ABI Platform
pranavfirebase_rag-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 13.5 kB

Release files / pranavfirebase_rag-0.1.4.tar.gz

Download URL pranavfirebase_rag-0.1.4.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f8a10f7e36d7c7a916853173f2cc277a61de8c19084db755abb8ec75baf6fd5c
BLAKE2b-256 checksum
How to use checksums
f75c085cf32c53946a22e28b0bc389c65a32befefdcfad445a73329a55e61581
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / pranavfirebase_rag-0.1.4-py3-none-any.whl

Download URL pranavfirebase_rag-0.1.4-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
edef1f47210e646771041128fa8519166d0bc684be16f5d294880d4d2b05a791
BLAKE2b-256 checksum
How to use checksums
08fe07baeb3b69ba40000c6779878b36c38466e49001600f604b35089274d241
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page