How markomilos/netflix-clone works
Main components
• Frontend Application: Represented by the Next.js “app” directory that contains pages for browsing, movies, my list, profiles, authentication, etc. Also note the component library (components directory), and Storybook for isolated UI components.
• API Endpoints: Under the “app/api” directory you have endpoints for authentication (including social login via NextAuth), movie details, managing “my list”, and user data.
• Business Logic/Services: The “service” directory encapsulates services like AuthService, ContentService, MyListService, ProfileService, TMDBService, and UserService. These form the backend logic connecting frontend actions to data operations.
• Database: The PostgreSQL database is interfaced via Prisma (see prisma/schema.prisma) and its connection is managed with Prisma’s client in “lib/prismadb.ts”.
• External Integrations: The TMDB API is used to retrieve content data (see TMDBService.ts and lib/tmdb-image.ts).
• Infrastructure: Docker Compose is used to simplify the deployment, indicating separate containers for the Next.js application, the PostgreSQL database, and pgAdmin for database administration.
Relationships and interactions
• The Frontend (Next.js) communicates with the internal API endpoints for authentication, content fetching, and user data management.
• The API endpoints, in turn, call the respective services (service/AuthService, service/ContentService, etc.) which encapsulate business logic.
• Data persistence is handled via Prisma which interfaces with the PostgreSQL database.
• The TMDBService integrates with the external TMDB API to fetch movie/TV content and images.
• Internal libraries (in the “lib” folder) provide shared functionality (e.g., logging, fetching utilities, authentication management).
Architectural patterns & technologies
• MVC/MV* like separation is evident wherein Next.js pages render the frontend while API routes and services handle backend logic.
• API layering: The separation of concerns is visible with dedicated API routes invoking service logic.
• External API integration: TMDB is used to source content data.
• Component-based UI design: React components are modularized with component directories and are developed/tested using Storybook.
• Dockerized Infrastructure: Using Docker Compose to manage and run multi-container applications.
• Integration with modern state management (Zustand) and data fetching (SWR) is used on the client side.
• Chart out the flow from API calls to the Service layer and then to the PostgreSQL database, including communication with the TMDB external API.
• A separate node for the Docker Compose setup, which houses multiple containers (Next.js, PostgreSQL, pgAdmin).