VidVerse is a backend application for a video-sharing platform that enables users to upload, share, and interact with video content. It incorporates secure user authentication, media storage on Cloudinary, and token-based access control.
- User authentication and authorization (JWT-based)
- Media file uploads (Images, Videos) using Cloudinary
- Watch history tracking
- Subscription system for channels
- Password management (Change/Update)
- Secure cookie handling (Access and Refresh tokens)
- User profile updates including avatars and cover images
- Backend: Node.js, Express.js
- Database: MongoDB, Mongoose
- Authentication: JWT (JSON Web Tokens)
- File Storage: Cloudinary, Multer
- Environment Management: dotenv
- Other Libraries: bcrypt, jsonwebtoken, cookie-parser, validator
-
Clone the repository:
git clone https://github.com/Deepika0701/VidVerse.git
-
Navigate to the project directory:
cd VidVerse -
Install dependencies:
npm install
-
Create a
.envfile in the root directory and provide the following environment variables:MONGO_URI=your_mongo_database_uri JWT_SECRET=your_jwt_secret REFRESH_TOKEN_SECRET=your_refresh_token_secret CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name CLOUDINARY_API_KEY=your_cloudinary_api_key CLOUDINARY_API_SECRET=your_cloudinary_api_secret
-
Start the development server:
npm run dev
- Register as a new user and log in using your credentials.
- Upload videos, update your profile, and manage your channel.
- Subscribe to other users' channels and keep track of your watch history.
- POST /api/auth/register: Register a new user.
- POST /api/auth/login: Log in with email/username and password.
- POST /api/auth/refresh: Get a new access token using a refresh token.
- POST /api/auth/logout: Log out a user.
- GET /api/users/me: Get the current logged-in user's profile.
- PATCH /api/users/me: Update account details.
- PATCH /api/users/avatar: Update user avatar.
- PATCH /api/users/cover-image: Update cover image.
- GET /api/channels/:username: Get user channel profile by username.
- GET /api/users/watch-history: Fetch user's video watch history.
VidVerse uses JWT-based authentication, with tokens passed via cookies. The system uses access tokens for short-lived sessions and refresh tokens for renewing expired access tokens without requiring re-login.
- On login, an
accessTokenandrefreshTokenare generated and stored as HTTP-only cookies. - The
accessTokenis used for authenticating API requests. - If the
accessTokenexpires, therefreshTokenis used to obtain a new one by hitting the/api/auth/refreshendpoint.
- Fork the repository.
- Create your feature branch:
git checkout -b feature/my-feature
- Commit your changes:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature/my-feature
- Open a pull request.