This guide provides detailed instructions for setting up RAGify from scratch, including prerequisites, environment configuration, database setup, and troubleshooting common issues.
- Operating System: Linux, macOS, or Windows 10+
- Python: Version 3.8 or higher
- Memory: Minimum 4GB RAM (8GB recommended)
- Storage: At least 2GB free space for models and data
- Network: Internet connection for downloading dependencies
- Python 3.8+ – main runtime
- SQLite – ships with Python, used by default
- Optional: PostgreSQL 12+ (if you need pgvector/permanent DB)
- Optional: Redis 6+ (for distributed caching; the app auto-falls back to an in-memory cache if Redis is unavailable)
git clone <repository-url>
cd RAGify# Create virtual environment
python -m venv venv
# Activate virtual environment
# Linux/macOS
source venv/bin/activate
# Windows
venv\Scripts\activate# Install the package in development mode
pip install -e .
# Or install dependencies manually
pip install -r requirements.txtCreate a .env file in the project root:
cp .env.example .envEdit the .env file with your configuration:
# Database Configuration
# Default: local SQLite file (no external service required)
DATABASE_URL=sqlite+aiosqlite:///./ragify.db
# To use PostgreSQL instead, replace the line above with:
# DATABASE_URL=postgresql+asyncpg://username:password@localhost:5432/ragify
# Security Settings
SECRET_KEY=your-super-secret-key-change-this-in-production
DEBUG=true
# Redis Configuration (optional)
REDIS_URL=redis://localhost:6379
# OpenRouter API Key (Primary AI Provider)
OPENROUTER_API_KEY=sk-or-v1-your-openrouter-api-key-here
# Default Model Settings
DEFAULT_MODEL=openai/gpt-4o-mini
DEFAULT_TEMPERATURE=0.7
DEFAULT_MAX_TOKENS=4096
# Application Settings
LOG_LEVEL=INFO
MAX_UPLOAD_SIZE=100MB
EMBEDDING_MODEL=all-MiniLM-L6-v2
# CORS Settings
ALLOWED_ORIGINS=http://localhost:5173,http://localhost:15173,http://localhost:3000
# Rate Limiting
RATE_LIMIT_REQUESTS=100
RATE_LIMIT_WINDOW=60SQLite works out of the box—no setup required. Just run ./startup.sh and pick option 1.
If you prefer PostgreSQL + pgvector:
- Create database and user
sudo -u postgres psql CREATE DATABASE ragify; CREATE USER ragify_user WITH PASSWORD 'your_secure_password'; GRANT ALL PRIVILEGES ON DATABASE ragify TO ragify_user; \q
- Verify connection
psql -h localhost -U ragify_user -d ragify
- Enable pgvector
psql -d ragify -c "CREATE EXTENSION IF NOT EXISTS vector;"
- Update
DATABASE_URLin.env, then run./startup.shand choose option 2 (PostgreSQL).
Tables are created automatically on startup; Alembic migrations remain available if you need manual control.
RAGify uses OpenRouter as the primary AI provider, giving you access to 100+ models through a single API.
- Visit OpenRouter
- Create an account or sign up
- Navigate to the API Keys section
- Create a new API key
- Add to your
.envfile:OPENROUTER_API_KEY=sk-or-v1-your-key-here
OpenRouter provides access to models from:
- OpenAI: GPT-4, GPT-3.5 Turbo, GPT-4o, etc.
- Anthropic: Claude-3, Claude-2, etc.
- Google: Gemini models
- Meta: Llama models
- And many more providers
You can specify any supported model in your application configuration using the model identifier (e.g., openai/gpt-4o-mini, anthropic/claude-3-haiku).
If you prefer containers, the project ships with a helper script that builds a reusable base image and launches the full stack (backend, frontend, PostgreSQL with pgvector, and Redis).
# Build or refresh the dependency base image and start all services
./startupdocker.sh --build
# Follow logs during startup (optional)
./startupdocker.sh --build --logs
# Stop the containers when you're done
./startupdocker.sh --downThe Docker stack publishes the following ports on the host:
- Backend API:
http://localhost:18000 - Frontend UI:
http://localhost:15173 - PostgreSQL:
localhost:15432(user/passwordragify/RagifyStrongPass2023) - Redis:
localhost:16379
The first --build run creates the ragify-backend-base image that caches all heavy Python dependencies such as PyTorch and transformers. Subsequent builds reuse that base layer, so only application code changes trigger rebuilds. Environment variables are loaded from the project’s .env file inside the containers.
# Start backend server
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000
# In another terminal, start frontend
cd frontend && npm run dev# Using uvicorn with workers
uvicorn backend.main:app --host 0.0.0.0 --port 8000 --workers 4
# Or using gunicorn
gunicorn backend.main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000curl http://localhost:8000/healthExpected response:
{
"status": "ok",
"timestamp": 1234567890.123,
"database": {...},
"cache": {...},
"task_queue": {...}
}Visit: http://localhost:8000/docs
Visit: http://localhost:5173 (local dev) or http://localhost:15173 when using the Docker stack.
Error: psycopg2.OperationalError: could not connect to server
Solutions:
- Ensure PostgreSQL is running:
sudo systemctl status postgresql - Check database credentials in
.env - Verify database exists:
psql -l - Check PostgreSQL logs:
sudo tail -f /var/log/postgresql/postgresql-*.log
Error: ModuleNotFoundError: No module named 'sentence_transformers'
Solutions:
- Install dependencies:
pip install -e . - Activate virtual environment:
source venv/bin/activate - Check Python path:
python -c "import sys; print(sys.path)"
Error: [Errno 48] Address already in use
Solutions:
- Kill process using port:
lsof -ti:8000 | xargs kill -9 - Change port in command:
--port 8001 - Check what's using the port:
lsof -i :8000
Error: ConnectionError: Couldn't reach server
Solutions:
- Check internet connection
- Use different model: Set
EMBEDDING_MODELto a local model - Download manually and place in cache directory
Error: redis.ConnectionError: Error 61 connecting to localhost:6379
Solutions:
- Start Redis:
sudo systemctl start redis-server - Check Redis status:
redis-cli ping - Disable Redis in
.env: Comment outREDIS_URL - Install Redis if not present
- Reduce batch size in embedding configuration
- Use smaller embedding models
- Implement document chunking for large files
- Enable Redis caching
- Optimize database queries
- Use connection pooling
- Implement rate limiting
LOG_LEVEL=DEBUG
DEBUG=true# Backend logs (when running with uvicorn)
uvicorn backend.main:app --log-level debug
# Frontend logs
streamlit run app.py --logger.level=debug# In backend/core/database.py
import logging
logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)# In backend/modules/rag/embedding.py
from sentence_transformers import SentenceTransformer
# Load custom model
model = SentenceTransformer('path/to/your/model')# In backend/core/database.py
from sqlalchemy.pool import QueuePool
engine = create_async_engine(
DATABASE_URL,
poolclass=QueuePool,
pool_size=10,
max_overflow=20
)# Generate SSL certificates
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
# Run with SSL
uvicorn backend.main:app --ssl-keyfile key.pem --ssl-certfile cert.pemAfter successful setup:
- Create your first knowledge base in the web interface
- Upload documents (PDF, DOCX, TXT)
- Build an application and associate knowledge bases
- Test the chat functionality
- Review the API documentation for integration options
For production deployment, see the deployment guide.