This guide explains how to set up Supabase database storage for ThreadCraft progress tracking.
ThreadCraft now stores your API credentials and thread progress in a Supabase database with encryption. This means:
- Credentials persist until you disconnect - enter them once, use forever
- No more daily copy-paste - your API keys are saved securely
- Thread URLs encrypted - stored safely with your progress
- All data encrypted - credentials and thread data protected with Fernet encryption
- A Supabase account (free tier works)
- Access to your Supabase project's SQL editor
- Go to your Supabase project dashboard
- Navigate to SQL Editor
- Copy the contents of
supabase_migration.sql - Paste and run the SQL migration
This creates a table called threadcraft_users with:
- Encrypted credentials storage - All API keys encrypted with Fernet
- Encrypted thread ID storage - Thread URLs encrypted separately
- User identifier hashing - SHA-256 hash (session ID + salt)
- Automatic timestamp tracking - Created/updated timestamps
- In Supabase dashboard, go to Settings → API
- Copy your Project URL (e.g.,
https://xxxxx.supabase.co) - Copy your anon/public key (under "Project API keys")
Add these environment variables to your backend deployment:
SUPABASE_URL=https://xxxxx.supabase.co
SUPABASE_KEY=your-anon-key-here
DATABASE_SALT=your-random-salt-string-hereImportant:
- Change
DATABASE_SALTto a random, secret string (at least 32 characters) - Never commit the salt to version control
- Use different salts for different environments (dev/prod)
Example salt generation:
# Linux/Mac
openssl rand -hex 32
# Python
python -c "import secrets; print(secrets.token_hex(32))"The Supabase client is already added to requirements.txt. If deploying:
pip install -r requirements.txt-
User Identifier Hashing:
- Your session ID is combined with a salt
- SHA-256 hash is generated (64-character hex string)
- This hash is stored as
user_identifier_hash
-
Credentials Encryption:
- All API credentials (keys, tokens) are encrypted using Fernet (symmetric encryption)
- Encryption key is derived from your session ID
- Encrypted data is base64-encoded before storage
- Credentials persist until you click "Disconnect"
-
Thread ID Encryption:
- Thread URL/ID is encrypted using Fernet (symmetric encryption)
- Same encryption key derived from session ID
- Encrypted data is base64-encoded before storage
-
Decryption:
- When loading, your session ID is used to derive the same encryption key
- Both credentials and thread ID are decrypted on-the-fly
- Original data is never stored in plain text
Important: If Supabase is not configured or unavailable:
- Credentials cannot be stored - Users must enter API keys every time
- Thread progress falls back to JSON file storage (
progress.json) - Supabase is required for persistent credential storage
✅ Credentials Encryption: All API keys encrypted with Fernet (AES-128) ✅ Thread Encryption: Thread IDs encrypted separately ✅ Hashing: User identifiers hashed with SHA-256 + salt ✅ No Plain Text: Sensitive data never stored in readable format ✅ Session-Based Keys: Each user has unique encryption keys derived from session ID ✅ Permanent Until Disconnect: Credentials persist until explicit disconnect
- Verify
SUPABASE_URLandSUPABASE_KEYare correct - Check Supabase project is active
- Ensure table
threadcraft_progressexists (run migration again if needed) - Check backend logs for specific error messages
- Ensure you have proper permissions in Supabase
- Check that the table doesn't already exist (or drop it first)
- Verify PostgreSQL version compatibility
- Check backend logs for database errors
- Verify environment variables are set correctly
- Try resetting progress (it will fall back to file if DB fails)
If you're currently using the old session-based approach:
- Set up Supabase as described above
- Enter your API credentials once in the Settings page
- Your credentials will be saved permanently (encrypted in database)
- Use "Continue Existing Thread" to re-link your thread if needed
- Your progress and credentials now persist across sessions
No more daily credential entry! Once connected, your credentials stay saved until you click "Disconnect".
If you encounter issues:
- Check backend logs for error messages
- Verify Supabase dashboard shows the table
- Test database connection from Supabase SQL editor
- Ensure all environment variables are correctly set