Skip to content

Rana0001/cinevora

Repository files navigation

Cinevora - AI-Powered Movie & TV Streaming Platform

A modern, full-stack streaming platform built with Next.js, Firebase, and TMDB API, featuring deterministic AI-powered recommendations.

🎯 Features

  • Authentication:
    • Google Sign-In (OAuth)
    • Passwordless Email Authentication (Magic Link)
  • Movie & TV Browsing: Browse trending, popular, and search content from TMDB
  • Personalized Recommendations: Deterministic AI recommendations using:
    • Content-based filtering (genre similarity)
    • Collaborative filtering (user similarity)
    • Behavioral ranking (recency, completion rate, engagement)
  • Watchlist: Save movies and TV shows for later
  • Watch History: Track viewing progress and continue watching
  • Real-time Updates: Firebase Firestore for real-time data sync
  • Responsive Design: Beautiful UI that works on all devices
  • Mobile-Ready APIs: RESTful APIs ready for React Native consumption

πŸ› οΈ Tech Stack

  • Frontend: Next.js 15 (App Router), React 19, Tailwind CSS
  • Backend: Next.js API Routes, Server Actions
  • Database: Firebase Firestore
  • Authentication: Firebase Authentication
  • External API: TMDB API v3
  • Language: TypeScript
  • Styling: Tailwind CSS with custom dark theme

πŸ“‹ Prerequisites

πŸš€ Getting Started

1. Clone the repository

git clone <repository-url>
cd Movie-Streaming

2. Install dependencies

npm install

3. Configure environment variables

Create a .env.local file in the root directory:

# TMDB API Configuration
NEXT_PUBLIC_TMDB_API_KEY=your_tmdb_api_key_here
TMDB_API_KEY=your_tmdb_api_key_here

# Firebase Client Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id

# Firebase Admin SDK (Server-side only)
FIREBASE_ADMIN_PROJECT_ID=your-project-id
FIREBASE_ADMIN_CLIENT_EMAIL=firebase-adminsdk@your-project.iam.gserviceaccount.com
FIREBASE_ADMIN_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYour private key here\n-----END PRIVATE KEY-----\n"

4. Set up Firebase

  1. Create a Firebase project at https://console.firebase.google.com
  2. Enable Authentication with the following providers:
    • Google (OAuth)
    • Email/Password (for email link authentication)
  3. Create a Firestore database
  4. Download your service account key for Admin SDK
  5. Copy the configuration values to .env.local

5. Deploy Firestore security rules

Create firestore.rules in your Firebase project:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    // Users collection
    match /users/{userId} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }

    // Watchlists
    match /watchlists/{userId}/items/{itemId} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }

    // Watch History
    match /watchHistory/{userId}/items/{itemId} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }

    // Recommendations
    match /recommendations/{userId} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }
  }
}

6. Run the development server

npm run dev

Open http://localhost:3000 in your browser.

πŸ“ Project Structure

Movie-Streaming/
β”œβ”€β”€ app/                      # Next.js App Router pages
β”‚   β”œβ”€β”€ api/                  # API routes
β”‚   β”‚   β”œβ”€β”€ user/            # User profile endpoints
β”‚   β”‚   β”œβ”€β”€ watchlist/       # Watchlist endpoints
β”‚   β”‚   β”œβ”€β”€ history/         # Watch history endpoints
β”‚   β”‚   └── recommendations/ # Recommendation endpoints
β”‚   β”œβ”€β”€ movie/[id]/          # Movie detail page
β”‚   β”œβ”€β”€ tv/[id]/             # TV show detail page
β”‚   β”œβ”€β”€ login/               # Login page
β”‚   β”œβ”€β”€ signup/              # Signup page
β”‚   β”œβ”€β”€ profile/             # User profile page
β”‚   β”œβ”€β”€ watchlist/           # Watchlist page
β”‚   β”œβ”€β”€ history/             # Watch history page
β”‚   β”œβ”€β”€ search/              # Search page
β”‚   β”œβ”€β”€ layout.tsx           # Root layout
β”‚   β”œβ”€β”€ page.tsx             # Home page
β”‚   └── globals.css          # Global styles
β”œβ”€β”€ components/              # Reusable React components
β”‚   β”œβ”€β”€ Navbar.tsx
β”‚   β”œβ”€β”€ Footer.tsx
β”‚   β”œβ”€β”€ MovieCard.tsx
β”‚   β”œβ”€β”€ Carousel.tsx
β”‚   β”œβ”€β”€ WatchlistButton.tsx
β”‚   └── Loading.tsx
β”œβ”€β”€ lib/                     # Core library code
β”‚   β”œβ”€β”€ api/                 # API utilities
β”‚   β”‚   └── middleware.ts    # Auth middleware
β”‚   β”œβ”€β”€ context/             # React contexts
β”‚   β”‚   └── AuthContext.tsx
β”‚   β”œβ”€β”€ firebase/            # Firebase configuration
β”‚   β”‚   β”œβ”€β”€ config.ts        # Client SDK
β”‚   β”‚   └── admin.ts         # Admin SDK
β”‚   β”œβ”€β”€ services/            # Business logic services
β”‚   β”‚   β”œβ”€β”€ tmdb.ts          # TMDB API service
β”‚   β”‚   β”œβ”€β”€ watchlist.ts     # Watchlist service
β”‚   β”‚   β”œβ”€β”€ history.ts       # Watch history service
β”‚   β”‚   └── recommendation.ts # Recommendation engine
β”‚   └── utils/               # Utility functions
β”‚       └── similarity.ts    # Similarity algorithms
β”œβ”€β”€ types/                   # TypeScript type definitions
β”‚   └── index.ts
β”œβ”€β”€ public/                  # Static assets
β”œβ”€β”€ .env.example             # Environment variables template
β”œβ”€β”€ .env.local               # Your environment variables (gitignored)
β”œβ”€β”€ next.config.js           # Next.js configuration
β”œβ”€β”€ tailwind.config.ts       # Tailwind CSS configuration
β”œβ”€β”€ tsconfig.json            # TypeScript configuration
└── package.json             # Dependencies and scripts

🎨 Key Features Explained

Recommendation Engine

The recommendation system uses a hybrid approach combining multiple algorithms:

  1. Content-Based Filtering: Analyzes genre similarity between watched content and potential recommendations
  2. Collaborative Filtering: Finds users with similar watch patterns (using Jaccard similarity)
  3. Behavioral Ranking: Considers recency, completion rate, and re-watch count
  4. Cold-Start Handling: New users get trending and popular content until enough data is collected

All algorithms are deterministic and explainable - no black-box ML models.

Real-Time Features

  • Watchlist updates instantly across devices using Firestore real-time listeners
  • Watch progress syncs automatically
  • Recommendations are cached for 24 hours and refreshed on-demand

API Design

All API routes follow RESTful conventions and return consistent JSON responses:

{
  "success": true,
  "data": { ... }
}

Or on error:

{
  "success": false,
  "error": {
    "message": "Error description",
    "code": "ERROR_CODE"
  }
}

πŸ”’ Security

  • Firebase Authentication handles user sessions
  • Server-side token verification on all protected routes
  • Firestore security rules enforce user-specific data access
  • API keys are never exposed to the client
  • CORS configured for mobile app support

πŸ“± Mobile App Integration

The API is designed to be consumed by a React Native mobile app:

  1. All endpoints use standard HTTP methods (GET, POST, PUT, DELETE)
  2. Authentication uses Firebase tokens in Authorization header
  3. Consistent response format across all endpoints
  4. TypeScript types can be shared between web and mobile

πŸš€ Deployment

Vercel (Recommended)

  1. Push your code to GitHub
  2. Import project in Vercel
  3. Add environment variables in Vercel dashboard
  4. Deploy!

Other Platforms

The app can be deployed to any platform that supports Next.js:

  • AWS Amplify
  • Netlify
  • Railway
  • Self-hosted with Docker

πŸ“ Environment Variables

Variable Description Required
NEXT_PUBLIC_TMDB_API_KEY TMDB API key (client-side) Yes
TMDB_API_KEY TMDB API key (server-side) Yes
NEXT_PUBLIC_FIREBASE_API_KEY Firebase API key Yes
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN Firebase auth domain Yes
NEXT_PUBLIC_FIREBASE_PROJECT_ID Firebase project ID Yes
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET Firebase storage bucket Yes
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID Firebase messaging sender ID Yes
NEXT_PUBLIC_FIREBASE_APP_ID Firebase app ID Yes
FIREBASE_ADMIN_PROJECT_ID Firebase admin project ID Yes
FIREBASE_ADMIN_CLIENT_EMAIL Firebase admin client email Yes
FIREBASE_ADMIN_PRIVATE_KEY Firebase admin private key Yes

🀝 Contributing

This is a production-ready codebase. Contributions are welcome!

πŸ“„ License

MIT License - feel free to use this project for learning or commercial purposes.

πŸ™ Acknowledgments

πŸ“§ Support

For issues or questions, please open an issue on GitHub.


Note: This platform is for demonstration purposes. Actual video streaming functionality is not implemented - only metadata, recommendations, and playback state tracking.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published