A full-stack TikTok/Instagram Reels clone built with the MERN stack (MongoDB, Express.js, React, Node.js). Users can upload short videos, scroll through an infinite feed, like content, and interact with other users.
Videos and images are now stored in the cloud with Cloudinary for:
- π Global CDN delivery - Fast video streaming worldwide
- π― Automatic optimization - Smart compression and format selection
- πΈ Auto thumbnails - Generated from uploaded videos
- π Real-time analytics - Monitor usage and performance
- πΎ Scalable storage - No local storage limits
- Upload short videos (up to 60 seconds, 50MB) to Cloudinary
- Infinite scroll feed with TikTok-style navigation
- Auto-play videos when in viewport
- Like and unlike videos with real-time counts
- Comments system with nested replies
- Auto-generated thumbnails from videos
- JWT Authentication (register/login)
- User profiles with avatars stored on Cloudinary
- Follow/unfollow system
- User search functionality
- Profile customization
- Mobile-first responsive design
- Dark/light theme support
- Smooth animations and transitions
- Touch-friendly interactions
- Keyboard navigation support
- Cloudinary CDN for optimized video streaming
- Lazy loading and code splitting
- Database indexing for fast queries
- File upload with progress tracking
- Real-time updates without page refresh
reels-platform/
βββ reels-backend/ # Express.js API Server
β βββ src/
β β βββ config/ # Cloudinary configuration
β β βββ controllers/ # Route handlers
β β βββ models/ # MongoDB schemas
β β βββ routes/ # API endpoints
β β βββ middleware/ # Auth, Cloudinary uploads
β β βββ utils/ # Helper functions
β βββ package.json
β
βββ reels-frontend/ # React Frontend
β βββ src/
β β βββ components/ # React components
β β βββ contexts/ # State management
β β βββ lib/ # API client & utils
β β βββ hooks/ # Custom hooks
β βββ package.json
β
βββ CLOUDINARY_SETUP.md # Cloudinary setup guide
βββ README.md # This file
- Node.js 20+ or Bun (recommended)
- MongoDB (local or cloud)
- Cloudinary Account (free tier available)
- Git
git clone <repository-url>
cd reels-platformQuick Setup:
- Go to cloudinary.com and create free account
- Get your Cloud Name, API Key, and API Secret from Dashboard
- See CLOUDINARY_SETUP.md for detailed guide
cd reels-backend
# Install dependencies
npm install # or bun install
# Set up environment variables
cp .env.example .env
# Edit .env with your MongoDB URI, JWT secrets, and Cloudinary credentials
# Start development server
npm run dev # or bun run devThe backend will run on http://localhost:5000
cd ../reels-frontend
# Install dependencies
npm install # or bun install
# Set up environment variables
cp .env.example .env
# Update VITE_API_URL if needed
# Start development server
npm run dev # or bun devThe frontend will run on http://localhost:3000
Local MongoDB:
# Install MongoDB locally or use Docker
docker run -d -p 27017:27017 --name mongodb mongo:latestMongoDB Atlas (Cloud):
- Create account at mongodb.com/atlas
- Create new cluster
- Get connection string
- Update
MONGODB_URIin backend.env
PORT=5000
MONGODB_URI=mongodb://localhost:27017/reels-platform
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
JWT_REFRESH_SECRET=your-super-secret-refresh-key-change-this-in-production
JWT_EXPIRES_IN=7d
CLIENT_URL=http://localhost:3000
NODE_ENV=development
# Cloudinary Configuration (Required)
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secretVITE_API_URL=http://localhost:5000/apicd reels-backend
# Development with auto-reload
npm run dev
# Production build
npm run build
# Start production server
npm run start
# Type checking
npm run type-checkcd reels-frontend
# Development server
npm run dev
# Production build
npm run build
# Preview production build
npm run preview
# Type checking
npm run type-checkPOST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/profile- Get current userPUT /api/auth/profile- Update profilePUT /api/auth/avatar- Upload avatar (to Cloudinary)
GET /api/reels- Get reels feed (paginated)POST /api/reels- Upload new reel (to Cloudinary)GET /api/reels/:id- Get specific reelPOST /api/reels/:id/like- Like/unlike reelPOST /api/reels/:id/comments- Add commentGET /api/reels/:id/comments- Get comments
GET /api/users/search- Search usersGET /api/users/:id- Get user profilePOST /api/users/:id/follow- Follow/unfollow userGET /api/users/:id/followers- Get followersGET /api/users/:id/following- Get following
- Runtime: Bun (or Node.js)
- Framework: Express.js
- Database: MongoDB with Mongoose ODM
- Authentication: JWT (JSON Web Tokens)
- Cloud Storage: Cloudinary for videos/images
- File Upload: Multer + Cloudinary Storage
- Password Hashing: bcryptjs
- Language: TypeScript
- Framework: React 19 with TypeScript
- Routing: React Router v7
- Styling: Tailwind V4 + ShadCN UI
- State Management: React Context + TanStack Query
- HTTP Client: Custom Fetch wrapper
- Build Tool: Vite 6
- Icons: Lucide React
- Video Storage: Cloudinary
- CDN: Cloudinary's global CDN
- Image Processing: Automatic optimization
- Video Processing: Compression and format conversion
- Smart compression based on device and connection
- Format selection (WebM, MP4, etc.)
- Quality adaptation for different screen sizes
- Thumbnail generation from videos
- CDN delivery from 200+ locations worldwide
- Adaptive bitrate streaming
- Lazy loading support
- Progressive image loading
- Simple API - just upload and get URLs
- Real-time transformations via URL parameters
- Analytics dashboard for monitoring usage
- Webhook support for advanced workflows
- Frontend: Deploy to Vercel (automatic)
- Backend: Deploy to Railway (with env vars)
- Database: MongoDB Atlas (cloud)
- Media: Cloudinary (already integrated)
# Build and run with Docker Compose
docker-compose up -d- Set up Node.js and MongoDB
- Configure Cloudinary environment variables
- Use PM2 for process management
- Set up Nginx reverse proxy
- JWT Authentication with refresh tokens
- Password hashing with bcrypt
- Cloudinary secure uploads with signed URLs
- File type validation (videos/images only)
- Rate limiting on API endpoints
- CORS configuration for cross-origin requests
- Environment variable protection
- Database indexing for fast queries
- Cloudinary CDN for global media delivery
- Pagination for large datasets
- Caching strategies with TanStack Query
- Code splitting with React.lazy
- Cloudinary automatic optimization
- Virtual scrolling for infinite feeds
- Request caching with TanStack Query
- Intersection Observer for video auto-play
- Start both servers (backend + frontend)
- Register/login to your account
- Go to Create page (/create)
- Select a video file (MP4, MOV, WebM)
- Fill in title/description
- Click Upload - video goes to Cloudinary
- Check Cloudinary Dashboard - see your uploaded files
- View in feed - video streams from Cloudinary CDN
- Real-time notifications with WebSockets
- Advanced video editing with Cloudinary transformations
- Live streaming with Cloudinary Live
- AI-powered recommendations
- Content moderation with Cloudinary AI
- Mobile app with React Native
- Analytics dashboard for creators
// Backend automatically handles Cloudinary upload
const formData = new FormData();
formData.append('video', videoFile);
formData.append('title', 'My awesome reel');
const response = await api.createReel(formData);
// Returns Cloudinary URL, not local path// Thumbnail automatically created from video
const thumbnailUrl = generateVideoThumbnail(videoUrl);
// Returns optimized thumbnail from Cloudinary- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Test with Cloudinary (use your own account for testing)
- Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
β Ready to build the next TikTok? This platform provides everything you need with enterprise-grade cloud infrastructure!