Overview
Portal Ciudadano Manta uses Supabase as its Backend as a Service (BaaS), providing PostgreSQL database, authentication, file storage, and real-time capabilities.Create Supabase Project
Create Account
Go to https://supabase.com and create a free account.
Create New Project
Click “New Project” and fill in:
- Project Name: Portal Ciudadano Manta
- Database Password: Strong password (save this securely)
- Region: Choose closest to Ecuador (e.g.,
us-east-1) - Pricing Plan: Free tier is sufficient for development
Get API Credentials
Database Schema Setup
Option 1: SQL Editor (Recommended)
Execute Schema
Copy the contents of
supabase-schema.sql from your project and execute it.This creates all tables:usuarios- User profilesadministradores- Admin accountsnoticias- News articlesencuestas- Surveysrespuestas_encuestas- Survey responsesreportes- Citizen reports
Database Tables
The schema includes:| Table | Purpose |
|---|---|
usuarios | Citizen user profiles with parroquia/barrio |
administradores | Municipal administrator accounts |
noticias | News articles with geotargeting |
encuestas | Surveys with multiple types |
respuestas_encuestas | Survey responses from citizens |
reportes | Urban problem reports with geolocation |
Configure Authentication
Enable Email Auth
Go to Authentication → Providers → Email
- Enable “Email” provider
- Configure email templates (optional)
Configure Storage
Create Storage Bucket
Go to Storage → Create Bucket
- Name:
imagenes - Public: OFF (controlled by policies)
- File size limit: 5MB (5242880 bytes)
- Allowed MIME types:
image/jpeg,image/jpg,image/png,image/webp
Apply Storage Policies
Execute the SQL from
sql/storage_policies.sql to enable:- Public read access for all images
- Admin upload/delete for news images
- User upload/delete for report images
Apply Row Level Security
Apply Policies
Execute the SQL files:
sql/noticias_rls.sql- News policiessql/reportes_rls.sql- Reports policies
Test Connection
Verify your setup works:Supabase Client Configuration
The application configures Supabase with:src/lib/supabase.ts:16
Next Steps
Environment Variables
Configure all required variables
Row Level Security
Understand security policies
