Complete guide to setting up Supabase for DigiLogBook
Prerequisites • Create Project • Deploy Edge Functions • Configure Secrets • Connect App
Before you begin:
- ✅ A Supabase account (free tier works perfectly)
- ✅ DigiLogBook application installed
- ✅ Internet connection
- ✅ 10-15 minutes to complete setup
- Go to supabase.com
- Click "Start your project"
- Sign in with GitHub, Google, or email
-
Click "New Project" in your dashboard
-
Fill in project details:
- Name:
DigiLogBook(or your preferred name) - Database Password: Create a strong password (save this!)
- Region: Choose closest to your location
- Pricing Plan: Free tier is sufficient
- Name:
-
Click "Create new project"
-
Wait 2-3 minutes for project initialization
💡 Note: You don't need to remember the database password for DigiLogBook - it only uses Edge Functions, not direct database connections!
Once created, you'll need these from your Supabase dashboard:
-
Project URL:
- Go to Settings → API
- Copy Project URL (e.g.,
https://xxxxx.supabase.co)
-
Anon/Public Key:
- Same page (Settings → API)
- Copy anon
publickey
📝 Important: Keep these handy - you'll need them to configure DigiLogBook!
DigiLogBook uses Supabase Edge Functions instead of direct database connections for better security and serverless architecture.
-
Open SQL Editor
- In Supabase dashboard, click "SQL Editor" (left sidebar)
- Click "+ New query"
-
Run Permission Script
- Navigate to your DigiLogBook repository
- Open
Edge Functions/database-schema.sql - Copy the entire SQL script
- Paste it into the SQL Editor
- Click "Run" (or press
Ctrl+Enter)
-
What This Does
- Grants Edge Functions permission to create and manage tables
- Sets up Row Level Security (RLS) policies
- Does NOT create tables - those are auto-created by the app!
✅ Success Indicator: You should see "Success. No rows returned"
Script Location: Edge Functions/database-schema.sql
Supabase Edge Functions are managed via the Supabase CLI. While you can see the functions in the Supabase Dashboard UI, you must deploy the code from your terminal.
# Install Supabase CLI
npm install -g supabase
# Login
supabase login
# Link to your project
supabase link --project-ref [your-project-ref]
# Deploy the server-api function
supabase functions deploy server-api --no-verify-jwt
# Deploy the client-api function
supabase functions deploy client-api --no-verify-jwt
⚠️ Important: We use the --no-verify-jwt flag because DigiLogBook handles authentication via a custom X-SERVER-HEADER secret. If you forget this flag, the Java app will receive a 401 Unauthorized error.
💡 Note: The Edge Functions are already deployed in the repository. This step is optional unless you're modifying them.
Edge Functions need 3 secret keys to work. These are NOT the default Supabase secrets!
- In Supabase dashboard, click "Edge Functions" (left sidebar)
- Click on "server-api" function (if visible)
- Go to "Secrets" tab
Or alternatively:
- Go to Settings → Edge Functions → Secrets
You need to add these exact secret names:
| Secret Name | Description | Example Value |
|---|---|---|
RECORDS_TABLE_NAME |
Name for the sessions table | sessions or student_records |
CONFIG_TABLE_NAME |
Name for the configuration table | configuration_options or config_data |
ADMIN_KEY |
Secret key for server authentication | your_secure_random_key_here |
Secret 1: RECORDS_TABLE_NAME
- Click "Add secret" or "New secret"
- Enter:
(You can choose any name, but
Name: RECORDS_TABLE_NAME Value: sessionssessionsis recommended)
Secret 2: CONFIG_TABLE_NAME
- Click "Add secret" again
- Enter:
(You can choose any name, but
Name: CONFIG_TABLE_NAME Value: configuration_optionsconfiguration_optionsis recommended)
Secret 3: ADMIN_KEY
- Click "Add secret" again
- Enter:
Name: ADMIN_KEY Value: [CREATE A STRONG RANDOM KEY]
🔒 CRITICAL: The
ADMIN_KEYis used to authenticate requests from DigiLogBook to your Edge Functions.
- Generate a strong random key (20+ characters)
- SAVE THIS KEY SECURELY - you'll need it when configuring DigiLogBook
- Never share this key publicly!
Example secure ADMIN_KEY: 7kX9mPq2RtY5wNzLbVcFgH8jU3sD6aE4
Click "Add secret" in Edge Functions settings
All 3 secrets successfully configured
Now that Supabase is configured, connect your DigiLogBook application!
- Open DigiLogBook application
- Click the ⚙️ Settings icon (top-right corner)
- Go to "Cloud Database" tab
- Click "Add Cloud Database Info" button
You need to enter 3 pieces of information:
| Field | Where to Find It | Example |
|---|---|---|
| Project URL | Supabase → Settings → API → Project URL | https://xxxxx.supabase.co |
| Publishable/Anon Key | Supabase → Settings → API → anon public |
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... |
| Admin Key | The ADMIN_KEY you created in Step 3.3 |
7kX9mPq2RtY5wNzLbVcFgH8jU3sD6aE4 |
Fill in the form:
Project URL: https://xxxxx.supabase.co
Publishable/Anon Key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Admin Key: 7kX9mPq2RtY5wNzLbVcFgH8jU3sD6aE4
- Click "Verify and Save" button
- Wait for verification process:
- "Verifying & Setting up Cloud..." (orange status)
- Application tests connection to Edge Functions
- Automatically creates database tables (sessions and configuration)
- "Verified" (green status) ✅
✨ Magic Happens: When you verify, DigiLogBook automatically calls the Edge Functions to create the necessary tables in your Supabase database - no manual table creation needed!
You should see:
- ✅ "Verified" label in green
- Tables
sessionsandconfiguration_optionsauto-created in your Supabase database
Visual Guide:
Enter your Supabase credentials
Successfully connected and verified!
Before using DigiLogBook with cloud sync:
- Supabase project created
- Project URL and Anon Key noted
- SQL permission script executed in SQL Editor
- 3 Edge Function secrets added (
RECORDS_TABLE_NAME,CONFIG_TABLE_NAME,ADMIN_KEY) - Admin Key saved securely
- DigiLogBook configured with Project URL, Anon Key, and Admin Key
- DigiLogBook shows green "Verified" status
- Tables auto-created successfully
Possible Causes:
- Incorrect Project URL format
- Wrong Anon Key
- Wrong Admin Key (doesn't match what you set in Supabase secrets)
- Edge Functions not deployed
- Secrets not configured correctly
Solutions:
-
Double-check Project URL:
- Should be:
https://xxxxx.supabase.co - Should NOT include
/functions/v1/or any path
- Should be:
-
Verify Anon Key:
- Copy fresh from Supabase → Settings → API
- Should be a long JWT token starting with
eyJ
-
Confirm Admin Key matches:
- Must be EXACT same value as the
ADMIN_KEYsecret in Supabase - Case-sensitive!
- Must be EXACT same value as the
-
Check Edge Function Secrets:
- Go to Supabase → Edge Functions → Secrets
- Verify all 3 secrets exist:
RECORDS_TABLE_NAME,CONFIG_TABLE_NAME,ADMIN_KEY
Solution:
- Check internet connection
- Verify Supabase project is active (not paused)
- Check firewall/antivirus isn't blocking requests
Solution:
- Check if
database-schema.sqlwas run in SQL Editor - Verify Edge Functions have database permissions
- Try re-verifying in DigiLogBook (it will retry table creation)
Solution:
- 401: Invalid Anon Key - copy fresh from Supabase
- 403: Invalid Admin Key - must match the secret in Supabase exactly
- ✅ Never share your Admin Key publicly
- ✅ Never commit Admin Key to version control
- ✅ Use strong, random Admin Keys (20+ characters)
- ✅ Rotate Admin Key periodically (update in both Supabase and DigiLogBook)
The Admin Key is critical - it authenticates DigiLogBook's requests to your Edge Functions:
- Project URL & Anon Key: Public (included in frontend apps)
- Admin Key: MUST BE KEPT SECRET (only known to your DigiLogBook app)
If Admin Key is compromised:
- Generate new random key
- Update in Supabase Edge Function secrets
- Update in DigiLogBook settings
- Click "Verify and Save"
After successful verification, check your Supabase database:
- Go to Table Editor in Supabase dashboard
- You should see two tables:
sessions(or your chosen name fromRECORDS_TABLE_NAME)configuration_options(or your chosen name fromCONFIG_TABLE_NAME)
Expected Structure:
Table: sessions
session_id(text, primary key)login_time(text)logout_time(text)usn(text)name(text)details(jsonb) - stores dynamic fields
Table: configuration_options
id(integer, primary key, auto-increment)category(text) - e.g., "Subject", "Department"item_value(text) - e.g., "Data Structures", "CSE"
Once cloud setup is complete:
- ✅ Return to README.md
- ✅ Test cloud synchronization with "⟳ Refresh" button
- ✅ Import your first CSV file
- ✅ Configure auto-save/delete settings
- ✅ Manage configuration categories
- ✅ Export your first report
🎉 Supabase setup complete! DigiLogBook is now cloud-enabled! 🎉
