A full-featured video streaming platform built with modern web technologies and cloud infrastructure, enabling users to upload, process, and stream videos with adaptive bitrate streaming.
- Video Upload & Processing: Secure video upload to AWS S3 with automated processing pipeline
- Adaptive Bitrate Streaming: HLS (HTTP Live Streaming) with multiple quality options (360p, 720p, 1080p)
- Real-time Video Player: Custom HLS player with quality selection and buffering management
- Content Management: Admin dashboard for video management and user approval
- Cloud Infrastructure: AWS Lambda-based serverless video processing
- Queue Management: Redis-based job queuing for video processing tasks
- CDN Integration: CloudFront distribution for optimized content delivery
- File Size Validation: Client and server-side file size validation
- Presigned URLs: Secure direct-to-S3 uploads with temporary access
- Retry Logic: Automated retry mechanisms for failed video processing
This platform enables content creators to upload videos, which are then automatically processed, transcoded into multiple resolutions, and made available for streaming with adaptive bitrate technology. The application ensures high-quality video playback regardless of the viewer's network conditions.
The system uses a queue-based architecture to handle video processing asynchronously, ensuring scalability and reliability even with large video files and high traffic.
The application follows a modern microservice-oriented architecture:
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Frontend ββββββΆβ API ββββββΆβ Database β
β (React) βββββββ (Express) βββββββ (PostgreSQL)β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β β²
β β
βΌ β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β S3 Storage ββββββΆβ Video Queue ββββββΆβ Video β
β (AWS) β β (Redis) β β Processing β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
- Frontend: React application with TypeScript, using Zustand for state management
- Backend API: Express.js server handling authentication, content management
- Database: PostgreSQL with Prisma ORM
- Queuing System: Redis-based message queues for video processing jobs
- Storage: AWS S3 buckets for video files and processed content
- Processing Pipeline: FFmpeg-based video transcoding microservice
-
Frontend:
- React 18
- TypeScript
- Zustand (State Management)
- TailwindCSS + ShadCN UI
- Video.js (Player)
-
Backend:
- Node.js with Express
- PostgreSQL with Prisma ORM
- Redis for queuing
- JWT for authentication
- Serverless functions for processing
-
Cloud & Infrastructure:
- AWS S3 for storage
- AWS Lambda for serverless functions
- CDN for content delivery
-
Video Processing:
- FFmpeg for transcoding
- HLS (HTTP Live Streaming) protocol
- Node.js (v18+)
- PostgreSQL
- Redis
- AWS Account with S3 access
- FFmpeg (for local development)
-
Clone the repository:
git clone https://github.com/MrPurushotam/content-streaming.git cd livestreaming-application
-
Install dependencies for the backend:
cd backend npm install
-
Set up environment variables (create
.env
file):DATABASE_URL=postgresql://user:password@localhost:5432/videodb AIVEN_REDIS_URL=redis://localhost:6379 AIVEN_REDIS_PASSWORD=your_redis_password AWS_REGION=us-east-1 AWS_ACCESS_KEY_ID=your_access_key AWS_SECRET_ACCESS_KEY=your_secret_key AWS_S3_PRIMARYBUCKET_NAME=your-primary-bucket AWS_S3_SECONDARYBUCKET_NAME=your-secondary-bucket JWT_SECRET=your_jwt_secret FRONTEND_URL=http://localhost:5173 CDN_BASE_URL=https://your-cdn-url.com VIDEO_PROCESSING_FUNCTION_URL=http://localhost:3001 S3CLEANUP_FUNCTION_URL=http://localhost:3002
-
Start the backend server:
npm run dev
-
Install dependencies for the frontend:
cd ../frontend npm install
-
Set up environment variables (create
.env
file):VITE_API_URL=http://localhost:3000/api/v1
-
Start the frontend development server:
npm run dev
-
Install dependencies for the video processing service:
cd ../backend/pipeline/VideoProcessing npm install
-
Create a
.env
file with the same variables as the backend. -
Start the video processing service:
npm run dev
-
Install dependencies for the S3 cleanup service:
cd ../S3Cleanup npm install
-
Create a
.env
file with the same variables as the backend. -
Start the S3 cleanup service:
npm run dev
The application uses Prisma ORM with a PostgreSQL database. The schema is defined in:
/Packages/CustomPrismaPackage/prisma/schema.prisma
Key entities include:
User
: Stores user information and authentication detailsContent
: Represents uploaded videos with metadataBiteRateVideo
: Tracks different resolution versions of videosVideoSourceInfo
: Manages the original video source information
The application uses two S3 buckets:
- Primary Bucket: For initial video uploads (temporary storage)
- Secondary Bucket: For processed videos and HLS content (permanent storage)
The application uses Redis for message queues:
ffmpeg_queue
: Video processing jobsprimary_bucket_queue
: S3 cleanup jobs
-
Registration & Login:
- Create an account with email and password
- Admin users require approval before posting content
-
Uploading Videos:
- Navigate to the upload page
- Get a presigned URL for S3 upload
- Upload video directly to S3
- Add metadata (title, description, thumbnail)
- Submit for processing
-
Processing:
- Video is queued for processing
- FFmpeg transcodes video to multiple resolutions
- HLS playlists and segments are created
- Processed files are stored in S3
-
Viewing Content:
- Browse videos on the homepage
- Click to view a video
- Video player automatically selects the appropriate resolution based on bandwidth
-
User Management:
- Approve or reject new admin users
- Manage existing users
-
Content Management:
- Review uploaded content
- Delete inappropriate content
- Edit video metadata
livestreaming-application/
βββ backend/
β βββ libs/ # Shared libraries (AWS, etc.)
β βββ middleware/ # Express middleware
β βββ pipeline/ # Video processing services
β β βββ VideoProcessing/ # FFmpeg transcoding service
β β βββ S3Cleanup/ # S3 cleanup service
β βββ prisma/ # Database schema and migrations
β βββ routes/ # API routes
β βββ utils/ # Utility functions
βββ frontend/
β βββ public/ # Static assets
β βββ src/
β βββ components/ # Reusable UI components
β βββ pages/ # Page components
β βββ store/ # Zustand store
β βββ utils/ # Utility functions
βββ Packages/
βββ CustomPrismaPackage/ # Shared Prisma client package
- Frontend: Follow React best practices, use TypeScript for type safety
- Backend: Use Express middleware for authentication, validation
- Database: Use Prisma migrations for schema changes
- Testing: Write unit tests for critical components
The backend is designed to be deployed as serverless functions:
-
API Server:
- Deploy as an AWS Lambda function
- Configure with API Gateway
-
Video Processing:
- Deploy as a separate AWS Lambda function
- Configure with higher memory and longer timeout
-
S3 Cleanup:
- Deploy as a scheduled AWS Lambda function
- Configure to run periodically
-
Build the frontend:
cd frontend npm run build
-
Deploy the built assets to a static hosting service (AWS S3, Vercel, Netlify)
POST /auth/register
- User registrationPOST /auth/login
- User loginGET /auth/verify
- Token verification
GET /video/
- Get all public videosGET /video/:id
- Get specific videoPUT /video/view/:id
- Increment view countPOST /content/metadata
- Upload video metadataPOST /content/confirmsource
- Confirm video uploadGET /content/status/:id
- Get processing status
GET /user/uploads
- Get user's uploaded videosPUT /video/:id
- Update video detailsDELETE /video/:id
- Delete videoGET /user/list/admin
- Get pending admin approvals
- Upload Request: Client requests presigned URL
- Direct Upload: Video uploaded directly to S3 primary bucket
- Queue Processing: Video processing job added to Redis queue
- Lambda Processing: FFmpeg processes video into multiple bitrates
- HLS Generation: Creates master playlist and segment files
- S3 Storage: Processed files stored in secondary bucket
- Database Update: Video status updated to "published"
- CDN Distribution: Content available via CloudFront
- Video Files: 100MB maximum
- Thumbnail Images: 5MB maximum
- Supported Formats: MP4, MOV, AVI (video) / JPG, PNG, WEBP (thumbnails)
The application automatically generates three quality levels:
- 360p: 640x360, 800k bitrate
- 720p: 1280x720, 2.5M bitrate
- 1080p: 1920x1080, 5M bitrate
- JWT-based authentication
- Admin role-based access control
- Rate limiting on API endpoints
- File type and size validation
- CORS protection
- Presigned URL expiration (3 hours)
The application is fully responsive and optimized for:
- Desktop browsers
- Tablet devices
- Mobile phones
- Touch interactions
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the ISC License.
Built by Purushotam Jeswani
- GitHub: @MrPurushotam
- LinkedIn: purushotamjeswani
- Email: work.purushotam@gmail.com
- FFmpeg for video transcoding
- React and Express teams for the excellent frameworks
- Video.js for the player implementation