How sanjanavarade/nexora works
Project Type and Purpose
• This is a full-stack, live-streaming platform built on Next.js 14 (App Router).
• It provides public browsing (“browse”), creator dashboards (“dashboard”), auth flows, real-time chat, RTMP/WHIP ingestion, webhooks, and a Postgres + Prisma backend.
File-Structure Analysis
• Top-level “app” folder subdivided into:
– (auth): registration + sign-in pages (Server Components + layouts)
– (browse): public/home and user profile browsing UI
– (dashboard): protected creator UI (home, chat, keys)
– api/: Route Handlers for auth ([...nextauth]), webhooks, stream token & lifecycle
• “components” contains shared UI (shadcn/ui, stream-player, theme provider).
• “lib” holds backend service modules (auth-service, stream-service, user-service, follow-service, block-service, recommended-service).
• “prisma” holds schema and migrations for PostgreSQL.
• “hooks” and “store” contain client hooks for viewer tokens and sidebar state.
• Configuration: next.config.ts, middleware.ts, tailwind/postcss configs, env vars.
README Insights
• Technology stack: Next.js (frontend + API), TypeScript, Tailwind, Prisma + PostgreSQL, NextAuth, OBS → RTMP/WHIP.
• Features: live broadcasting, auth, channel mgmt, real-time chat (WebSocket/SSE ready), stream lifecycle webhooks, local tunnels (ngrok).
• Deployment: Vercel for frontend & API, optional Railway/Render/Fly.io for media server.
Main Components & Interactions
a. Client Layer
• Web Browsers: React UI (Next.js App Router)
• OBS (or WHIP-enabled client): publishes stream via RTMP/WHIP
b. Edge/API Layer (Next.js)
• Route Handlers under app/api → handle auth, stream token issuance, start/stop calls, webhooks, follow/block actions
• Server Components (layouts/pages) for auth, browse, dashboard
• Middleware for auth checks (protect dashboard routes)
c. Business-Logic Services (lib/*.ts)
• auth-service, user-service → user lookup, session mgmt (NextAuth + Prisma adapter)
• stream-service → create token, update isLive, viewers count
• block-service, follow-service, recommended-service → community features
d. Database Layer
• PostgreSQL with Prisma Client (schema.prisma) → models: User, Channel, Stream, ChatMessage, Account, Session, VerificationToken
e. Real-Time & External Services
• Media-ingest server (Node Media Server or NGINX RTMP or cloud RTMP)
• Chat transport (WebSocket or SSE channel—planned)
• Webhooks: media server calls /api/webhooks on start/stop, auth via WEBHOOK_SECRET
• Tunnels (ngrok/Cloudflared) for local testing
Architectural Patterns & Principles
• “BFF” pattern: Next.js acts as both frontend and backend for data gathering, composition, and SSR/SSR.
• App-Router grouping for layout isolation (auth vs. public vs. protected).
• Service-layer abstraction in lib/ for business rules and DB operations.
• Prisma Migrations for schema evolution.
• Environment-driven configuration for secrets, URLs, streaming endpoints.