A modern, feature-rich YouTube clone built with Next.js, TypeScript, and Tailwind CSS. This project demonstrates the implementation of a video-sharing platform with a focus on user experience and performance.
- โ Modern and responsive UI using Tailwind CSS with mobile-first approach
- โ Server-side rendering with Next.js 15 and App Router
- โ Authentication system using Clerk for secure user management
- โ Navigation sidebar with responsive design for different screen sizes
- โ Search functionality with optimized performance
- โ Home page layout with category filtering
- โ Radix UI components integration for accessible UI elements
- โ Categories system with filtering capabilities
- โ tRPC integration for type-safe API calls between client and server
- โ Database integration with Drizzle ORM and NeonDB
- ๐ Video upload and processing with cloud storage integration
- ๐ User profiles and channels with customization options
- ๐ Video recommendations based on user preferences
- ๐ Comments and interactions with real-time updates
- ๐ Playlists management for organizing content
- ๐ Watch history tracking for personalized experience
- ๐ Subscriptions system for following creators
- ๐ Video analytics for content creators
- ๐ Advanced search with filters and sorting options
- ๐ Notifications system for user engagement
- Framework: Next.js 15 with TypeScript and App Router
- Styling: Tailwind CSS 4 with custom components
- UI Components: Radix UI (comprehensive suite of accessible components)
- Form Handling: React Hook Form with Zod validation
- State Management: React Query with tRPC
- Client Utilities:
- date-fns for date formatting
- clsx and tailwind-merge for conditional styling
- Lucide React for icons
- Embla Carousel for slider components
- API Layer: tRPC for end-to-end typesafe APIs
- Authentication: Clerk for user management
- Database: Drizzle ORM with NeonDB (PostgreSQL)
- Caching: Upstash Redis
- Rate Limiting: Upstash Rate Limit
- Package Manager: Bun (with npm compatibility)
- Deployment: Netlify with continuous integration
- Development Tools: Turbopack for fast refresh
โโโ src/
โ โโโ app/ # Next.js app directory with App Router
โ โ โโโ (auth)/ # Authentication routes
โ โ โโโ (home)/ # Home page routes
โ โ โโโ api/ # API routes
โ โ โโโ globals.css # Global styles
โ โ โโโ layout.tsx # Root layout component
โ โโโ components/ # Reusable UI components
โ โ โโโ ui/ # Base UI components
โ โ โโโ filter-carousel.tsx # Category filter component
โ โโโ db/ # Database configuration
โ โ โโโ index.ts # Database connection
โ โ โโโ schema.ts # Database schema
โ โโโ hooks/ # Custom React hooks
โ โโโ lib/ # Utility functions and configurations
โ โ โโโ ratelimit.ts # Rate limiting configuration
โ โ โโโ redis.ts # Redis configuration
โ โ โโโ utils.ts # Utility functions
โ โโโ middleware.ts # Next.js middleware
โ โโโ modules/ # Feature-based modules
โ โ โโโ auth/ # Authentication module
โ โ โโโ categories/ # Categories module
โ โ โโโ home/ # Home page module
โ โโโ providers/ # React context providers
โ โโโ scripts/ # Utility scripts
โ โ โโโ seed-categories.ts # Database seeding
โ โโโ trpc/ # tRPC configuration
โ โโโ client.tsx # Client-side tRPC setup
โ โโโ init.ts # tRPC initialization
โ โโโ query-client.ts # React Query client
โ โโโ routers/ # tRPC routers
โ โโโ server.tsx # Server-side tRPC setup
โโโ public/ # Static assets
โโโ config files # Various configuration files
-
Clone the repository
git clone [repository-url] cd youtube-clone
-
Install dependencies
bun install # or npm install
-
Set up environment variables Create a
.env.local
file in the root directory with the following variables:# Clerk Authentication NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key CLERK_SECRET_KEY=your_clerk_secret_key # Database DATABASE_URL=your_neondb_connection_string # Redis UPSTASH_REDIS_REST_URL=your_upstash_redis_url UPSTASH_REDIS_REST_TOKEN=your_upstash_redis_token
-
Seed the database
bun seed # or npm run seed
-
Run the development server
bun dev # or npm run dev
-
Open http://localhost:3000 in your browser
- Development Mode:
bun dev
ornpm run dev
- Development with Webhook:
bun run dev:all
(runs both dev server and ngrok webhook) - Build:
bun build
ornpm run build
- Production:
bun start
ornpm start
- Linting:
bun lint
ornpm run lint
- Database Seeding:
bun seed
ornpm run seed
The project follows a modular architecture with feature-based organization:
- App Router: Utilizes Next.js 15 App Router for page routing
- tRPC: Provides type-safe API communication between client and server
- Modules: Features are organized into self-contained modules
- Components: Reusable UI components built with Radix UI and Tailwind
- Create a modern and performant video-sharing platform
- Implement industry best practices for scalability
- Provide a seamless user experience across devices
- Demonstrate advanced Next.js and React patterns
- Build a fully accessible application following WCAG guidelines
- Optimize for performance with efficient data fetching and rendering
- Unit testing implementation planned with Vitest
- E2E testing with Cypress planned
- Component testing with React Testing Library planned
- Performance testing with Lighthouse planned
- Mobile-first approach with adaptive layouts
- Responsive navigation with collapsible sidebar
- Adaptive video player for different screen sizes
- Cross-browser compatibility testing
- Touch-friendly interactions for mobile devices
- Authentication with Clerk for secure user management
- Protected API routes with proper authorization
- Input validation with Zod schema validation
- CSRF protection for form submissions
- Rate limiting with Upstash Rate Limit
- Secure environment variable handling
- Server-side rendering for improved initial load
- Image optimization with Next.js Image component
- Code splitting and lazy loading
- Efficient data fetching with React Query
- Caching strategies with Redis
- Bundle size optimization
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Built with โค๏ธ using Next.js and TypeScript