Skip to content

Latest commit

 

History

History
139 lines (102 loc) · 4.17 KB

File metadata and controls

139 lines (102 loc) · 4.17 KB

MediaBox Backend Implementation Summary

Overview

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.

Key Components

1. Firebase Configuration (src/lib/firebase.ts)

  • Firebase app initialization with environment variable support
  • Authentication, Firestore, and Storage services
  • Analytics initialization

2. Authentication Service (src/services/authService.ts)

  • Email/password registration and login
  • Google and Facebook social login
  • Password reset functionality
  • User profile management

3. User Service (src/services/userService.ts)

  • User profile management
  • Favorites system
  • Watch history tracking
  • Custom lists functionality

4. TMDB Service (src/services/tmdbService.ts)

  • Integration with TMDB API with caching in Firestore
  • Methods for fetching movies, TV shows, and anime
  • Conversion between TMDB and IMDb IDs

5. Video Source Service (src/services/videoSourceService.ts)

  • 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

6. Recommendation Service (src/services/recommendationService.ts)

  • Personalized content recommendations based on watch history
  • Genre preference analysis
  • Recommendation caching

7. Data Migration Utilities

  • Migration script for jsonstorage.net data (scripts/migrate-data.js)
  • Admin interface for data migration (src/pages/AdminPage.tsx)

8. Security Rules (firestore.rules)

  • Secure access to user data
  • Protection for custom lists
  • Cache access rules

React Hooks

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

Database Structure

Firestore Collections

  1. users: User profiles and preferences

    • User authentication details
    • Favorites list
    • Watch history
    • User settings
  2. lists: Custom user-created lists

    • List metadata
    • List items
  3. tmdb_cache: Cached responses from TMDB API

    • API response data
    • Timestamp for cache invalidation
  4. recommendations: User recommendations

    • Personalized content recommendations
    • Recommendation metadata

Migration Process

To migrate data from jsonstorage.net to Firebase:

  1. Using the Admin Interface:

    • Navigate to /admin in the application
    • Enter the jsonstorage.net bin ID
    • Click "Start Migration"
  2. Using the Command Line:

    • Run npm run migrate <jsonstorage-bin-id>

Deployment

  1. Build the Application:

    npm run build
  2. Deploy to Firebase:

    npm run firebase:deploy
  3. Deploy Only Firestore Rules:

    npm run firebase:deploy:rules

Video Source Integration

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

Next Steps

  1. Performance Optimization:

    • Implement pagination for large data sets
    • Optimize database queries
  2. Enhanced Security:

    • Implement Firebase App Check
    • Add rate limiting for API calls
  3. Additional Features:

    • User ratings and reviews
    • Social sharing functionality
    • Enhanced recommendation algorithms

Conclusion

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.