The MediaBox backend has been successfully implemented using Firebase, replacing the previous jsonstorage.net storage solution while preserving all required video source integration logic. This implementation provides a professional, scalable, and secure backend for the MediaBox streaming platform.
- Firebase app initialization with environment variable support
- Authentication, Firestore, and Storage services
- Analytics initialization
- Email/password registration and login
- Google and Facebook social login
- Password reset functionality
- User profile management
- User profile management
- Favorites system
- Watch history tracking
- Custom lists functionality
- Integration with TMDB API with caching in Firestore
- Methods for fetching movies, TV shows, and anime
- Conversion between TMDB and IMDb IDs
- Implementation of all required video source URL generation logic
- Support for vidsrc.dev, 2embed, 2embed.cc, vidsrc.xyz, and vidsrc.to
- Handling of different URL formats for movies and TV shows
- Personalized content recommendations based on watch history
- Genre preference analysis
- Recommendation caching
- Migration script for jsonstorage.net data (
scripts/migrate-data.js) - Admin interface for data migration (
src/pages/AdminPage.tsx)
- Secure access to user data
- Protection for custom lists
- Cache access rules
The backend provides several custom hooks for frontend integration:
- useAuth: Authentication state management
- useFavorites: Add/remove favorites
- useWatchHistory: Track watch progress
- useUserSettings: User preferences
- useTMDB: TMDB API data fetching
- useVideoSources: Video source URL generation
- useRecommendations: Personalized content recommendations
-
users: User profiles and preferences
- User authentication details
- Favorites list
- Watch history
- User settings
-
lists: Custom user-created lists
- List metadata
- List items
-
tmdb_cache: Cached responses from TMDB API
- API response data
- Timestamp for cache invalidation
-
recommendations: User recommendations
- Personalized content recommendations
- Recommendation metadata
To migrate data from jsonstorage.net to Firebase:
-
Using the Admin Interface:
- Navigate to
/adminin the application - Enter the jsonstorage.net bin ID
- Click "Start Migration"
- Navigate to
-
Using the Command Line:
- Run
npm run migrate <jsonstorage-bin-id>
- Run
-
Build the Application:
npm run build
-
Deploy to Firebase:
npm run firebase:deploy
-
Deploy Only Firestore Rules:
npm run firebase:deploy:rules
The implementation preserves all required video source integration logic:
- Dynamic URL generation for multiple providers
- TMDB ID to IMDb ID conversion where required
- Support for different URL formats for movies and TV shows
- Season and episode handling for TV shows
-
Performance Optimization:
- Implement pagination for large data sets
- Optimize database queries
-
Enhanced Security:
- Implement Firebase App Check
- Add rate limiting for API calls
-
Additional Features:
- User ratings and reviews
- Social sharing functionality
- Enhanced recommendation algorithms
The MediaBox backend implementation using Firebase provides a robust, secure, and scalable solution for the streaming platform. The implementation successfully replaces jsonstorage.net while preserving all required functionality and adding new features like personalized recommendations.