🎥 VideoTube API
VideoTube is a modern backend API for a YouTube-inspired video platform built with Node.js, Express, and TypeScript. It provides a secure, scalable foundation for user authentication, video management, community features, and media uploads.
This project is designed to showcase strong backend engineering practices such as modular architecture, input validation, authentication, file handling, and production-ready middleware.
🚀 Why This Project Stands Out
- Built with a clean MVC-style structure using controllers, routes, models, and middleware
- Implements JWT-based authentication and protected routes
- Supports media uploads with Cloudinary integration
- Includes community features such as tweets, comments, likes, subscriptions, playlists, and watch history
- Uses TypeScript for better maintainability and safer backend development
- Includes security middleware such as rate limiting, helmet, sanitization, and error handling
✨ Core Features
- User registration, login, refresh token flow, and profile management
- Secure video upload, update, publish/unpublish, and deletion
- Commenting, liking, subscribing, and playlist creation
- Tweet posting and user tweet history
- Dashboard endpoints for personalized content insights
- Cloudinary integration for thumbnail and media storage
- Robust validation and centralized error handling
🛠️ Tech Stack
Backend
- Node.js
- Express.js
- TypeScript
- MongoDB with Mongoose
- JWT Authentication
- Cloudinary
- Multer
- Zod
- Winston logging
Security & Reliability
- Helmet
- CORS
- Rate limiting
- Express sanitizer
- Centralized error middleware
🏗️ Architecture
The application follows a modular backend architecture:
Client
│
▼
Express Server
│
├─ Middleware (Auth, Security, Validation, Logging)
│
├─ Routes
│ ├─ Users
│ ├─ Videos
│ ├─ Tweets
│ ├─ Comments / Likes / Subscriptions / Playlists
│ └─ Dashboard
│
├─ Controllers
├─ Models
└─ Database / Cloud Storage
├─ MongoDB
└─ Cloudinary
Request Flow
- Client sends a request to an Express route
- Middleware validates authentication, security, and input
- Controller handles the business logic
- Model interacts with MongoDB
- Media files are uploaded to Cloudinary when required
- Response is returned in a standardized API format
📁 Project Structure
src/
├── app.ts
├── index.ts
├── config/
├── controllers/
├── db/
├── middlewares/
├── models/
├── routes/
├── schema/
├── utils/
└── multithreading/
🔐 Environment Variables
Create a .env file in the root directory with the following variables:
PORT=5000
CORS_ORIGIN=http://localhost:3000
DB_URI=<your_mongodb_connection_string>
ACCESS_TOKEN_SECRET=<your_access_token_secret>
ACCESS_TOKEN_EXPIRY=1d
REFRESH_TOKEN_SECRET=<your_refresh_token_secret>
REFRESH_TOKEN_EXPIRY=10d
CLOUDINARY_CLOUD_NAME=<your_cloudinary_cloud_name>
CLOUDINARY_API_KEY=<your_cloudinary_api_key>
CLOUDINARY_API_SECRET=<your_cloudinary_api_secret>
NODE_ENV=development
⚙️ Installation & Setup
1. Clone the repository
git clone <repository-url>
cd rest_api_videotube_app
2. Install dependencies
npm install
3. Start the development server
npm run dev
4. Build for production
npm run build
📡 API Highlights
Authentication
POST /api/v1/users/registerPOST /api/v1/users/loginPOST /api/v1/users/refresh-tokenGET /api/v1/users/logout
Videos
GET /api/v1/videosPOST /api/v1/videosGET /api/v1/videos/:videoIdPATCH /api/v1/videos/:videoIdDELETE /api/v1/videos/:videoId
Social Features
POST /api/v1/tweetsGET /api/v1/tweets/user/:userIdPATCH /api/v1/tweets/:tweetIdDELETE /api/v1/tweets/:tweetId
Other Modules
- Comments
- Likes
- Playlists
- Subscriptions
- Dashboard
- Watch history
🧠 What I Learned While Building This
- Designing scalable REST APIs with Express and TypeScript
- Structuring backend code with separation of concerns
- Implementing secure authentication and authorization flows
- Handling file uploads and cloud storage integration
- Managing database relationships and application-level validation
📜 License
This project is licensed under the ISC License.
👤 Contact
- Email: bhoyarnikhil683@gmail.com
- GitHub: https://github.com/devnick10