This repository contains the backend code for a video-sharing and social media platform.
It is built with Node.js, Express.js, and MongoDB, and provides RESTful APIs for user management, video uploads, comments, likes, playlists, subscriptions, tweets, and email validation.
- User Management – Registration, authentication (JWT), profile management
- Video Uploads – Upload, stream, and manage videos (Multer + Cloudinary)
- Comments & Likes – Add comments and likes to videos
- Playlists – Create and manage playlists
- Subscriptions – Subscribe/unsubscribe to channels
- Tweets – Post and manage short tweets
- File Uploads – Handled via Multer middleware
- Cloud Storage – Integrated with Cloudinary
- Email Validation – Validates email addresses using Abstract API
https://emailreputation.abstractapi.com/v1/?api_key=${ABSTRACT_API_KEY}&email=${email} - Error Handling – Custom ApiError and ApiResponse classes
src/
app.js # Main Express app setup
constants.js # Application constants
index.js # Entry point
controllers/ # Route controllers for each feature
comment.controller.js
like.controller.js
playlist.controller.js
subscription.controller.js
tweet.controller.js
user.controller.js
video.controller.js
db/
index.js # Database connection setup
middlewares/ # Custom Express middlewares
auth.middleware.js
emailValidator.middleware.js
multer.middleware.js
models/ # Mongoose models for MongoDB
comment.model.js
like.model.js
playlist.model.js
subscription.model.js
tweet.model.js
user.model.js
video.model.js
routes/ # API route definitions
comment.routes.js
like.routes.js
playlist.routes.js
subscription.routes.js
tweet.routes.js
user.routes.js
video.routes.js
utils/ # Utility classes and functions
ApiError.js
ApiResponse.js
asyncHandler.js
Cloudinary.js
public/
temp/ # Temporary files (e.g., uploads)
- Node.js (JavaScript runtime)
- Express.js (backend framework)
- MongoDB + Mongoose (database & ORM)
- Multer (file upload handling)
- Cloudinary (media storage)
- JWT (authentication & authorization)
- Bcrypt (password hashing)
- Dotenv (environment variable management)
- Nodemon (development server auto-restart)
- mailmeteor (email validation)
git clone https://github.com/rahul-vyas-dev/social-media-Backend-Project
cd social-media-Backend-Projectnpm installYou don’t need to run
npm initsince this project already includes apackage.jsonwith"type": "module"set.
You must create a .env file in the root directory.
A sample configuration is provided in .env.sample.
Development mode (auto-reload with nodemon):
npm run devProduction mode:
node src/index.jsBase URL: http://localhost:5000/api/v1
| Endpoint | Description |
|---|---|
/api/v1/users |
User operations (register, login, profile) |
/api/v1/videos |
Video upload & management |
/api/v1/comments |
Comment operations |
/api/v1/likes |
Like/unlike videos |
/api/v1/playlists |
Playlist CRUD |
/api/v1/subscriptions |
Subscribe/unsubscribe users |
/api/v1/tweets |
Tweet CRUD |
/api/v1/email/validate |
Validate email addresses |
From package.json:
npm run dev # Start backend in development mode with nodemon
npm start # Start normally with Node.js (if added)- Fork the repo
- Create a new branch (
feature/your-feature) - Commit your changes
- Push to your fork
- Create a Pull Request
This project is licensed under the MIT License.
Now anyone can:
- Clone →
git clone - Install →
npm install - Configure →
.env(check.env.samplefor reference) - Run →
npm run devornode src/index.js
This project took me a good amount of time and effort to build. During development, I:
- Carefully structured the backend from scratch.
- Implemented and tested every route one by one.
- Learned a lot about Node.js, Express, MongoDB, and integrations like Cloudinary and Abstract API.
- Focused on clean error handling and modular code organization.
I’m proud of the learning journey this project represents