The Bible Assistant API is a powerful semantic search engine and AI-powered insights generator for biblical texts and patristic commentaries. Built with Flask, LangChain, and ChromaDB, it enables users to explore scripture through natural language queries, delivering context-aware search results and theological insights.
- Semantic Search: Find relevant Bible verses and Church Father commentaries using natural language (e.g., "What does the Bible say about anxiety?" vs. keyword search).
- AI Insights: Generates theological summaries, connections, and practical applications based on retrieved passages using LLMs (OpenAI/Anthropic).
- Real-time Streaming: Utilizes Server-Sent Events (SSE) to stream search results and AI tokens for a responsive user experience.
- Vector Database: Uses ChromaDB with
hkunlp/instructor-largeembeddings for high-accuracy text retrieval. - Comprehensive Filtering: Filter results by Old Testament, New Testament, or Church Father commentaries.
- Backend: Flask (Python)
- AI/Orchestration: LangChain, OpenAI API / Anthropic API
- Database: ChromaDB (Vector Store)
- Embeddings: HuggingFace Instructor Embeddings
- Documentation: Swagger UI (
flasgger)
- Python 3.12
- OpenAI API Key
- Git
-
Clone the repository:
git clone https://github.com/eymanM/bible-assistant.git cd bible-assistant -
Create and activate a virtual environment:
python -m venv venv # Windows .\venv\Scripts\activate # Linux/Mac source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure Environment: Create a
.envfile in the root directory (see.env.examplefor a template) and add your keys:OPENAI_API_KEY=your_openai_key XAI_API_KEY=your_xai_key DATABASE_URL=postgresql://user:password@localhost:5432/bible_assistant API_KEY=your_secret_api_key ENV=dev PORT=5000
-
Run the application:
python app.py
The API will start at
http://127.0.0.1:5000.
Build and run the application using Docker:
# Build the image
docker build -t bible-assistant .
# Run the container
docker run -p 5000:5000 --env-file .env bible-assistantInteractive API documentation is available via Swagger UI.
- Start the application.
- Navigate to
http://127.0.0.1:5000/apidocs.
POST /search: Main search endpoint. Accepts a JSON body withqueryandsettings. Returns an event stream.GET /health: Health check endpoint. Returns200 OKif the service is running.
This project uses pytest for unit testing. The tests mock external dependencies (OpenAI, ChromaDB) to ensure speed and reliability.
# Run tests
python -m pytest tests/This API is designed to work with a modern frontend application. The official frontend implementation is built with Next.js and can be found here:
Ensure the frontend is configured to point to http://127.0.0.1:5000 (or your deployed URL).