How shajon-404/iptv works
1. Repository shape
- This is a single Next.js App Router application, not a multi-service backend.
- The codebase is split into route folders under app/, shared UI in app/components/, domain hooks in app/hooks/, and server utilities in app/lib/.
- The main architecture is a browser-based IPTV player with a few adjacent features: authentication, playlist sync, viewer tracking, and a separate fixtures/bracket section.
2. Primary user-facing surface
- The IPTV experience is centered around the player UI in app/components/IPTVPlayer.tsx and the app/components/player/* subcomponents.
- The player area is decomposed into channel listing, playlist management, channel stats, sidebar, and video playback views.
- Supporting shell components like Header, Footer, MobileNavBar, BackgroundScene, and modal/popup wrappers provide the site chrome and cinematic presentation layer.
3. Playback subsystem
- Media playback is a dedicated subsystem with support for multiple stream formats, as described in the README: HLS, DASH/ClearKey DRM, and MPEG-TS.
- The project uses client-side playback engines such as HLS.js, Shaka Player, and mpegts.js, which implies that the browser is responsible for actual decoding/rendering while the server mostly brokers access.
- The useVideoPlayer hook likely coordinates player state, stream selection, quality switching, and viewer-facing playback controls.
4. IPTV backend API boundary
- The API under app/api/iptv/ is the core server boundary for IPTV-specific operations.
- Endpoints cover:
- playlist CRUD/sync (playlists)
- channel listing and channel hashing (channels, channels/hash)
- stream proxying (proxy)
- viewer telemetry (viewers)
- This keeps the browser UI thin: it asks the app server for playlist/channel metadata and only hits stream sources through a controlled proxy when needed.
5. Stream access and proxying
- The app/api/iptv/proxy/route.ts endpoint is a security and compatibility layer between client playback and external stream origins.
- According to the README, it exists to handle CORS, geo-blocking, custom headers, and anti-SSRF validation, using Node-side HTTP handling (undici).
- Architecturally, this is the main trust boundary for untrusted playlist URLs and third-party stream endpoints.
6. Authentication and session flow
- Authentication is implemented as a custom Google OAuth flow, not a generic auth framework.
- The routes under app/api/auth/ handle login initiation, OAuth callback, logout, and session lookup.
- Shared auth logic lives in app/lib/auth.ts, and app/hooks/useAuth.tsx suggests the client maintains session-aware UI state based on the server session endpoint.
7. Cloud playlist sync and persistence
- Playlist persistence is backed by Prisma and PostgreSQL, with schema defined in prisma/schema.prisma and client wiring in app/lib/prisma.ts.
- The client hook useIPTVPlaylists and the playlists API route form the data path for syncing user playlists across devices.
- The README indicates playlists may be M3U or JSON, and app/lib/playlistParser.ts is the parsing/normalization layer before data is stored or displayed.
8. Security gates around user actions
- Cloudflare Turnstile is used as an explicit anti-abuse gate, with client and server pieces in app/components/Turnstile.tsx, TurnstileGuard.tsx, and app/actions/turnstile.ts.
- This is a server action boundary rather than a purely client-side widget, which matters because verification influences sensitive operations like playlist access or submission.
- Environment variables also suggest development-origin allowlists and a disable switch for local testing.
9. Viewer tracking and analytics
- ViewerTracker.tsx and the app/api/iptv/viewers/ route indicate lightweight playback telemetry.
- Channel stats in the player UI likely consume that data to show current viewer or stream-related metrics.
- This is separate from authentication and playlist persistence: it is operational telemetry tied to playback sessions.
10. Secondary content areas
- The app is not only IPTV; it also has standalone pages for About, FAQ, Login, Dashboard, and FTP.
- The app/fixtures/ subtree is a separate feature domain with its own page, client component, hooks, types, and UI primitives for fixtures/bracket-style content.
- Because it has its own local component and utility structure, it should be diagrammed as a parallel feature area rather than part of the IPTV player core.
11. Delivery, SEO, and installability
- public/manifest.json and public/sw.js show this app is configured as a PWA with offline/install-related behavior.
- robots.ts and sitemap.ts indicate the app also has SEO-aware server routes.
- next.config.ts, Dockerfile, and Node 22.19+ support show the app is meant to be deployed as a containerized Next.js server.
12. Overall data flow
- Browser loads the Next.js app shell, renders public pages, and then hydrates client components for login, playlists, player, and tracking.
- Authenticated users exchange Google OAuth/session state with the auth API, fetch or save playlists through the IPTV API, and play channels through either direct stream URLs or the proxy endpoint.
- Persistent user data lives in PostgreSQL via Prisma; external dependencies are Google OAuth, Turnstile, and upstream stream sources/playlist URLs.
Main entry points: page.tsx Home · IPTVPlayer.tsx IPTV player · iptv IPTV API · PlaylistManagerView.tsx Playlist manager
Components 27
App shell
Route pages and shared chrome around the main app experience.
- Home · Landing page entry for the app.
app/page.tsx - About · Public about page.
app/about/page.tsx - FAQ · Public help and questions page.
app/faq/page.tsx - Dashboard · Authenticated user area.
app/dashboard/page.tsx - FTP · Separate FTP-related page.
app/ftp/page.tsx - Turnstile · Anti-abuse verification for sensitive actions.
app/components/Turnstile.tsx - Gate wrapper · Client/server wrapper around Turnstile-protected actions.
app/components/TurnstileGuard.tsx
IPTV core
Player UI, playback hooks, and IPTV-specific API boundaries.
- IPTV player · Main browser IPTV experience and orchestration layer.
app/components/IPTVPlayer.tsx - Channel list · Channel browsing and selection UI.
app/components/player/ChannelListView.tsx - Playlist manager · Playlist editing and sync UI.
app/components/player/PlaylistManagerView.tsx - Sidebar · Secondary playlist and navigation panel.
app/components/player/PlaylistSidebarView.tsx - Channel stats · Viewer and stream metrics display.
app/components/player/ChannelStats.tsx - Video view · Playback surface and stream rendering UI.
app/components/player/VideoPlayerView.tsx - useVideoPlayer · Client playback state, stream selection, and controls.
app/hooks/useVideoPlayer.ts - IPTV API · Core IPTV server boundary for channels, playlists, proxying, and viewers.
app/api/iptv - Stream proxy · Trust boundary for external stream access, CORS, and SSRF-safe fetching.
app/api/iptv/proxy/route.ts - Viewer tracker · Playback telemetry and viewer reporting.
app/components/ViewerTracker.tsx
Auth and data
Authentication, session state, playlist persistence, and parsing.
- Login · Authentication entry page.
app/login/page.tsx - useIPTVPlaylists · Client playlist fetch and sync state.
app/hooks/useIPTVPlaylists.ts - useAuth · Session-aware auth state on the client.
app/hooks/useAuth.tsx - Auth API · Google OAuth, callback, session lookup, and logout.
app/api/auth - Prisma DB · PostgreSQL access via Prisma.
app/lib/prisma.ts - Auth lib · Shared Google OAuth and session logic.
app/lib/auth.ts - Playlist parser · Parses and normalizes M3U and JSON playlist data.
app/lib/playlistParser.ts
Fixtures
Standalone fixtures/bracket feature area.
- Fixtures page · Standalone fixtures/bracket entry page.
app/fixtures/page.tsx - Fixtures client · Interactive fixtures/bracket UI coordinator.
app/fixtures/FixturesClient.tsx - useFixtures · Fixtures data loading and state.
app/fixtures/hooks/useFixtures.ts
Connections 24
- Home → IPTV player: loads · Main app shell enters the IPTV player.
- Home → About: nav · Public site content.
- Home → FAQ: nav · Public help content.
- Home → Login: auth · Login entry point.
- Home → Dashboard: nav · Authenticated surface.
- Home → FTP: nav · Adjacent standalone page.
- IPTV player → Channel list: composes · Builds the main browsing UI.
- IPTV player → Playlist manager: composes · Provides playlist controls.
- IPTV player → Sidebar: composes · Renders supporting sidebar.
- IPTV player → Channel stats: composes · Shows viewer and stream stats.
- IPTV player → Video view: composes · Embeds the playback surface.
- useVideoPlayer → Video view: drives · Coordinates player state and playback.
- useIPTVPlaylists → Playlist manager: feeds · Supplies playlist sync state.
- useAuth → Auth API: reads · Consumes session state from auth endpoints.
- Auth API → Auth lib: uses · Shared OAuth and session logic.
- IPTV API → Prisma DB: persists · Stores playlist and related data.
- IPTV API → Playlist parser: normalizes · Converts playlist input into usable records.
- IPTV API → Stream proxy: includes · Stream access boundary.
- Stream proxy → Video view: serves · Proxies external streams to the browser.
- Gate wrapper → Turnstile: wraps · Enforces verification before sensitive actions.
- Gate wrapper → Playlist manager: protects · Gates playlist-related user actions.
- Viewer tracker → IPTV API: reports · Sends playback telemetry.
- Fixtures page → Fixtures client: loads · Entrypoint for the fixtures feature.
- Fixtures client → useFixtures: uses · Fetches and manages fixtures state.