Overview
Quail BI requires two database services:MongoDB
Stores user data, connections, dashboards, and chat history
Supabase
Handles user authentication and session management
MongoDB Setup
Option 1: MongoDB Atlas (Recommended)
Create Account
Sign up for a free account at mongodb.com/cloud/atlas
Create Cluster
- Click Create to create a new cluster
- Choose the Free Shared tier (M0)
- Select a cloud provider and region close to your users
- Name your cluster (e.g.,
quail-production) - Click Create Cluster
Configure Network Access
- Navigate to Network Access in the sidebar
- Click Add IP Address
- Choose Allow Access from Anywhere (
0.0.0.0/0) for development - For production, whitelist specific IPs
Create Database User
- Navigate to Database Access
- Click Add New Database User
- Choose Password authentication
- Create a username and secure password
- Set Database User Privileges to Read and write to any database
- Click Add User
Get Connection String
- Go to Database and click Connect on your cluster
- Choose Connect your application
- Copy the connection string:
- Replace
<username>,<password>, and<database>with your values
Option 2: Local MongoDB
For development, you can run MongoDB locally:- macOS
- Linux
- Windows
- Docker
MongoDB Database Schema
Quail automatically creates these collections:users
users
Stores user account information (synced with Supabase).Indexes:
{ supabaseId: 1 } (unique), { email: 1 }connections
connections
Stores encrypted database connection strings.Indexes:
{ userId: 1 }, { userId: 1, name: 1 }dashboards
dashboards
Stores dashboard configurations.Indexes:
{ userId: 1 }, { userId: 1, createdAt: -1 }charts
charts
Stores chart configurations.Indexes:
{ userId: 1 }, { dashboardId: 1 }chats
chats
Stores chat conversation history.Indexes:
{ userId: 1 }, { userId: 1, createdAt: -1 }Creating Indexes
For optimal performance, create indexes manually:Supabase Setup
Create Supabase Project
Sign Up
Create an account at supabase.com
Create Project
- Click New Project
- Enter a project name (e.g.,
quail-production) - Set a secure database password (save this!)
- Choose a region close to your users
- Click Create new project
Get API Keys
- Go to Settings → API in the sidebar
- Copy three values:
- Project URL (e.g.,
https://abc123.supabase.co) - anon public key (under “Project API keys”)
- service_role secret key (click “Reveal” to see it)
- Project URL (e.g.,
Configure Authentication
Enable Email Authentication
- Go to Authentication → Providers
- Ensure Email is enabled
- Configure email templates (optional)
Configure Email Templates (Optional)
- Go to Authentication → Email Templates
- Customize the confirmation and password reset emails
- Add your branding and domain
Configure Row Level Security (Optional)
For additional security, enable Row Level Security (RLS) on Supabase tables:Quail stores most data in MongoDB, so RLS is optional. However, if you add tables to Supabase, enable RLS.
Testing Authentication
Verify authentication is working:Production Considerations
MongoDB
Backups
Enable automated backups in MongoDB Atlas or set up regular
mongodump backupsMonitoring
Use MongoDB Atlas monitoring or tools like Datadog, New Relic
Scaling
Upgrade to a larger cluster tier as usage grows
Security
Use IP whitelisting and strong passwords
Supabase
Custom Domain
Configure a custom domain for authentication emails
Rate Limiting
Monitor API usage and configure rate limits
Upgrade Plan
Free tier has limits; upgrade for production
Email Provider
Configure a custom SMTP provider for better deliverability
Troubleshooting
MongoDB connection fails
MongoDB connection fails
Check these common issues:
- Connection string format: Ensure no extra spaces or line breaks
- Network access: Verify IP is whitelisted in MongoDB Atlas
- Credentials: Check username and password are correct
- Database name: Ensure the database name exists
Supabase authentication doesn't work
Supabase authentication doesn't work
Common issues:
- Wrong keys: Verify you’re using the correct anon and service_role keys
- URL mismatch: Check the project URL matches your Supabase project
- Email not confirmed: Check inbox for confirmation email
- Redirect URL: Add your site URL to allowed redirect URLs
- Go to Authentication → Users
- Try creating a test user
'NEXT_PUBLIC_SUPABASE_URL is not defined' error
'NEXT_PUBLIC_SUPABASE_URL is not defined' error
Environment variables are not loaded:
- Verify
.env.localexists in project root - Restart the dev server after adding variables
- Check variable names match exactly (case-sensitive)
Next Steps
Environment Variables
Configure all environment variables
Configuration
Advanced configuration options
Security
Secure your databases
Troubleshooting
Fix common database issues
