Overview
Filebright uses a dual-database architecture:- PostgreSQL: Stores application data (users, document metadata, sessions, jobs)
- MongoDB: Stores document chunks with vector embeddings for semantic search
PostgreSQL
PostgreSQL serves as the primary relational database for structured application data.What’s stored in PostgreSQL
- User accounts and authentication data
- Document metadata (filename, size, status, upload date)
- Session data
- Queue jobs for background processing
- Cache entries
Connection configuration
Configure PostgreSQL using these environment variables:Docker setup
The includeddocker-compose.yml automatically sets up PostgreSQL:
docker-compose.yml
Manual PostgreSQL installation
If you’re not using Docker, install PostgreSQL manually:Create database and user
Create a dedicated database and user for Filebright:Run migrations
Once PostgreSQL is configured, run the migrations to create the database schema:users- User accountsdocument_metadata- Document information and statussessions- User sessionsjobs- Background job queuecache- Application cache
The
document_metadata table includes a vector_id field that references document chunks stored in MongoDB.MongoDB
MongoDB stores document chunks and their vector embeddings for efficient semantic search.What’s stored in MongoDB
- Document text chunks (split from uploaded documents)
- Vector embeddings for each chunk (generated by OpenRouter)
- Metadata for filtering (user ID, document ID, chunk index)
Connection configuration
Configure MongoDB using these environment variables:Manual MongoDB installation
MongoDB Atlas (recommended for production)
For production deployments, we recommend using MongoDB Atlas:- Create a free account at mongodb.com/cloud/atlas
- Create a new cluster
- Create a database user
- Whitelist your application’s IP address
- Get your connection string and add it to
.env
Vector search index
For semantic search to work, you must create a vector search index in MongoDB.Using MongoDB Atlas UI
- Navigate to your cluster in MongoDB Atlas
- Click Search in the left sidebar
- Click Create Search Index
- Select JSON Editor
- Use the following configuration:
- Name the index
vector_index - Select the
document_chunkscollection - Click Create Search Index
The
dimensions value (1536) matches the text-embedding-3-small model. If you use a different embedding model, adjust this value accordingly.Using MongoDB Shell
Connect to your MongoDB instance and run:Document chunk schema
Each document stored in MongoDB follows this structure:PHP MongoDB extension
Filebright requires the MongoDB PHP extension. It’s automatically installed in the Docker container, but for local development: Verify installation:Connection testing
Test your database connections:PostgreSQL
MongoDB
Troubleshooting
PostgreSQL connection refused
PostgreSQL connection refused
- Check if PostgreSQL is running:
sudo systemctl status postgresql - Verify host and port in
.env - Check firewall rules
- For Docker: ensure
dbservice is healthy
MongoDB authentication failed
MongoDB authentication failed
- Verify connection string format
- Check username and password
- Ensure database user has proper permissions
- For Atlas: verify IP whitelist
Vector search not working
Vector search not working
- Verify
vector_indexexists in MongoDB - Check index name matches code (
vector_index) - Ensure embedding dimensions match (1536 for text-embedding-3-small)
- Wait a few minutes for index to become active after creation
MongoDB extension not found
MongoDB extension not found
- Install the MongoDB PHP extension:
pecl install mongodb - Enable the extension in
php.ini - Restart PHP-FPM or web server
- Verify:
php -m | grep mongodb
Next steps
AI integration
Configure OpenRouter for embeddings and chat
Docker deployment
Deploy Filebright with Docker