Setup & Installation Guide¶
Overview¶
This guide covers the complete setup process for ConnectGain, including environment configuration, dependencies, and deployment.
Prerequisites¶
Required Accounts¶
- Supabase Account - For backend services
- AppGain Account (optional) - For WhatsApp Lite
- Meta Business Account (optional) - For WhatsApp Cloud, Messenger, Instagram
- Stripe Account (optional) - For payment processing
Development Tools¶
- Node.js 18+ and npm
- Git - Version control
- Code Editor - VS Code recommended
- Supabase CLI - For local development
Local Development Setup¶
Step 1: Clone Repository¶
Step 2: Install Dependencies¶
Step 3: Environment Variables¶
Create .env.local file:
VITE_SUPABASE_URL=https://txpaxbxhnvnhsjwwaeoy.supabase.co
VITE_SUPABASE_ANON_KEY=your_anon_key_here
VITE_STRIPE_PUBLIC_KEY=your_stripe_key_here
Step 4: Start Development Server¶
Application will be available at http://localhost:5173
Production Deployment¶
Frontend Deployment (Vercel)¶
- Connect Repository
- Import project to Vercel
-
Connect GitHub repository
-
Configure Environment Variables
- Add all required environment variables
-
Set production values
-
Deploy
- Vercel automatically deploys on push
-
Or trigger manual deployment
-
Configure Domain
- Add custom domain
- Configure DNS
Frontend Deployment (Netlify)¶
- Connect Repository
- Import project to Netlify
-
Connect Git repository
-
Build Settings
- Build command:
npm run build -
Publish directory:
dist -
Environment Variables
- Add environment variables
-
Set production values
-
Deploy
- Deploy automatically or manually
Edge Functions Deployment¶
# Install Supabase CLI
npm install -g supabase
# Login to Supabase
supabase login
# Link project
supabase link --project-ref your-project-ref
# Deploy function
supabase functions deploy function-name
Database Setup¶
Initial Migration¶
Required Extensions¶
-- Enable required extensions
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
Seed Data (Optional)¶
Channel Configuration¶
WhatsApp Lite Setup¶
- Get AppGain Account
- Sign up at AppGain
-
Get Suit ID
-
Configure in ConnectGain
- Go to Settings → Channels
- Add WhatsApp Lite
- Enter Suit ID
- Connect
WhatsApp Cloud Setup¶
- Meta Business Setup
- Create Meta Business Account
- Set up WhatsApp Business API
-
Get access token and phone number ID
-
Configure Webhook
- Webhook URL:
https://your-project.supabase.co/functions/v1/whatsapp-cloud-webhook - Subscribe to
messagesevents -
Verify webhook
-
Configure in ConnectGain
- Go to Settings → Channels
- Add WhatsApp Cloud
- Enter credentials
- Connect
Other Channels¶
Similar setup process for: - Facebook Messenger - Instagram - Telegram - TikTok
Security Configuration¶
API Keys¶
- Generate API Keys
- Go to Settings → API Keys
- Generate new key
-
Store securely
-
Set Permissions
- Configure key permissions
- Set expiration (optional)
Webhook Security¶
- Configure Webhook Secrets
- Generate secret
- Store in environment variables
-
Configure in webhook settings
-
Verify Signatures
- Webhooks verify HMAC signatures
- Ensure secrets match
Monitoring Setup¶
Error Tracking¶
- Configure Error Logging
- Set up error tracking service
- Configure error boundaries
- Monitor Edge Function logs
Analytics¶
- Set Up Analytics
- Configure analytics service
- Track key metrics
- Set up dashboards
Backup Configuration¶
Database Backups¶
- Automatic Backups
- Supabase provides automatic backups
- Configure backup retention
- Test restore process
Manual Backups¶
Performance Optimization¶
Frontend Optimization¶
- Build Optimization
- Enable code splitting
- Optimize images
-
Minify assets
-
Caching
- Configure CDN caching
- Set cache headers
- Use service workers
Backend Optimization¶
- Database Indexing
- Add indexes for frequent queries
- Optimize slow queries
-
Monitor query performance
-
Edge Functions
- Optimize function code
- Set appropriate timeouts
- Monitor function performance
Testing Setup¶
Unit Tests¶
Integration Tests¶
E2E Tests¶
Troubleshooting Setup Issues¶
Common Issues¶
- Environment Variables Not Loading
- Check
.env.localfile exists - Verify variable names match
-
Restart dev server
-
Database Connection Failed
- Verify Supabase URL and key
- Check network connectivity
-
Verify RLS policies
-
Edge Functions Not Deploying
- Check Supabase CLI version
- Verify project link
- Review function code
Related Documentation¶
Last Updated: January 2025