A self-hosted video distribution and streaming platform similar to YouTube, built with modern web technologies and designed for creators and viewers to upload, manage, and stream videos using HLS (HTTP Live Streaming).
- π₯ Video Upload & Processing: Upload videos with automatic transcoding to HLS format
- π± Adaptive Streaming: HLS.js powered video player with quality selection
- π Authentication: JWT + Google OAuth2 login system
- π₯ User Management: Creator and viewer roles with subscriptions
- π Video Catalog: Search, browse, and discover videos
- π¬ Interactive Features: Comments, likes, and view tracking
- π Analytics Dashboard: Creator analytics and insights
- π³ Containerized: Full Docker setup for easy deployment
- Next.js 14 - React framework with App Router
- TypeScript - Type safety
- Tailwind CSS - Utility-first styling
- Radix UI - Headless UI components
- HLS.js - HTML5 video streaming
- Sonner - Toast notifications
- Express.js - Node.js web framework
- MongoDB - Document database with Mongoose ODM (using remote instance to reduce load on local machine)
- Redis - Caching and session storage (using remote instance to reduce load on local machine)
- Passport.js - Authentication middleware
- JWT - Token-based authentication
- Multer - File upload handling
- Docker & Docker Compose - Containerization
- NGINX - Reverse proxy
- FFmpeg - Video transcoding and processing (in API service)
- Cloudflare R2 - Object storage for videos and media (S3-compatible)
- Turborepo - Monorepo build system
- pnpm - Fast package manager
- ESLint & Prettier - Code quality and formatting
- Jest - Testing framework
ciihu/
βββ apps/
β βββ api/ # Express.js backend
β βββ web/ # Next.js frontend
βββ packages/
β βββ shared-types/ # TypeScript type definitions
β βββ ui/ # Shared UI components
β βββ logger/ # Logging utilities
β βββ eslint-config/ # ESLint configurations
βββ docker/
β βββ nginx/ # Reverse proxy config
β βββ ffmpeg/ # Video processing scripts
βββ docker-compose.yml # Container orchestration
- Node.js 18+ and pnpm
- Docker and Docker Compose
- FFmpeg (for video processing)
- Remote MongoDB instance (MongoDB Atlas, self-hosted, etc.)
- Remote Redis instance (Redis Cloud, self-hosted, etc.)
-
Clone the repository
git clone <repository-url> cd ciihu
-
Install dependencies
pnpm install
-
Set up environment variables
# Copy example environment files cp apps/api/.env.example apps/api/.env cp apps/web/.env.example apps/web/.envImportant Configuration Required:
- Configure your remote MongoDB connection in
apps/api/.env(MONGODB_URI) - Configure your remote Redis connection in
apps/api/.env(REDIS_URL) - Configure Cloudflare R2 storage credentials. See R2_STORAGE_SETUP.md for instructions.
- Configure your remote MongoDB connection in
-
Start the development environment
# Start all services with Docker docker-compose up -d # Or for development without Docker pnpm dev
-
Access the application
- Frontend: http://localhost:3000
- API: http://localhost:5001
- Sign up and enable creator mode in your profile
- Upload videos through the upload interface
- Manage content via the creator dashboard
- View analytics and engagement metrics
- Browse videos on the homepage
- Search and filter content
- Subscribe to creators you like
- Interact with likes and comments
POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/google- Google OAuth loginPOST /api/auth/refresh- Refresh access token
GET /api/videos- Search and browse videosGET /api/videos/:id- Get video detailsPOST /api/videos/:id/like- Like/dislike videoGET /api/videos/:id/comments- Get video comments
POST /api/upload/presigned-url- Get upload URLPOST /api/upload/video- Create video record
GET /api/users/:id- Get user profilePOST /api/users/:id/subscribe- Subscribe to user
The application includes a complete Docker setup for production deployment:
# Production deployment
docker-compose -f docker-compose.yml up -d
# View logs
docker-compose logs -f
# Scale services
docker-compose up -d --scale api=2- NGINX - Reverse proxy
- API - Express.js backend (includes FFmpeg video processing)
- Web - Next.js frontend
Note: MongoDB and Redis must be configured as remote instances. See environment configuration section for setup.
This application uses Cloudflare R2 for object storage. Before deployment:
- Set up a Cloudflare R2 bucket
- Configure the required environment variables
- See R2_STORAGE_SETUP.md for detailed setup instructions
Note: All video files (uploads, processed videos, thumbnails) are stored in R2, not in local volumes.
# Development
pnpm dev # Start all apps in development mode
pnpm build # Build all apps for production
pnpm test # Run tests across all packages
pnpm lint # Lint all packages
pnpm format # Format code with Prettier
# Package management
pnpm add <package> --filter=web # Add dependency to web app
pnpm add <package> --filter=api # Add dependency to API- Shared types: Add to
packages/shared-types - UI components: Add to
packages/ui - API routes: Add to
apps/api/src/routes - Frontend pages: Add to
apps/web/src/app
MongoDB indexes are automatically created on startup. For schema changes:
- Update models in
apps/api/src/models - Update types in
packages/shared-types - Add migration script if needed
- NGINX caching for static assets and HLS segments
- Redis caching for frequently accessed data
- CDN integration ready (Cloudflare)
- Database indexing for optimal query performance
- Rate limiting on API endpoints
- CORS protection
- Helmet.js security headers
- JWT token rotation
- Input validation with Joi
- Structured logging with Winston
- Health check endpoints /status & /message/jared
- Error tracking ready for Sentry integration
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make changes and add tests
- Commit:
git commit -m 'Add amazing feature' - Push:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Check this README, .docs folder, and code comments
- Issues: Open a GitHub issue for bugs or feature requests
- Discussions: Use GitHub Discussions for questions
Built with β€οΈ using modern web technologies for the creator economy.