How front-end-bootcamp-plus-4/jackpot_plug works
Project type and purpose
• This is a full-stack web application built with Next.js and TypeScript, following a 4-layer Clean Architecture (app/api → application/usecases → domain → infra).
• Purpose: Allow users to extract music tracks from long YouTube videos, select favorites, assemble custom playlists, save/play them, and integrate with Spotify/YouTube APIs for search and recommendations. User management is backed by Supabase.
File structure
• app/ — Next.js front-end pages, shared components (/components) and serverless API routes (app/api/.../route.ts).
• application/usecases/ — business-logic services (e.g., LoginUseCase, SearchMusicUseCase) and DTOs.
• domain/ — core entities (Member, Music, Playlist, Video, etc.) and repository interfaces.
• infra/repositories/ — concrete implementations connecting domain repositories to external systems: Supabase (Postgres), Spotify API, YouTube API.
• hooks/, store/, utils/ — client-side utilities and state management (Zustand).
• Config files: next.config.ts (Next.js settings), lib/supabase.ts (Supabase client), tsconfig.json, etc.
• Public assets under public/.
README for additional insights
• Confirms Clean Architecture, tech stack (React, Next.js, TypeScript, Zustand, SASS, Supabase, Spotify API, YouTube API).
• Provides ERD showing Supabase tables for members, musics, playlists, playlist_videos, etc.
• Describes external API usage patterns (ISRC code from Spotify, OR‐based YouTube searches).
Main components and their relationships
a. Frontend (Next.js UI)
• Pages in app/(anon) for anonymous users and app/(sign) for auth flows
• Shared components in app/components + global utils/hooks
• Client-side state stores via Zustand (store/)
• Trigger API calls to app/api/* routes
b. API layer (Next.js Serverless Functions)
• Handlers under app/api/*/route.ts map HTTP requests to application use cases
• Perform input validation, authentication (cookies/JWT), then call use cases
c. Application Layer (Use Cases)
• Encapsulate application-specific business logic (e.g., CreatePlaylistUseCase)
• Receive DTOs from API, orchestrate domain operations, return DTOs
d. Domain Layer
• Entities model core concepts (Member, Music, Playlist, Video)
• Repository interfaces declare operations (IMemberRepository, MusicRepository, etc.)
e. Infra Layer
• Implements repository interfaces:
• SupabaseMemberRepository, SupabaseMusicRepository → Supabase (Postgres) via lib/supabase.ts
• SpotifyApiRepository → Spotify Web API (fetch ISRC and track data)
• YouTubeApiRepository / VideoRepository / VideoCommentRepository → YouTube Data API
f. Database (Supabase/Postgres)
• Tables: members, musics, playlists, playlist_videos, etc. as per ERD
g. External Services
• Spotify API (ISRC lookup, track info)
• YouTube Data API (search, comments, video info)
Architectural patterns and design principles
• Clean Architecture (four layers, Dependency Rule: outer layers depend on inner layers only via abstractions).
• Separation of concerns: UI vs. API routing vs. business logic vs. persistence.
• Dependency Injection: API handlers instantiate use cases with concrete infra repositories.
• Single-Responsibility: each module has one reason to change.
• Serverless functions (stateless handlers) for scalability and Vercel deployment.
Final advice
• Be exhaustive: include every major module (pages, API routes, use cases, repos).
• Don’t overcrowd: group modules logically and expose only public interfaces.
• Data flows for the critical user journeys:
• User logs in → LoginUseCase → MemberRepository (Supabase).
• User extracts tracks → GetVideoContentsUseCase → YouTubeRepo → Domain → UI.
• User searches → SearchMusicUseCase → SpotifyRepo → YouTubeRepo.
• User creates playlist → CreatePlaylistUseCase → PlaylistRepo + PlaylistMusicRepo.