Backend Video Streaming Project - Model Link
Table of Contents
Overview
This project is a backend system for a YouTube-like application that supports user registration, login, and logout functionalities. As development progresses, more features like video uploading, comments, likes, and subscriptions are being added.
Features
User Management:
Registration, login, logout, change password
Profile management (avatar, cover image, other details)
Watch history tracking and Clearing Watch History
Liked videos tracking
Seeding:
Seed Random Users with Dummy information
Get Seeded Informaiton of the Pre-seeded users.
Seed user with @faker-js.
Video Management:
Video upload
Canceling Video upload with all resources cleaned up on backend.
Visibility control (publish/un-publish)
Video editing and deletion
Video Search and pagination
Tweet creation and publishing
Viewing user tweets
Updating and deleting tweets
Liking-disliking tweets
Subscription Management:
Subscribing to channels
Viewing Channel subscriber
Viewing Subscribed channel lists
Playlist Management:
Creating, updating, and deleting playlists
Adding videos to playlists
Removing videos from playlists and undoing them
Viewing user playlists
Like Management:
Liking and Un-liking videos, comments, and tweets
Viewing liked videos
Adding, updating, and deleting comments on videos
Dashboard:
Viewing channel statistics (views, subscribers, videos, likes)
Accessing uploaded videos and Controls
Viewing Video statistics (PublishStatus, VideoName, DateUploaded, Views, TotalComments, LikeRatings)
Health Check:
Endpoint to verify the server's health
Technologies Used
Backend Framework: Node.js with Express
Database: MongoDB with Mongoose
Authentication: JSON Web Token (JWT)
Message Broker (for future features): RabbitMQ
File Storage: (e.g., cloudinary, local storage, etc.)
Containerization: (for future features) Docker (for RabbitMQ and other services)
Installation
Method 1: Docker-compose.yml
Clone the repository then do:
Method 2: Manual
Clone the repository:
Copy git clone git@github.com:Barmanji/Youtube-and-Twitter-Compelete-Backend.git
cd Youtube-and-Twitter-Compelete-Backend
Install dependencies:
Set up environment variables:
Create a .env file in the root of your project and add the following OR Change .env.example -> .env
Copy PORT = 8000
ORIGIN_KEY_CORS = *
MONGODB_URI = MAKE_IT_YOUR_OWN_ALSO_DONT_AND_I_MEAN_IT_DONT_PUT_@_IN_PASS_SPECIALLY_IN_THE_END
ACCESS_TOKEN_SECERET = Your ACCESS_TOKEN_SECERET
ACCESS_TOKEN_EXPIRY = Your ACCESS_TOKEN_EXPIRY
REFRESH_TOKEN_SECERET = Your REFRESH_TOKEN_SECERET
REFRESH_TOKEN_EXPIRY = Your REFRESH_TOKEN_EXPIRY //use numbers like 10d === 10days
CLOUDNARY_APISECRET = Your_Api_Seceret-from-Cloudinary
CLOUDNARY_APIKEY = Your_Api_Key-from-Cloudinary
CLOUDNARY_CLOUDNAME = Your-Cloud-name
Start the server:
Running the Project
Once you have completed the setup, you can run the project using:
This will start the server, and the application will be available on http://localhost:8000.
User
Method Endpoint Description Protected POST /api/v1/user/registerRegister a new user No POST /api/v1/user/loginLogin and get token No POST /api/v1/user/logoutLogout user Yes GET /api/v1/user/refresh-tokenEndPoint to Refresh all Tokens Yes POST /api/v1/user/change-passwordChange password from old to new Yes GET /api/v1/user/current-userGive login user details Yes PATCH /api/v1/user/update-accountUpdate user fullname and email Yes PATCH /api/v1/user/avatarChange Avatar of the Login user Yes PATCH /api/v1/user/cover-imageChange Cover Image of the Login user Yes GET /api/v1/user/c/:usernameGive channel details like subcribers and all Yes GET /api/v1/user/historyGive watchHistory of login user Yes
Dashboard
Method Endpoint Description Protected POST /api/v1/user/seedSeed the database with dummy users. No GET /api/v1/user/seed-credentialsGet the credentials of the seeded users. No
Videos
Method Endpoint Description Protected POST /api/v1/videos/Upload a video Yes GET /api/v1/videos/Get videos by search Yes GET /api/v1/videos/:videoIdGet a specific video by its ID Yes DELETE /api/v1/videos/:videoIdDelete a video by its ID Yes PATCH /api/v1/videos/:videoIdUpdate video details Yes PATCH /api/v1/videos/toggle/publish:videoIdToggle publish status Yes
Method Endpoint Description Protected POST /api/v1/comments/:videoIdPost a comment on a video Yes GET /api/v1/comments/:videoIdGet comments for a specific video Yes DELETE /api/v1/comments/c/:commentIdDelete comments through Id Yes PATCH /api/v1/comments/c/:commentIdUpdate comment through Id Yes
like
Method Endpoint Description Protected POST /api/v1/likes/toggle/v/:videoIdtoggle like of video Yes POST /api/v1/likes/toggle/c/:commentIdtoggle like of comment Yes POST /api/v1/likes/toggle/t/:tweetIdtoggle like of tweet Yes GET /api/v1/likes/videosGet all the Likes of video Yes
Method Endpoint Description Protected POST /api/v1/tweets/Create tweet Yes GET /api/v1/tweets/user/:userIdGet User tweet Yes PATCH /api/v1/tweets/:tweetIdupdate tweet Yes DELETE /api/v1/tweets/:tweetIddelete the Tweet Yes
PlaylistRouter
Method Endpoint Description Protected POST /api/v1/playlist/Create Playlist Yes GET /api/v1/playlist/:playlistIdGet Playlist By Id Yes PATCH /api/v1/playlist/:playlistIdUpdate Playlist Yes DELETE /api/v1/playlist/:playlistIddelete the Playlist Yes PATCH /api/v1/playlist/add/:videoId/:playlistIdAdd video to playlist Playlist Yes PATCH /api/v1/playlist/remove/:videoId/:playlistIdRemove video to playlist Yes GET /api/v1/playlist/user/:userIdGet Playlist of a user Yes
Dashboard
Method Endpoint Description Protected GET /api/v1/dashboard/statsGet channel details Yes GET /api/v1/dashboard/videosGet Video upload by channel Yes
Subscriptions
Method Endpoint Description Protected POST /api/v1/subscriptions/c/:channelIdToggle Subscription to channel Yes GET /api/v1/subscriptions/c/:channelIdGot Subsbcriber list of channel Yes GET /api/v1/subscriptions/u/:subscriberIdsubscriber list of a User channel Yes
HealthCheck
Method Endpoint Description Protected GET /api/v1/healthcheckGet Health Status Yes
Future Improvements
Video Recommendations: Recommend videos based on user preferences.
Analytics: Track views and other engagement metrics.
Notifications: Real-time notifications for new comments, likes, and subscriptions.
Microservices Architecture: Plan to scale the application by breaking features into microservices.
CI/CD: Set up automated testing and deployment pipelines.
Liscense
Project is Liscensed under ChaiAurCode