A backend service built with Node.js, Express, and MongoDB. This project provides an API for managing users, videos, playlists, comments, likes, subscriptions, and tweets.
Mentor : Hitesh Choudhary
Feel free to test this application and if you want to build the frontend upon it you can use this backend, Incase if you find any bug or something just rise a issue and if you want to contribute just pull a request I will be excited to merge your pull.
- User Management: Allows users to register, login, manage their profile, and keep a watch history.
- Video Management: Users can upload videos, add metadata like title and description, and track views.
- Playlists: Users can create and manage playlists containing multiple videos.
- Comments and Likes: Users can comment on videos and like both videos and tweets.
- Subscriptions: Allows users to subscribe to other users’ channels.
- Tweets: Users can post tweets associated with their profile.
Here’s an overview of the main database models:
Field | Type | Description |
---|---|---|
_id |
ObjectId | Primary key |
username |
String | Unique username |
email |
String | Unique email |
fullName |
String | Full name of the user |
avatar |
String | URL of user’s avatar |
coverImage |
String | URL of cover image |
password |
String | Hashed password |
refreshToken |
String | Refresh token for sessions |
watchHistory |
[ObjectId] | Array of video IDs watched |
createdAt |
Date | Account creation date |
updatedAt |
Date | Profile update date |
Field | Type | Description |
---|---|---|
_id |
ObjectId | Primary key |
videoFile |
String | URL of the video file |
thumbnail |
String | URL of the thumbnail image |
owner |
ObjectId | User ID of the video owner |
title |
String | Title of the video |
description |
String | Description of the video |
duration |
Number | Duration of the video in seconds |
views |
Number | Number of views |
isPublished |
Boolean | Published status |
createdAt |
Date | Date of upload |
updatedAt |
Date | Last updated date |
Field | Type | Description |
---|---|---|
_id |
ObjectId | Primary key |
name |
String | Name of the playlist |
description |
String | Description of the playlist |
owner |
ObjectId | User ID of the playlist owner |
videos |
[ObjectId] | Array of video IDs in playlist |
createdAt |
Date | Date of creation |
updatedAt |
Date | Last updated date |
Field | Type | Description |
---|---|---|
_id |
ObjectId | Primary key |
content |
String | Content of the comment |
video |
ObjectId | ID of the related video |
owner |
ObjectId | User ID of the commenter |
createdAt |
Date | Date of comment |
updatedAt |
Date | Last updated date |
Field | Type | Description |
---|---|---|
_id |
ObjectId | Primary key |
comment |
ObjectId | ID of the liked comment |
video |
ObjectId | ID of the liked video |
tweet |
ObjectId | ID of the liked tweet |
likedBy |
ObjectId | User ID of the liker |
createdAt |
Date | Date of like |
Field | Type | Description |
---|---|---|
_id |
ObjectId | Primary key |
owner |
ObjectId | User ID of the tweet poster |
content |
String | Content of the tweet |
createdAt |
Date | Date of tweet |
updatedAt |
Date | Last updated date |
Field | Type | Description |
---|---|---|
_id |
ObjectId | Primary key |
subscriber |
ObjectId | User ID of the subscriber |
channel |
ObjectId | ID of the subscribed channel |
createdAt |
Date | Subscription date |
updatedAt |
Date | Last updated date |
-
Clone the repository:
git clone https://github.com/Sourav0010/videotube-backend.git cd youtube-backend
-
Install dependencies:
npm i
-
Configure environment variables:
- Create a
.env
file based on the.env.example
template. - Set up your MongoDB URI and other necessary configurations.
- Create a
-
Start the server:
npm run dev
https://videotube-backend-vevz.onrender.com
POST /api/v1/users/signup
: Register a new userPOST /api/v1/users/login
: Login an existing userGET /api/v1/users/getuser
: Get current loggined user detailsPOST /api/v1/users/logout
: Logout userPOST /api/v1/users/refresh-token
: refresh user tokenPOST /api/v1/users/c/:channelId
: get Subscriber count of a channelPOST /api/v1/users/delete-user
: Delete User Account
POST /api/v1/videos/
: Upload a new videoGET /api/v1/videos/
: Retrieve all videosGET /api/videos/:videoId
: Get a perticular video detailsDELETE /api/v1/videos/:videoId
: Delete a videoPATCH /api/v1/videos/toggle/publish/:videoId
: Toggle Publish Status Of A Video
POST /api/v1/subscriptions/c/:channelId
: Subscribe/Unsubscribe ChannelGET /api/v1/subscriptions/c/:channelId
: Get subscriber list of a channelGET /api/v1/subscriptions/u/:subscriberId
: Get channel list to which user has subscribed
POST /api/v1/tweets/
: Create TweetGET /api/v1/tweets/user/:userId
: Get User TweetsPATCH /api/v1/tweets/:tweetId
: Update TweetDELETE /api/v1/tweets/:tweetId
: Delete Tweet
POST /api/v1/playlists/
: Create a playlistGET /api/v1/playlists/:playlistId
: Get Playlist by IDPATCH /api/v1/playlists/:playlistId
: Update Playlist details by IDDELETE /api/v1/playlists/:playlistId
: Delete Playlist by IDPATCH /api/v1/playlists/add/:videoId/:playlistId
: Add video to a playlistPATCH /api/v1/playlists/remove/:videoId/:playlistId
: Remove a video from the playlistGET /api/v1/playlists/user/:userId
: Get Playlists Created by user
POST /api/v1/comments/:videoId
: Create a commentGET /api/v1/comments/:videoId
: Get all comments of a videoPATCH /api/v1/comments/c/:commentId
: Update CommentDELETE /api/v1/comments/c/:commentId
: Delete Comment
POST /api/v1/likes/toggle/v/:videoId
: Toggle Video LikePOST /api/v1/likes/toggle/c/:commentId
: Toggle Comment LikePOST /api/v1/likes/toggle/t/:tweetId
: Toggle Tweet LikeGET /api/v1/likes/videos
: Get All Liked Video
- Backend: Node.js, Express
- Database: MongoDB
- Authentication: JWT
- Other: Mongoose for MongoDB ORM , Cloudinary for ODM
Thanks You ~ Sourav Mohanty