A full-featured YouTube clone built with modern web technologies, enhanced with AI-powered features for content creation and management.
- Video Upload - Upload videos directly using Mux integration with real-time upload progress
- Video Processing - Automatic video transcoding and optimization via Mux
- Thumbnail Generation - Auto-generated thumbnails with AI-powered custom thumbnail creation
- Video Preview - Animated GIF previews for video hover states
- Subtitles - Auto-generated English subtitles for accessibility
- AI Title Generation - Automatically generate engaging video titles
- AI Description Generation - Create compelling video descriptions using AI
- AI Thumbnail Generation - Generate custom thumbnails with text prompts
- Powered by Upstash Workflow for reliable background job processing
- Authentication - Secure authentication with Clerk
- User Profiles - View user channels and their content
- Subscriptions - Subscribe to creators and manage subscriptions
- Video History - Track viewed videos
- Comments - Add, view, and manage comments on videos
- Reactions - Like and dislike videos
- View Tracking - Track video views per user
- Subscriber Counts - Real-time subscriber statistics
- Content Management - Manage all uploaded videos in one place
- Video Editor - Update title, description, category, and visibility
- Thumbnail Management - Upload custom thumbnails or restore defaults
- Analytics Dashboard - View video performance metrics
- Categories - Browse videos by category (Gaming, Music, Education, etc.)
- Visibility Controls - Set videos as public or private
- Search & Filter - Filter content with carousel-based category selection
- Next.js 15 - React framework with App Router
- TypeScript - Type-safe development
- Tailwind CSS - Utility-first styling
- shadcn/ui - Beautiful, accessible UI components
- Lucide React - Icon library
- React Hook Form - Form handling with Zod validation
- tRPC - End-to-end typesafe APIs
- Drizzle ORM - TypeScript-first ORM
- Neon Database - Serverless PostgreSQL
- Upstash Redis - Rate limiting and caching
- Upstash Workflow - Background job processing for AI features
- Mux - Video hosting, streaming, and processing
- UploadThing - File uploads for thumbnails
- Clerk - Complete user management and authentication
src/
βββ app/ # Next.js App Router pages
β βββ (auth)/ # Authentication pages (sign-in, sign-up)
β βββ (home)/ # Public-facing pages
β βββ (studio)/ # Creator studio pages
β βββ api/ # API routes (tRPC, webhooks, uploads)
βββ components/ # Shared UI components
β βββ ui/ # shadcn/ui components
βββ db/ # Database schema and connection
βββ hooks/ # Custom React hooks
βββ lib/ # Utility libraries (Mux, Redis, etc.)
βββ modules/ # Feature modules
β βββ auth/ # Authentication components
β βββ categories/ # Category management
β βββ comments/ # Comment system
β βββ home/ # Home page features
β βββ studio/ # Creator studio
β βββ subscriptions/ # Subscription management
β βββ users/ # User profiles
β βββ video-reactions/ # Like/dislike system
β βββ video-views/ # View tracking
β βββ videos/ # Video management
βββ scripts/ # Database seeding scripts
βββ trpc/ # tRPC configuration and routers
- Node.js 18+ or Bun
- PostgreSQL database (Neon recommended)
- Mux account for video processing
- Clerk account for authentication
- UploadThing account for file uploads
- Upstash account for Redis and Workflow
Create a .env.local file with the following variables:
# Database
DATABASE_URL=
# Clerk
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=
CLERK_WEBHOOK_SECRET=
# Mux
MUX_TOKEN_ID=
MUX_TOKEN_SECRET=
MUX_WEBHOOK_SECRET=
# UploadThing
UPLOADTHING_TOKEN=
# Upstash
UPSTASH_REDIS_REST_URL=
UPSTASH_REDIS_REST_TOKEN=
UPSTASH_WORKFLOW_URL=
QSTASH_TOKEN=
# OpenAI (for AI features)
OPENAI_API_KEY=# Install dependencies
bun install
# Push database schema
bun run db:push
# Seed categories
bun run db:seed
# Run development server
bun run devTo test webhooks locally, use the provided ngrok integration:
# Run both dev server and ngrok tunnel
bun run dev:all| Command | Description |
|---|---|
bun run dev |
Start development server |
bun run dev:all |
Start dev server with ngrok for webhooks |
bun run build |
Build for production |
bun run start |
Start production server |
bun run lint |
Run ESLint |
Key entities in the database:
- users - User profiles synced with Clerk
- videos - Video metadata and Mux integration
- categories - Video categories
- comments - Video comments
- subscriptions - Creator-viewer relationships
- videoViews - View tracking
- videoReactions - Like/dislike tracking
The application uses tRPC for type-safe API communication:
- videos - CRUD operations, AI generation triggers
- studio - Creator studio operations
- categories - Category listing
- comments - Comment management
- subscriptions - Subscription management
- videoViews - View tracking
- videoReactions - Reaction management
Deploy on Vercel for the best experience with Next.js:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
Built with β€οΈ using Next.js, tRPC, and AI