Documentation Index
Fetch the complete documentation index at: https://mintlify.com/EdgarJr30/proyecto-de-grado-cms/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Supabase provides the backend infrastructure for MLM CMMS, including authentication, database, storage, and Edge Functions. This guide covers the complete configuration process after database setup.Complete the Database Setup before proceeding with this configuration.
Edge Function Deployment
Push Notification Worker
Thesend-push-from-outbox Edge Function processes the notification outbox and sends Web Push notifications.
Prerequisites
Configure Function Secrets
Set the required secrets for the Edge Function:Deploy the Function
Notification Dispatch Configuration
The notification system uses two dispatch mechanisms for reliability:Option A: Immediate Dispatch via pg_net (Recommended)
Configure database settings to trigger the Edge Function immediately when notifications are queued:If you receive “permission denied to set parameter”, use Option B (Database Webhook) instead.
Option B: Immediate Dispatch via Database Webhook (Fallback)
IfALTER DATABASE is not permitted, configure a Database Webhook:
Create New Webhook
Click Create a new webhook with these settings:
- Name: Push Notification Dispatch
- Table:
public.notification_outbox - Events:
INSERT - HTTP Method:
POST - URL:
https://<project-ref>.functions.supabase.co/send-push-from-outbox?limit=1
Cron Job for Backup Processing (Always Recommended)
Set up a cron job to process any stuck or failed notifications:- Supabase Cron (pg_cron)
- External Cron (Linux)
- GitHub Actions
Execute in Supabase SQL Editor:
Storage Configuration
Configure Supabase Storage for file uploads:Create Storage Buckets
The database setup script (14_storage.sql) should have created these buckets automatically:
ticket-attachments: Photos and files attached to ticketsuser-avatars: User profile picturesasset-photos: Fixed asset images
Storage Policies
The SQL script automatically configures RLS policies for Storage:Realtime Configuration
Enable Realtime for Critical Tables
Enable Tables
Ensure these tables are enabled in the
supabase_realtime publication:- ✅
public.notification_deliveries - ✅
public.ticket_comments - ✅
public.tickets(optional, for live kanban updates) - ✅
public.work_orders(optional, for work order tracking)
The database setup script (
13_realtime.sql) should have configured replica identity automatically. This verification ensures it was applied correctly.Realtime Security
Realtime subscriptions respect RLS policies. Users can only receive updates for rows they have permission to view. Example frontend subscription:Authentication Configuration
Email Authentication
Configure Email Templates
Go to Authentication > Email Templates.Customize:
- Confirmation email
- Password reset email
- Magic link email
Set Site URL
In Authentication > URL Configuration, set:
- Site URL:
https://your-domain.com - Redirect URLs: Add all valid redirect URLs for OAuth flows
Session Configuration
Recommended settings in Authentication > Settings:- JWT expiry: 3600 seconds (1 hour)
- Refresh token rotation: Enabled
- Reuse interval: 10 seconds
- Session timeout: 604800 seconds (7 days)
API Configuration
Rate Limiting
Configure rate limits in Project Settings > API:- Anonymous requests: 100 per hour (restrictive)
- Authenticated requests: 1000 per hour (generous for active users)
CORS Configuration
Add your production domain to allowed origins:Testing the Configuration
Smoke Test Script
Run the notifications smoke test to verify the entire pipeline:- ✅ Notification creation
- ✅ Delivery to user
- ✅ Outbox processing
- ✅ Push notification dispatch
- ✅ Comment system integration
Manual UI Testing
Test In-App Notifications
- Navigate to
/notificaciones - Verify bell icon shows unread count
- Click notification to mark as read
- Swipe notification to toggle read/unread status
Test Admin Notifications
- Login as user with
users:full_accessorrbac:manage_permissionspermission - Use “Prueba Admin” button to send test notification
- Verify notification appears in bell dropdown
Test Comment Notifications
- Open a ticket detail page
- Add a comment
- Verify comment appears in UI
- Check that notification is created for ticket owner
- Click notification to navigate to ticket
Verify Outbox Processing
Check notification outbox status:- Most messages in
sentstatus - Few in
pending(only recent ones) - None stuck in
processingfor more than 5 minutes
Platform-Specific Push Notification Notes
Android
- ✅ Chrome browser with granted notification permission
- ✅ Works in regular browser tabs
- ✅ Works in PWA installed mode
iOS
- ⚠️ Requires app to be installed to home screen (PWA)
- ⚠️ Only works in Safari (not Chrome or Firefox)
- ⚠️ User must grant notification permission in iOS settings
- ✅ iOS 16.4+ supports Web Push in PWAs
Desktop
- ✅ Works in Chrome, Edge, Firefox
- ✅ Requires system notification permission
- ✅ Works in both browser tabs and PWAs
Monitoring and Maintenance
Database Queries for Health Checks
Set Up Monitoring Alerts
Recommended alerts:- ⚠️ Outbox processing rate drops below threshold
- ⚠️ Failed notifications exceed 5% of total
- ⚠️ Messages stuck in
processingfor >10 minutes - ⚠️ Edge Function errors increase
- ⚠️ Database connection pool exhaustion
Troubleshooting
Edge Function Deployment Fails
Notifications Not Sending
- Check outbox for stuck messages
- Verify Edge Function secrets are correct
- Check Edge Function logs for errors
- Verify cron job or webhook is triggering
- Test manual trigger:
Realtime Not Working
- Verify tables are in
supabase_realtimepublication - Check replica identity is set to
FULL - Verify RLS policies allow user to SELECT rows
- Check browser console for WebSocket errors
- Verify Realtime is enabled in project settings
Storage Upload Fails
- Verify bucket exists and is correctly named
- Check RLS policies on
storage.objects - Verify file size is within limits (default 50MB)
- Check CORS configuration for your domain
Next Steps
Environment Setup
Review environment variable configuration for all environments
Production Build
Build and deploy the frontend application