This guide walks you through connecting your Agriculture Drone GCS to Supabase (managed PostgreSQL).
- Go to https://app.supabase.com
- Sign up or log in
- Click "New Project"
- Choose organization, enter project name
- Set a strong database password (save this!)
- Choose region closest to your users
- Wait for project to initialize (~2 minutes)
- In your Supabase project dashboard, go to Settings → Database
- Find the "Connection info" section
- Copy the Connection string (URI format)
- It looks like:
postgresql://postgres:PASSWORD@db.xxx.supabase.co:5432/postgres
-
Copy the environment template:
cd backend copy .env.example .env
-
Edit
backend/.envand update:DATABASE_URL=postgresql://postgres:YOUR_PASSWORD@db.YOUR_PROJECT_ID.supabase.co:5432/postgres?sslmode=require SECRET_KEY=generate-a-long-random-secret-key-hereImportant:
- Replace
YOUR_PASSWORDwith your Supabase database password - Replace
YOUR_PROJECT_IDwith your actual project ID from the connection string - Generate a strong SECRET_KEY (use a password generator for 32+ characters)
- Replace
cd backend
venv\Scripts\activate
pip install -r requirements.txtThe requirements.txt now includes psycopg2-binary for PostgreSQL support.
cd backend
venv\Scripts\activate
python -c "from database import create_tables; create_tables(); print('✅ Tables created successfully')"You can verify tables were created by:
- Going to your Supabase project
- Click "Table Editor" in the sidebar
- You should see tables: users, fields, missions, waypoints, etc.
If you have existing users/data in your local SQLite database:
cd backend
venv\Scripts\activate
python migrate_to_supabase.pyThis will copy all your existing users, fields, missions, and telemetry data to Supabase.
-
Start your backend:
cd backend venv\Scripts\activate python main.py
-
You should see: "Connected to database successfully" (or similar)
-
Test registration/login:
- Start frontend:
cd frontend && npm start - Try creating a new account
- Check Supabase Table Editor → users table to verify the account was created
- Start frontend:
If deploying to production, update ALLOWED_ORIGINS in your .env:
ALLOWED_ORIGINS=http://localhost:3000,https://your-frontend-domain.com
- Verify your DATABASE_URL is correct
- Ensure
?sslmode=requireis at the end of the connection string - Check that your Supabase project is active (not paused)
Add ?sslmode=require to your DATABASE_URL if not already present.
- Check the console output for error messages
- Verify your connection string has the correct password
- Ensure your Supabase project is fully initialized
- Ensure your local SQLite file exists (
agriculture_gcs.db) - Check that DATABASE_URL points to Supabase (not SQLite)
- Run migration script with error output:
python migrate_to_supabase.py
- Never commit
.envfiles - they contain sensitive credentials - Use strong passwords for both Supabase and JWT secret keys
- Supabase provides built-in security (SSL, connection limits)
- Consider enabling Row Level Security (RLS) in Supabase for additional protection
Once connected to Supabase:
- Your app data is now shared across all devices
- Users can log in from anywhere
- Data persists even if your local machine is offline
- You can deploy your backend to any hosting service
- Consider using Supabase's built-in Auth system for additional features
For deployment, set the same environment variables on your hosting platform (Heroku, Render, Railway, etc.)