Raffi’s backend is built on a modern serverless stack, combining Convex for real-time features and Supabase for authentication and relational data.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/kaleidal/raffi/llms.txt
Use this file to discover all available pages before exploring further.
Tech Stack Overview
Backend Services
Technology Choices
- Convex 1.31.7: Real-time serverless backend
- Supabase 2.95.3: PostgreSQL database with real-time capabilities
- Ave ID SDK 0.2.2: Authentication provider
- TypeScript: Shared types across frontend and backend
Convex Backend
Overview
Convex provides the real-time layer for collaborative features and synchronized state across devices. Location:convex/ directory in root
Database Schema
Location:convex/schema.ts
Key Features
1. Addon Management
Schema:addons table
Stores user’s installed Stremio addons:
- Transport URL (addon endpoint)
- Manifest (capabilities, name, description)
- Flags (user-specific settings)
by_user: Get all addons for a userby_user_transport: Prevent duplicate addon installations
2. Library & Progress Tracking
Schema:libraries table
Tracks watched content across devices:
by_user: Get user’s entire libraryby_user_imdb: Check if content is in library
3. Custom Lists
Schema:lists + list_items tables
Two-table design for flexibility:
Lists:
4. Watch Parties
Schema:watch_parties + watch_party_members tables
Real-time synchronized viewing:
Party State:
- Host controls playback (play/pause/seek)
- Members receive instant updates
- Presence tracking via
last_seen - Automatic expiration
5. Trakt Integration
Schema:trakt_integrations table
Stores OAuth tokens for Trakt.tv:
- Access token for API requests
- Refresh token for renewal
- Token expiration tracking
Backend Logic
Location:convex/raffi.ts (53KB file)
Convex functions are written in TypeScript:
Query Example (read data):
Authentication
Location:convex/auth.config.ts
Client Integration
Desktop
Location:raffi-desktop/src/lib/
Mobile
Location:raffi-mobile/lib/convex.ts
Same API as desktop:
Supabase Backend
Overview
Supabase provides PostgreSQL database with authentication and storage. Primary Use Cases:- User authentication (OAuth, email/password)
- User profiles and settings
- Fallback for non-real-time data
- File storage (avatars, etc.)
Client Integration
Desktop
Location:raffi-desktop/src/lib/db/
Mobile
Same SDK, different entry point:Authentication Flow
Row-Level Security
Supabase supports RLS policies for data isolation:Integration with Ave ID
Package:@ave-id/sdk
Ave ID provides additional authentication options:
- Web3 wallet authentication
- Decentralized identity
- Cross-platform user profiles
- Desktop:
raffi-desktop/package.json:134 - Mobile:
raffi-mobile/package.json:14
Data Flow Architecture
Watch Progress Sync
Watch Party Flow
Addon Sync
Performance Considerations
Real-time Subscriptions
Convex:- Automatic query invalidation
- Efficient WebSocket protocol
- Batched updates
- Client-side caching
Optimistic Updates
Offline Support
Convex handles offline automatically:- Mutations queued when offline
- Retry on reconnection
- Conflict resolution via timestamps
Deployment
Convex
Supabase
Hosted:- Use Supabase cloud (supabase.com)
- Get project URL and anon key
- Set in environment variables
Security
API Keys
Environment Variables:.envfiles- API keys in code
- User tokens
Data Validation
Convex validates all inputs:Authentication
All Convex queries/mutations require authentication:Monitoring & Debugging
Convex Dashboard
- View all tables and data
- Monitor function calls
- Check error logs
- Inspect WebSocket connections
Supabase Dashboard
- Database explorer
- Auth user management
- Storage file browser
- SQL editor
- Real-time logs
Key Design Decisions
Why Convex?
- Real-time First: Built for live data
- Type Safety: Full TypeScript support
- Serverless: No infrastructure management
- Developer Experience: Excellent local development
Why Supabase?
- PostgreSQL: Powerful relational database
- Authentication: OAuth providers built-in
- Open Source: Self-hosting option
- Ecosystem: Large community and tools
Why Both?
- Convex: Real-time collaborative features
- Supabase: Authentication and relational data
- Separation of Concerns: Each service excels at its role
Future Considerations
Potential Enhancements
- Caching Layer: Redis for frequently accessed data
- CDN: Serve static content (posters, metadata)
- Analytics: Track usage patterns
- Search: Algolia or Meilisearch for content discovery
- Recommendations: ML-based content suggestions