How aswinpc143/netflixclone works
Project Type and Purpose
• This is a full-stack, Netflix-style streaming clone. The frontend is a React single-page application (SPA) that handles routing, UI, and state. The backend is entirely managed by Supabase (Auth, PostgreSQL database with RLS, and real-time subscriptions). External APIs (TMDB for movie data, YouTube for trailers) supply content. The app is deployed to Netlify.
High-Level File Structure & Architectural Patterns
• Top-level directories:
• public/ – static assets and index.html
• src/ – all client code
· App.js + index.js – entry point, router and context provider setup
· Components/ – reusable UI pieces (NavBar, Banner, RowPost, MovieCard, etc.)
· pages/ – route-level views (HomePage, BrowsePage, GenrePage, MyListPage, etc.)
· context/ – React Context providers for Auth, MyList, ViewingHistory
· lib/supabase.js – Supabase client initialization
· Axios.js & Urls.js – HTTP client and endpoint constants
· Constants/ – magic strings and API keys
• supabase/migrations/ – SQL schema definitions
• Architectural patterns: SPA with Context‐based state management, 3-tier separation (UI, client business logic, data), and micro-interactions via real-time subscriptions.
Main Components
A. User & Browser
• Represents end user accessing the React SPA served from Netlify.
B. Netlify CDN/Hosting
• Hosts built static assets (HTML, JS, CSS).
C. React Application (Client Layer)
• Router (React Router)
• Context Providers (AuthContext, MyListContext, ViewingHistoryContext)
• UI Components and Pages
• Axios HTTP client for REST calls
D. Supabase Services (Backend Layer)
1. Supabase Auth
• Handles user signup/login/logout
• Issues JWTs used in subsequent requests
2. PostgreSQL Database
• Tables: profiles, my_list, viewing_history, user_preferences
• Enforced Row Level Security (RLS)
3. Realtime Subscriptions
• Pushes live updates to the client (e.g., list changes) via websockets
E. External APIs
• TMDB REST API (movie/genre/search data)
• YouTube Embedded Player API (trailers)
Relationships & Data Flows
• User → Browser → Netlify → React App
• React App ⇄ Supabase Auth (REST over HTTPS for login/signup)
• React App ⇄ Supabase Realtime (websocket for live updates on lists/history)
• React App ⇄ Supabase PostgreSQL (REST/GraphQL‐style queries via Supabase client)
• React App → TMDB API (to fetch movie metadata and search results)
• React App → YouTube API (to embed trailers)
Architectural Patterns & Design Principles
• Single Page Application (SPA) with client-side routing
• Context API for cross-cutting concerns (authentication state, lists, history)
• Separation of concerns:
• Presentation (Components, Pages)
• State & Business Logic (Context + custom hooks)
• Data Access (Axios + Supabase client)
• Real-time updates via pub/sub model (Supabase Realtime)
• Secure by design: environment variables for API keys, RLS on database
Essential Elements to Capture
• Authentication lifecycle (signup→login→token propagation)
• Database schema components (profiles, my_list, viewing_history, preferences)
• Real-time subscription channels (e.g., when MyList changes)
• External API integration points (TMDB, YouTube)
• Hosting/CDN layer (Netlify) and build/deploy pipeline (GitHub Actions → npm-publish.yml → Netlify)