A comprehensive and complete clone of Instagram built with Django REST Framework and Next.js that supports all major social network features.
- β Secure registration and login with JWT
- β User profile with profile picture
- β Edit user information
- β View other users' profiles
- β Display followers and following counts
- β Create posts with images and captions
- β Edit and delete your own posts
- β Like posts
- β Comment on posts
- β Delete and edit comments
- β Save posts for later access
- β Display main feed with posts from followed users
- β Create new stories with images
- β View stories from followed users
- β Track story viewers
- β "My Stories" page for managing stories
- β Auto-delete expired stories
- β Follow and unfollow users
- β Display follower list
- β Display following list
- β Direct follow from search page
- β Send first message to users
- β Private conversations
- β View message history
- β Display user online status
- β Follow button within messages
- β Like notifications
- β Comment notifications
- β Follow notifications
- β View unread notifications
- β Search for users
- β Search for posts
- β Explore page for discovering popular posts
- β Search by hashtags
- β Create highlights from organized stories
- β Display highlights on profile
- β Manage highlights
config/
βββ manage.py # Django management script
βββ requirements.txt # All Python dependencies
βββ db.sqlite3 # SQLite database
βββ config/ # Django settings
β βββ settings.py # Project configuration
β βββ urls.py # Main routes
β βββ wsgi.py # WSGI configuration
β βββ asgi.py # ASGI configuration
β
βββ Django Apps:
βββ users/ # User management and authentication
βββ posts/ # Post system
βββ comments/ # Comments on posts
βββ likes/ # Post likes
βββ follow/ # Follow system
βββ stories/ # Instagram stories
βββ messages/ # Private messaging system
βββ notifications/ # System notifications
βββ saved/ # Save posts
βββ search/ # Search and explore
my-instaclone/
βββ package.json # Node.js dependencies
βββ tsconfig.json # TypeScript configuration
βββ next.config.ts # Next.js configuration
βββ tailwind.config.mjs # Tailwind CSS configuration
β
βββ src/
β βββ app/ # Next.js pages (App Router)
| | βββ(auth) # auth
| | βββ(root) # root pages
β βββ components/ # React components
β β βββ comments/ # Comments
β β βββ highlight/ # Highlight
β β βββ stories/ # Stories
β β βββ search/ # Search
β β βββ messages/ # Messages
β β βββ posts/ # Posts
β β βββ profile/ # Profile
| | βββ ... # Other componetns
β βββ hooks/ # Custom React Hooks
β βββ services/ # API client
β βββ lib/ # Helper functions
β βββ utils/ # Utilities
β βββ types/ # TypeScript types
β βββ styles/ # Global CSS
β
βββ public/ # Static files
- Django 4.x - Python web framework
- Django REST Framework - REST API
- PostgreSQL / SQLite - Database
- JWT (JSON Web Token) - Authentication
- Django Signals - Notifications and events
- Pillow - Image processing
- Next.js 15 - React framework
- React 19 - UI library
- TypeScript - Type safety
- Tailwind CSS - Styling
- Axios - HTTP client
- next/image - Image optimization
- Python 3.9+
- Node.js 18+
- npm or yarn
Django==4.x
djangorestframework
django-cors-headers
Pillow
python-dotenv
psycopg2-binary
next@15
react@19
typescript
tailwindcss
axios
git clone https://github.com/AhmadReza16/instagram-Clone.git
cd instagram-Clone# Windows
python -m venv venv
venv\Scripts\activate
# Mac/Linux
python3 -m venv venv
source venv/bin/activatecd config
pip install -r requirements.txt# config/.env
SECRET_KEY=your_secret_key_here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
DATABASE_URL=sqlite:///db.sqlite3
NEXT_PUBLIC_API_URL=http://127.0.0.1:8000python manage.py migratepython manage.py createsuperuserpython manage.py runserverDjango server runs at http://127.0.0.1:8000.
cd my-instaclone
npm install# my-instaclone/.env.local
NEXT_PUBLIC_API_URL=http://127.0.0.1:8000npm run devNext.js server runs at http://localhost:3000.
POST /api/auth/register/ - Register new user
POST /api/auth/login/ - User login
POST /api/auth/refresh/ - Refresh token
POST /api/auth/logout/ - Logout
GET /api/users/ - List all users
GET /api/users/<id>/ - Get user information
PUT /api/users/<id>/ - Update user information
GET /api/users/<username>/profile/ - User profile
GET /api/posts/ - List all posts
POST /api/posts/ - Create new post
GET /api/posts/<id>/ - Get post details
PUT /api/posts/<id>/ - Edit post
DELETE /api/posts/<id>/ - Delete post
GET /api/posts/feed/ - Personal feed
GET /api/posts/<id>/comments/ - Get post comments
POST /api/posts/<id>/comments/ - Create new comment
DELETE /api/comments/<id>/ - Delete comment
POST /api/posts/<id>/like/ - Like post
DELETE /api/posts/<id>/like/ - Unlike post
GET /api/posts/<id>/likes/ - Get likers list
POST /api/users/<id>/follow/ - Follow user
DELETE /api/users/<id>/unfollow/ - Unfollow user
GET /api/users/<id>/followers/ - Get followers list
GET /api/users/<id>/following/ - Get following list
GET /api/stories/ - All stories from followed users
POST /api/stories/ - Create new story
GET /api/stories/my-stories/ - Your stories
DELETE /api/stories/<id>/ - Delete story
POST /api/stories/<id>/view/ - Record story view
GET /api/messages/ - List conversations
GET /api/messages/<user_id>/ - Messages with user
POST /api/messages/<user_id>/ - Send new message
GET /api/search/users/ - Search users
GET /api/search/posts/ - Search posts
GET /api/posts/explore/ - Explore posts
GET /api/notifications/ - All notifications
GET /api/notifications/unread/ - Unread notifications
POST /api/notifications/<id>/read/ - Mark as read
The project uses JWT (JSON Web Token) for authentication:
- Access Token: For accessing protected API endpoints
- Refresh Token: For refreshing access token
Every request needs the following header:
Authorization: Bearer <access_token>
If likes don't work:
- Reset database:
python manage.py migrate - Refresh page
- Check browser console
If images won't upload:
- Check
media/folder exists - Verify directory write permissions
- Check file size limits
If CORS requests are blocked:
- Set
ALLOWED_HOSTSin Django - Configure
CORS_ORIGINS_ALLOWED
- All images are stored in
config/media/ - Tokens expire after 24 hours
- Stories auto-delete after 24 hours
- Notifications are auto-created by signals
To contribute to the project:
- Fork it
- Create a feature branch
- Commit your changes
- Submit a Pull Request
This project is licensed under the MIT License.
For questions and issues:
- π§ Email: your-email@example.com
- π GitHub: AhmadReza16
- Real-time Chat with WebSocket
- Reels implementation
- Hashtag tracking
- Advanced analytics
- Mobile App (React Native)
- Better Dark/Light Mode
- Multi-language support
Built with β€οΈ by AhmadReza16