A modern, full-stack streaming platform built with Next.js, Firebase, and TMDB API, featuring deterministic AI-powered recommendations.
- 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
- 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
- Node.js 18+ and npm
- Firebase project with Firestore and Authentication enabled
- TMDB API key (free tier available at https://www.themoviedb.org/settings/api)
git clone <repository-url>
cd Movie-Streamingnpm installCreate 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"- Create a Firebase project at https://console.firebase.google.com
- Enable Authentication with the following providers:
- Google (OAuth)
- Email/Password (for email link authentication)
- Create a Firestore database
- Download your service account key for Admin SDK
- Copy the configuration values to
.env.local
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;
}
}
}
npm run devOpen http://localhost:3000 in your browser.
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
The recommendation system uses a hybrid approach combining multiple algorithms:
- Content-Based Filtering: Analyzes genre similarity between watched content and potential recommendations
- Collaborative Filtering: Finds users with similar watch patterns (using Jaccard similarity)
- Behavioral Ranking: Considers recency, completion rate, and re-watch count
- 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.
- Watchlist updates instantly across devices using Firestore real-time listeners
- Watch progress syncs automatically
- Recommendations are cached for 24 hours and refreshed on-demand
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"
}
}- 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
The API is designed to be consumed by a React Native mobile app:
- All endpoints use standard HTTP methods (GET, POST, PUT, DELETE)
- Authentication uses Firebase tokens in Authorization header
- Consistent response format across all endpoints
- TypeScript types can be shared between web and mobile
- Push your code to GitHub
- Import project in Vercel
- Add environment variables in Vercel dashboard
- Deploy!
The app can be deployed to any platform that supports Next.js:
- AWS Amplify
- Netlify
- Railway
- Self-hosted with Docker
| 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 |
This is a production-ready codebase. Contributions are welcome!
MIT License - feel free to use this project for learning or commercial purposes.
- Movie and TV data provided by TMDB
- Built with Next.js
- Powered by Firebase
- Styled with Tailwind CSS
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.