A modern, full-stack Instagram clone built with React, Node.js, Express, and MongoDB. This application replicates the core features of Instagram including user authentication, photo sharing, social interactions, and a responsive design.
- User Registration & Login - Secure authentication with JWT tokens
- Profile Management - Edit profile information, bio, and profile pictures
- User Search - Find and discover other users
- Photo Sharing - Upload and share photos with captions and location tags
- News Feed - View posts from followed users in chronological order
- Like & Comment System - Interact with posts through likes and comments
- Follow/Unfollow - Build your social network by following other users
- User Profiles - View detailed user profiles with post grids and statistics
- Responsive Design - Works seamlessly on desktop, tablet, and mobile devices
- Instagram-like Interface - Familiar and intuitive user interface
- Real-time Updates - Dynamic content updates without page refreshes
- Image Upload - Drag-and-drop image upload with preview
- Loading States - Smooth loading indicators and error handling
- React 18 - Modern React with hooks and functional components
- React Router - Client-side routing and navigation
- Axios - HTTP client for API communication
- React Icons - Beautiful icon library
- React Dropzone - File upload with drag-and-drop
- Moment.js - Date and time formatting
- Node.js - JavaScript runtime environment
- Express.js - Web application framework
- MongoDB - NoSQL database for data storage
- Mongoose - MongoDB object modeling
- JWT - JSON Web Tokens for authentication
- Bcrypt - Password hashing and security
- Multer - File upload handling
- Express Validator - Input validation and sanitization
- Node.js (v14 or higher)
- MongoDB (local installation or MongoDB Atlas)
- npm or yarn package manager
```bash git clone cd instagram-clone ```
```bash
npm install
cd server npm install
cd ../client npm install ```
Create a `.env` file in the `server` directory:
```env PORT=5000 MONGODB_URI=mongodb://localhost:27017/instagram-clone JWT_SECRET=your-super-secret-jwt-key-change-this-in-production CLOUDINARY_CLOUD_NAME=your-cloudinary-cloud-name CLOUDINARY_API_KEY=your-cloudinary-api-key CLOUDINARY_API_SECRET=your-cloudinary-api-secret ```
Make sure MongoDB is running on your system:
```bash
mongod
```
```bash
npm run dev
npm run server
npm run client ```
The application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
- Register - Create a new account with username, email, and password
- Login - Sign in to your account
- Complete Profile - Add a profile picture and bio
- Create Posts - Share your first photo with a caption
- Discover Users - Find and follow other users
- Engage - Like and comment on posts in your feed
- Click the "+" icon in the navigation bar
- Drag and drop an image or click to select from your computer
- Add a caption and location (optional)
- Click "Share" to publish your post
- Like Posts - Click the heart icon on any post
- Comment - Add comments to posts and engage in conversations
- Follow Users - Visit user profiles and click "Follow"
- Profile Views - Click on usernames to view detailed profiles
- Click your profile picture in the navigation
- Select "Profile" to view your profile
- Click "Edit Profile" to update your information
``` instagram-clone/ βββ client/ # React frontend β βββ public/ # Static files β βββ src/ β β βββ components/ # React components β β β βββ Auth/ # Authentication components β β β βββ Posts/ # Post-related components β β β βββ Profile/ # Profile components β β βββ context/ # React Context (Auth) β β βββ App.js # Main App component β β βββ index.js # Entry point β βββ package.json βββ server/ # Node.js backend β βββ models/ # MongoDB schemas β βββ routes/ # API routes β βββ middleware/ # Custom middleware β βββ index.js # Server entry point β βββ package.json βββ package.json # Root package.json βββ README.md ```
- `POST /api/auth/register` - Register new user
- `POST /api/auth/login` - User login
- `GET /api/auth/me` - Get current user
- `GET /api/users/profile/:username` - Get user profile
- `PUT /api/users/profile` - Update user profile
- `POST /api/users/follow/:userId` - Follow/unfollow user
- `GET /api/users/search/:query` - Search users
- `POST /api/posts` - Create new post
- `GET /api/posts/feed` - Get user feed
- `GET /api/posts/user/:userId` - Get user's posts
- `GET /api/posts/:postId` - Get single post
- `POST /api/posts/:postId/like` - Like/unlike post
- `POST /api/posts/:postId/comment` - Add comment
- `DELETE /api/posts/:postId/comment/:commentId` - Delete comment
- `DELETE /api/posts/:postId` - Delete post
The application uses a custom CSS design system that closely mimics Instagram's visual design:
- Color Palette - Instagram's signature colors and gradients
- Typography - Clean, readable fonts with proper hierarchy
- Layout - Responsive grid system and flexible layouts
- Components - Reusable UI components with consistent styling
- Mobile-First - Responsive design that works on all screen sizes
- Password Hashing - Bcrypt for secure password storage
- JWT Authentication - Secure token-based authentication
- Input Validation - Server-side validation for all inputs
- CORS Protection - Cross-origin resource sharing configuration
- File Upload Security - Secure image upload with validation
```bash cd client npm run build
```
```bash
```
- Create a MongoDB Atlas cluster
- Update the MONGODB_URI in your environment variables
- Configure network access and database users
- Fork the repository
- Create a feature branch (`git checkout -b feature/amazing-feature`)
- Commit your changes (`git commit -m 'Add some amazing feature'`)
- Push to the branch (`git push origin feature/amazing-feature`)
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Talha
- Instagram for the design inspiration
- React and Node.js communities for excellent documentation
- All the open-source libraries that made this project possible
Note: This is a clone project created for educational purposes. It is not affiliated with or endorsed by Instagram/Meta.