How sarthaksharmassss14/moviefy works
Purpose and Runtime
Moviefy is a Next.js 15 App Router application for movie discovery, personalized AI recommendations, and private social watch parties. It runs as a Node.js web application, with server-rendered routes, API route handlers, and server actions. Primary application shell and landing entry points are src/app/layout.tsx and src/app/page.tsx.
Route and UI Composition
User-facing routes cover discovery, movie/person/director detail, lists, profiles, watchlists, and party rooms. Dynamic resources are addressed by route IDs, notably src/app/movies/[id]/page.tsx, src/app/lists/[id]/page.tsx, and src/app/party/[id]/page.tsx. Shared interactive UI—including movie cards, personalized shelves, mood input, and the watch-room experience—lives in src/components/MovieCard.tsx, src/components/PickedForYouSection.tsx, and src/components/WatchPartyRoom.tsx.
Identity and Access Boundary
Clerk supplies authentication and session identity. Middleware at src/middleware.ts is the cross-cutting request boundary for protected routes, while dedicated sign-in/sign-up route pages provide Clerk entry points under src/app/sign-in/[[...sign-in]]/page.tsx and src/app/sign-up/[[...sign-up]]/page.tsx. Authenticated identity is expected to govern database access and private party participation.
Persistence, Realtime, and Social Parties
Supabase is the persistence and realtime backend, accessed through src/lib/supabase.ts. Watch-party lifecycle and room interaction are centered on src/app/party/[id]/page.tsx, src/components/WatchPartyButton.tsx, and src/components/WatchPartyRoom.tsx. The intended boundary is Clerk JWT-backed Supabase authorization plus Postgres RLS, protecting party sessions and realtime chat from unauthorized users.
Movie Catalog and Discovery Flow
TMDB/OMDb-backed catalog access is encapsulated by src/lib/tmdb.ts; route pages consume movie metadata rather than owning third-party API concerns. Search and browse flows enter through src/app/search/page.tsx, src/app/movies/[id]/page.tsx, and home carousel/card components such as src/components/HeroCarousel.tsx. This separates external catalog retrieval from presentation and user-owned data such as ratings, reviews, lists, and watchlists.
AI Mood Search and Recommendation Pipeline
Mood discovery is exposed as an API boundary at src/app/api/ai/mood/route.ts, with client interaction in src/components/MoodSearch.tsx. The AI layer is divided among Groq LLM orchestration (src/lib/groq.ts), broader AI logic (src/lib/ai.ts), and embedding generation (src/lib/embedding.ts). Groq Llama 3.3 interprets natural-language intent; Hugging Face embeddings and Supabase vector storage support semantic retrieval.
Personalized RAG and Mutations
The “Picked For You” shelf derives recommendations from user ratings/reviews and vector similarity through src/lib/recommendations.ts, surfaced by src/components/PickedForYouSection.tsx and likely served through src/app/api/suggestions/route.ts. Server-side mutations for user content and list state are concentrated in src/app/actions.ts and src/app/list-actions.ts, forming the application-to-Supabase write boundary.
Operational Dependencies
Required external services are Clerk, Supabase Postgres/Realtime/vector capabilities, TMDB, OMDb, Groq, and Hugging Face Inference. Database initialization and knowledge/vector ingestion are operationally separate from the web runtime, represented by setup_db.sql, seed-knowledge.js, and scripts/seed-bulk.ts. Deployment is intended for Vercel.
Main entry points: supabase.ts Supabase access layer · tmdb.ts Catalog service · layout.tsx App shell & home · page.tsx Discovery & detail routes
Components 22
Next.js web app
- App shell & home · Server-rendered application entry and landing experience.
src/app/layout.tsx - Discovery & detail routes · Search, movie, list, and other catalog-facing screens.
src/app/search/page.tsx - Party room route · Private watch-party page addressed by room ID.
src/app/party/[id]/page.tsx - Catalog UI · Hero carousel and movie cards present discovery results.
src/components/HeroCarousel.tsx - Mood search UI
src/components/MoodSearch.tsx - Picked For You shelf
src/components/PickedForYouSection.tsx - Watch room UI · Interactive party lifecycle and room experience.
src/components/WatchPartyRoom.tsx
Identity & access
- Protected-route middleware · Cross-cutting authenticated request boundary.
src/middleware.ts - Clerk · Supplies authentication, sessions, and JWT identity.
Data & social
- Supabase Postgres & Realtime · Stores user data, party state, chat, and vectors under RLS.
- Supabase access layer
src/lib/supabase.ts - User-content mutations · Write boundary for lists and user-owned content.
src/app/actions.ts - Catalog service · Encapsulates movie metadata retrieval.
src/lib/tmdb.ts - TMDB & OMDb
AI & recommendations
- Mood API · Client-facing natural-language discovery boundary.
src/app/api/ai/mood/route.ts - LLM orchestration · Interprets mood intent and coordinates AI logic.
src/lib/groq.ts - Embedding generation · Creates vectors for semantic retrieval.
src/lib/embedding.ts - Recommendation engine · Combines ratings/reviews with vector similarity.
src/lib/recommendations.ts - Suggestions API
src/app/api/suggestions/route.ts - Groq & Hugging Face · Llama intent inference and embedding inference.
Operations
- Database initialization · Operational schema and policy initialization.
setup_db.sql - Knowledge/vector ingestion · Seeds knowledge and bulk vector data outside web runtime.
scripts/seed-bulk.ts
Connections 25
- App shell & home → Discovery & detail routes: renders navigation to
- Discovery & detail routes → Catalog UI: composes
- Discovery & detail routes → Catalog service: reads metadata from
- Catalog UI → Catalog service: displays results from
- Catalog service → TMDB & OMDb: queries
- App shell & home → Mood search UI: hosts
- Mood search UI → Mood API: submits intent to
- Mood API → LLM orchestration: interprets via
- LLM orchestration → Groq & Hugging Face: uses Llama inference
- Mood API → Catalog service: returns catalog matches via
- App shell & home → Picked For You shelf: hosts
- Picked For You shelf → Suggestions API: loads from
- Suggestions API → Recommendation engine: requests
- Recommendation engine → Supabase access layer: retrieves profile vectors through
- Recommendation engine → Embedding generation: uses semantic vectors from
- Embedding generation → Groq & Hugging Face: uses embedding inference
- Supabase access layer → Supabase Postgres & Realtime: accesses
- User-content mutations → Supabase access layer: writes through
- Party room route → Watch room UI: renders
- Watch room UI → Supabase access layer: syncs room and chat through
- Protected-route middleware → Clerk: validates sessions with
- Protected-route middleware → Party room route: guards
- Clerk → Supabase Postgres & Realtime: JWT authorizes RLS access
- Database initialization → Supabase Postgres & Realtime: initializes schema and RLS
- Knowledge/vector ingestion → Supabase Postgres & Realtime: loads knowledge vectors