How qkeluna/screen_recording_sharing_app works
Project Type and Purpose
• This is a full-stack Next.js application that lets users record their screen, upload videos, view AI transcripts, and share videos via unique links.
• Key characteristics: React UI (App Router), server-side logic (API routes), database integration (Xata + Drizzle ORM), video storage & streaming (Bunny.net), authentication (Better Auth + Google), and security middleware (Arcjet).
File Structure
• app/ – Next.js App Router structure with UI pages and server components:
• (auth) sign-in pages
• (root) main pages: profile, upload, video
• app/api/auth/ – API routes for authentication
• components/ – reusable UI pieces (Navbar, VideoPlayer, etc.)
• lib/ – client-side utilities and actions (file input, screen recording, video API calls)
• drizzle/ – migrations and schema using Drizzle ORM
• .xata, src/xata.ts – Xata DB configuration for storing video metadata
• middleware.ts and lib/arcjet.ts – Arcjet security layer for rate-limiting & bot protection
• next.config.ts, tailwind & postcss configs – build/deploy settings
README for Architectural Insights
• Tech stack calls out: Next.js (UI & server), Tailwind CSS (styling), Better Auth + Google (auth), Arcjet (security), Bunny.net (video CDN), Xata (database), Drizzle ORM (type-safe SQL).
Main Components
a. Frontend (Browser)
• Next.js React pages & components under app/ & components/
• Tailwind-styled UI, client-side hooks (useFileInput, useScreenRecording)
b. Backend / BFF Layer (Next.js Server)
• App Router server components (data fetching)
• API Routes: /api/auth/ for login, custom video upload endpoint (lib/actions/video.ts)
• Middleware (middleware.ts) invoking Arcjet for request filtering
c. Database
• Xata (serverless PostgreSQL) for storing users & video metadata (configured in xata.ts)
• Drizzle ORM used for migrations and type-safe queries against Postgres (drizzle folder)
d. Video Storage & Delivery
• Bunny.net edge storage & CDN for raw video files and adaptive streaming
• Bunny.net API called by server endpoints to upload and retrieve video URLs
e. Authentication & Security
• Better Auth (external auth service) + Google OAuth
• Arcjet for bot protection, rate limiting, and attack mitigation
f. External Services
• Google OAuth endpoints
• AI transcript service (if present)
• Discord link & other ancillary services (optional)
Relationships and Data Flow
1. User → Browser UI → Next.js Server (SSR or API call)
2. Next.js Server → Arcjet middleware → API route logic
3. Authentication flow:
• Browser calls /api/auth/[...all]/route.ts → Better Auth / Google → session cookie
4. Screen Recording & Upload:
• Client hook captures video → lib/actions/video.ts → POST to Next.js upload endpoint → Bunny.net storage → Next.js writes metadata to Xata DB via Xata SDK (or Drizzle)
5. Video Retrieval:
• Client navigates to /video/[videoId] → Next.js server component fetches metadata from Xata → retrieves streaming URL from Bunny.net → renders VideoPlayer
6. Search & Profile:
• Client calls server components or API to query Xata DB for search results or user’s video list
Architectural Patterns and Design Principles
• BFF (Backend-for-Frontend): Next.js API routes act as a tailored backend layer
• Server Components vs. Client Components (Next.js App Router)
• Type-safe database interactions (Drizzle ORM + Xata SDK)
• Separation of concerns: UI, business logic (lib/actions), data layer, external services
• Incremental Static Regeneration / SSR for video pages (leveraging Next.js performance)