Create a Supabase Project
- Go to supabase.com and sign in
- Click New Project
- Enter your project details:
- Name: Hive (or your preferred name)
- Database Password: Generate a secure password
- Region: Choose the closest region to your users
- Click Create new project
Save your database password - you’ll need it for direct database access if required.
Database Schema
usuarios Table
Theusuarios table stores user profiles and links to Supabase Auth users. Create it with the following schema:
Primary key for the user record
Foreign key linking to Supabase Auth
auth.users.id. This allows querying user profiles by authentication session.Username for login. Must be unique across all users.
Full name of the user (e.g., “Juan Pérez”)
National ID or employee ID number. Must be unique if provided.
Job title or position (e.g., “Desarrollador Senior”, “Gerente de Proyectos”)
User role for access control. Valid values:
administradororadmin- Full system accessusuario- Standard user access
/api/auth-sync function checks this field to authorize admin operations.Email address. Must match the email in Supabase Auth for authentication.
Profile picture URL. Can reference Supabase Storage or external URLs.
Real-time presence status updated by
/api/presence-ping. Values: online, offlineLast access timestamp, updated on login and presence pings
Row Level Security (RLS)
Enable RLS on theusuarios table to protect user data:
Policy Breakdown
Users can view all profiles
Users can view all profiles
Allows any authenticated user to read all user profiles. This is necessary for:
- Displaying team member lists
- Showing task assignees
- User search and selection in the UI
Users can update own profile
Users can update own profile
Users can only modify their own profile record (matched by
auth_user_id). This prevents users from:- Changing other users’ roles
- Modifying other users’ email addresses
- Impersonating other users
Service role full access
Service role full access
The service role key bypasses RLS by default, but this policy makes it explicit. Serverless functions use the service role to:
- Create new users during signup
- Sync Auth changes to the
usuariostable - Update presence status for all users
Authentication Setup
Enable Email Authentication
- Go to Authentication → Providers in your Supabase dashboard
- Enable Email provider
- Configure settings:
- Enable email confirmations: Optional (recommended for production)
- Enable email change confirmations: Recommended
- Secure email change: Recommended
Email Templates
Customize email templates under Authentication → Email Templates:- Confirm signup: Sent when new users register
- Magic Link: For passwordless login (if enabled)
- Change Email Address: Confirmation for email changes
- Reset Password: Password recovery emails
Customize the email templates with your brand colors and logo for a professional user experience.
Storage Setup
Profile Pictures Bucket
Create a storage bucket for user profile images:- Go to Storage in your Supabase dashboard
- Click Create bucket
- Configure:
- Name:
profile-pics - Public: ✅ Enabled (for public profile image access)
- File size limit: 2 MB (recommended)
- Allowed MIME types:
image/jpeg,image/png,image/webp,image/gif
- Name:
Storage Policies
The application uses
uploadProfileImage.js to handle file uploads to the profile-pics bucket. After upload, it updates usuarios.foto_url with the file path.Additional Tables
Hive also requires these tables for full functionality:proyectos
tareas
tarea_usuarios (Task Assignments)
etiquetas (Tags)
tarea_etiquetas (Task Tags Junction)
usuarios_borrados (Deleted Users Archive)
Realtime Subscriptions
Enable realtime for live updates:app.realtime.js to subscribe to table changes and update the UI automatically.
Testing the Connection
After setup, test your Supabase connection:Troubleshooting
Error: relation 'usuarios' does not exist
Error: relation 'usuarios' does not exist
The
usuarios table hasn’t been created yet.Solution: Run the SQL schema creation commands in the Supabase SQL Editor.Error: new row violates row-level security policy
Error: new row violates row-level security policy
RLS is enabled but no policy allows the operation.Solution:
- Check that RLS policies are created
- Verify the user is authenticated (for policies requiring
auth.uid()) - Use the service role key for admin operations
Profile picture uploads fail
Profile picture uploads fail
Storage bucket or policies not configured.Solution:
- Verify
profile-picsbucket exists and is public - Check storage policies allow authenticated uploads
- Ensure file size is under the bucket limit
Email confirmations not working
Email confirmations not working
SMTP not configured or confirmation emails disabled.Solution:
- For development, disable email confirmations in Auth settings
- For production, configure custom SMTP in Auth → Settings
Next Steps
Environment Variables
Configure environment variables for your deployment
Deployment
Deploy Hive to Vercel or other platforms
