Prerequisites
- Supabase account (free tier available)
- Supabase CLI installed
- Node.js 18+ and npm installed
Quick Start
Create a Supabase project
- Go to supabase.com and sign in
- Click New Project
- Choose an organization
- Enter project details:
- Name:
senti-radar(or your preferred name) - Database Password: Generate a strong password and save it
- Region: Choose closest to your users
- Name:
- Click Create new project and wait for provisioning (~2 minutes)
Link your project
https://supabase.com/dashboard/project/[your-project-ref]Database Schema
SENTi-radar uses the following database tables. The schema is automatically created during initial app setup, but you can manually create it if needed.Core Tables
topics
Stores user-created topics for sentiment monitoring.
posts
Stores scraped social media posts for analysis.
topic_stats
Aggregated statistics and AI summaries for each topic.
sentiment_timeline
Time-series data for sentiment trend charts.
alerts
Crisis alerts and notifications.
Indexes
Create indexes for performance:Edge Functions
SENTi-radar uses Supabase Edge Functions (Deno runtime) for server-side data processing.Available Functions
fetch-twitter
fetch-twitter
Fetches live posts from X (Twitter), Reddit, YouTube, and Parallel.ai.Priority order:
- Scrape.do (X + Reddit)
- Parallel.ai (social search fallback)
- YouTube Data API
- Algorithmic generation (guaranteed fallback)
SCRAPE_DO_TOKENSUPABASE_URLSUPABASE_SERVICE_ROLE_KEY
PARALLEL_API_KEYYOUTUBE_API_KEY
analyze-sentiment
analyze-sentiment
Analyzes sentiment and emotions using Gemini AI with keyword-based fallback.Features:
- Classifies sentiment: positive, negative, mixed, neutral
- Identifies 6 emotions: joy, anger, sadness, fear, surprise, disgust
- Generates AI summaries and key takeaways
- Detects crisis spikes
SUPABASE_URLSUPABASE_SERVICE_ROLE_KEY
GEMINI_API_KEY(falls back to keyword analysis if not set)
fetch-youtube
fetch-youtube
Fetches YouTube video search results and metadata.Required secrets:
YOUTUBE_API_KEYSUPABASE_URLSUPABASE_SERVICE_ROLE_KEY
analyze-topic
analyze-topic
Performs comprehensive topic analysis combining all data sources.Required secrets:
SUPABASE_URLSUPABASE_SERVICE_ROLE_KEY
generate-insights
generate-insights
Generates AI-powered insights and recommendations.Required secrets:
GEMINI_API_KEYSUPABASE_URLSUPABASE_SERVICE_ROLE_KEY
scheduled-monitor
scheduled-monitor
Scheduled function for automated topic monitoring (runs via cron).Required secrets:
SUPABASE_URLSUPABASE_SERVICE_ROLE_KEY
Deploy Edge Functions
Function Configuration
The edge functions are configured insupabase/config.toml:
Set Edge Function Secrets
Set required secrets for your edge functions:Authentication Setup
SENTi-radar currently has authentication disabled (
email_confirm_by_default = false). Enable authentication if you want to add user accounts.- Go to Authentication → Providers in Supabase dashboard
- Enable Email provider
- Configure email templates
- Update
config.toml:
Row Level Security (RLS)
Example RLS policies for thetopics table:
Monitoring & Logs
View Function Logs
Database Logs
View database logs in the Supabase dashboard:- Logs → Postgres Logs: SQL queries and errors
- Logs → API Logs: REST API requests
- Logs → Functions Logs: Edge function execution logs
Local Development
Start local Supabase stack
- PostgreSQL database on
localhost:54322 - Studio UI on
http://localhost:54323 - Edge Functions on
http://localhost:54321
Troubleshooting
Connection Issues
Problem: Cannot connect to Supabase from app Solutions:- Verify project URL has no trailing slash
- Check anon key is correct (not service role key)
- Ensure project is active (not paused)
- Check network firewall/proxy settings
Function Deployment Fails
Problem:supabase functions deploy fails
Solutions:
- Ensure you’re logged in:
supabase login - Verify project link:
supabase link --project-ref your-ref - Check function syntax (Deno TypeScript)
- Review function logs for errors
Secrets Not Working
Problem: Edge functions can’t access secrets Solutions:- Verify secrets are set:
supabase secrets list - Redeploy functions after setting secrets
- Check secret names match exactly (case-sensitive)
- View function logs for specific errors
Database Performance
Problem: Slow queries or timeouts Solutions:- Add indexes on frequently queried columns
- Use
EXPLAIN ANALYZEto identify slow queries - Enable connection pooling
- Upgrade to a larger database instance
Next Steps
Environment Variables
Configure all environment variables
Scrape.do Integration
Set up social media scraping
API Keys
Get YouTube, Gemini, and Groq API keys
Supabase Docs
Official Supabase documentation