Onboarding System - Quick Start Guide
Getting Started in 5 Minutes
Prerequisites
- Firebase project with Firestore enabled
- Supabase project with database
- JIRA Cloud instance (optional, for full pipeline)
- Environment variables configured
Step 1: Run Database Migrations
# Navigate to frontend
cd clients/frontend
# Run Supabase migrations
supabase db push
# Or manually run the migration SQL
psql -h your-supabase-host -U postgres -d your-db -f supabase/migrations/20241120_onboarding_tables.sqlStep 2: Configure Environment Variables
Create or update .env.local:
# Firebase
NEXT_PUBLIC_FIREBASE_API_KEY=your_key_here
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_domain_here
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_here
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_bucket_here
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id_here
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id_here
# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key_here
# JIRA (Optional)
NEXT_PUBLIC_JIRA_API_ENDPOINT=/api/jira
JIRA_API_URL=https://your-domain.atlassian.net
JIRA_EMAIL=your_email@example.com
JIRA_API_TOKEN=your_api_token_hereStep 3: Deploy Firebase Security Rules
Create firestore.rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// User profiles
match /user_profiles/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// Questionnaire responses
match /questionnaire_responses/{responseId} {
allow read: if request.auth != null && resource.data.user_id == request.auth.uid;
allow write: if request.auth != null && request.resource.data.user_id == request.auth.uid;
}
// Onboarding progress
match /onboarding_progress/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// League fingerprints
match /league_fingerprints/{fingerprintId} {
allow read: if request.auth != null;
allow write: if request.auth != null && request.resource.data.user_id == request.auth.uid;
}
// Compliance status
match /compliance_status/{statusId} {
allow read: if request.auth != null;
allow write: if request.auth != null;
}
// Generated contracts
match /generated_contracts/{contractId} {
allow read: if request.auth != null && resource.data.user_id == request.auth.uid;
allow write: if request.auth != null;
}
// JIRA cards
match /jira_cards/{cardId} {
allow read: if request.auth != null;
allow write: if request.auth != null;
}
}
}Deploy:
firebase deploy --only firestore:rulesStep 4: Test the Flow
- Start Development Server
npm run dev-
Create Test User
- Navigate to
/signup - Create account with email/password
- You should be redirected to onboarding
- Navigate to
-
Complete Onboarding
- Select "League Owner" role
- Fill out questionnaire
- Submit and verify redirect
-
Verify Data
Check Firebase:
// In Firebase Console β Firestore
// Look for documents in:
// - user_profiles/{userId}
// - questionnaire_responses/{responseId}
// - league_fingerprints/{fingerprintId}Check Supabase:
-- In Supabase SQL Editor
SELECT * FROM league_questionnaires;
SELECT * FROM league_fingerprints;Step 5: Configure JIRA (Optional)
-
Create Project
- Go to JIRA Cloud
- Create project with key "LO"
- Create board named "inbound"
-
Get API Token
- Go to https://id.atlassian.com/manage-profile/security/api-tokens (opens in a new tab)
- Create new token
- Add to environment variables
Role-Specific Onboarding Flows
League Owner (Full Flow)
- 10-step progressive questionnaire
- Auto-save every 30 seconds
- Contract generation
- JIRA card creation
Trader (Quick Setup)
- Preferences only
- 2-3 questions
- Immediate access
Sportsbook Operator
- Integration preferences
- API credentials
- Webhook configuration
Customization Options
Modify Questionnaire Steps
Edit clients/frontend/config/questionnaires/league-owner-flow.ts
Change Auto-Save Interval
Update AUTO_SAVE_INTERVAL in LeagueOwnerOnboardingWizard.tsx
Adjust Compliance Scoring
Modify calculateComplianceScore() in lib/utils/fingerprint.ts
Debugging Tips
Check Console Logs
# Browser console shows:
# - Auto-save events
# - Validation errors
# - API call statusVerify Firebase Connection
// In browser console
import { getFirestore } from 'firebase/firestore';
const db = getFirestore();
console.log('Firebase connected:', db);Test API Endpoints
# Test fingerprint generation
curl -X POST http://localhost:3000/api/fingerprint/generate \
-H "Content-Type: application/json" \
-d '{"leagueName": "Test League"}'Performance Tips
- Enable Firebase persistence for offline support
- Use Supabase connection pooling for high traffic
- Cache questionnaire configs in localStorage
- Lazy load contract generation
Security Checklist
- β Firebase security rules deployed
- β Supabase RLS policies enabled
- β API endpoints authenticated
- β Environment variables secured
- β File uploads validated
Monitoring
Firebase Console
- Monitor Firestore usage
- Check authentication logs
- Review storage usage
Supabase Dashboard
- Database query performance
- API endpoint metrics
- Real-time subscription usage
Deployment Instructions
Vercel Deployment
# Set environment variables in Vercel dashboard
# Deploy
vercel --prodEnvironment Variables Required
- All Firebase config vars
- All Supabase config vars
- JIRA credentials (if using)
Next Steps
- β Complete test flow
- π Review generated data
- π― Customize questionnaire
- π§ Integrate with your pipeline
- π Deploy to production
For complete implementation details, see the League Owner Onboarding System Guide.