A full-stack Instagram clone built with modern web technologies, featuring real-time messaging, stories, posts, and social interactions.
-
π Authentication
- Email/Password login and registration
- OAuth login (GitHub & Google)
- Email verification
- Password reset functionality
- Account deletion with verification
-
π± Core Features
- Create, edit, and delete posts
- Like and comment on posts
- Bookmark posts
- User profiles with bio and avatar
- Follow/unfollow users
- Real-time stories (24-hour expiration)
- Explore feed for discovering new content
- Search users
-
π¬ Real-time Messaging
- One-on-one chat
- Real-time message delivery using Socket.IO
- Message notifications
-
π Notifications
- Real-time notifications for likes, comments, and follows
- Notification badge counter
-
π₯ Social Features
- User suggestions
- Followers/Following lists
- Block/unblock users
- User profile pages
- Framework: Next.js 15.5 (App Router, Turbopack)
- Language: TypeScript
- Styling: Tailwind CSS
- State Management: Zustand
- Data Fetching: TanStack Query (React Query)
- Authentication: Better Auth
- UI Components: Radix UI
- Animations: Framer Motion
- Real-time: Socket.IO Client
- HTTP Client: Axios
- Forms: React Hook Form
- Notifications: React Hot Toast
- Runtime: Node.js
- Framework: Express.js 5
- Language: TypeScript
- Database: MongoDB (Mongoose ORM)
- Authentication: Better Auth
- Real-time: Socket.IO
- Image Upload: Cloudinary
- Email: Nodemailer
- Password Hashing: bcrypt.js
- Image Processing: Sharp
instagram-clone/
βββ backend/ # Backend server
β βββ src/
β β βββ auth/ # Authentication setup
β β βββ config/ # Configuration files
β β βββ controllers/ # Request handlers
β β βββ middlewares/ # Custom middlewares
β β βββ models/ # Database models
β β βββ routes/ # API routes
β β βββ socket/ # Socket.IO setup
β β βββ utils/ # Utility functions
β β βββ server.ts # Entry point
β βββ package.json
β βββ tsconfig.json
β
βββ frontend/ # Next.js frontend
βββ src/
β βββ app/ # Next.js app router pages
β βββ auth/ # Auth client setup
β βββ components/ # React components
β βββ config/ # Configuration files
β βββ hooks/ # Custom React hooks
β βββ lib/ # Utility libraries
β βββ store/ # Zustand store
β βββ types/ # TypeScript types
βββ public/ # Static assets
βββ package.json
βββ next.config.ts
- Node.js 18+ and npm
- MongoDB database
- Cloudinary account (for image uploads)
- GitHub OAuth App (optional, for GitHub login)
- Google OAuth App (optional, for Google login)
-
Clone the repository
git clone https://github.com/rohityadav-sas/instagram-clone.git cd instagram-clone -
Backend Setup
cd backend npm installCreate a
.envfile in thebackenddirectory:PORT=5000 FRONTEND_URL=http://localhost:3000 BETTER_AUTH_URL=http://localhost:5000 BETTER_AUTH_SECRET=your_secret_key_here MONGODB_URI=your_mongodb_connection_string CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name CLOUDINARY_API_KEY=your_cloudinary_api_key CLOUDINARY_API_SECRET=your_cloudinary_api_secret GITHUB_CLIENT_ID=your_github_client_id GITHUB_CLIENT_SECRET=your_github_client_secret GOOGLE_APP_PASSWORD=your_google_app_password GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret
-
Frontend Setup
cd ../frontend npm installCreate a
.env.localfile in thefrontenddirectory:NEXT_PUBLIC_API_URL=http://localhost:5000 NEXT_PUBLIC_FRONTEND_URL=http://localhost:3000 BETTER_AUTH_SECRET=your_secret_key_here BETTER_AUTH_URL=http://localhost:3000
-
Start the Backend (from the
backenddirectory)# Development mode with auto-reload npm run build # In one terminal npm run dev # In another terminal
-
Start the Frontend (from the
frontenddirectory)npm run dev
-
Access the Application
-
Frontend: http://localhost:3000
-
Backend API: http://localhost:5000
-
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set Authorization callback URL to:
http://localhost:5000/api/auth/callback/github - Add the Client ID and Client Secret to your
.envfile
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google+ API
- Create OAuth 2.0 credentials
- Set Authorized redirect URIs to:
http://localhost:5000/api/auth/callback/google - Add the Client ID and Client Secret to your
.envfile
- Sign up at Cloudinary
- Get your Cloud Name, API Key, and API Secret from the dashboard
- Add them to your
.envfile
- Use MongoDB Atlas for a cloud database
- Or install MongoDB locally
- Add your connection string to the
.envfile
- Push your code to GitHub
- Import project in Vercel
- Set Root Directory to
frontend - Add environment variable:
NEXT_PUBLIC_API_URL(your backend URL) - Deploy
- Create account on Railway or Render
- Create new project from GitHub repository
- Set Root Directory to
backend - Add all environment variables from
.env.example - Deploy
Note: Vercel is not recommended for the backend due to Socket.IO requirements. Use Railway, Render, or similar platforms that support WebSockets.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is open source and available under the MIT License.
Rohit Yadav
- Inspired by Instagram
- Built with modern web technologies
- Icons from Lucide
- UI components from Radix UI
β If you find this project helpful, please consider giving it a star!











