Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

226 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“± Instagram Clone

A comprehensive and complete clone of Instagram built with Django REST Framework and Next.js that supports all major social network features.


🌟 Key Features

πŸ‘€ User Management System

  • βœ… Secure registration and login with JWT
  • βœ… User profile with profile picture
  • βœ… Edit user information
  • βœ… View other users' profiles
  • βœ… Display followers and following counts

πŸ“ Post System

  • βœ… 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

πŸ“Έ Stories System

  • βœ… Create new stories with images
  • βœ… View stories from followed users
  • βœ… Track story viewers
  • βœ… "My Stories" page for managing stories
  • βœ… Auto-delete expired stories

πŸ‘₯ Follow System

  • βœ… Follow and unfollow users
  • βœ… Display follower list
  • βœ… Display following list
  • βœ… Direct follow from search page

πŸ’¬ Messaging System

  • βœ… Send first message to users
  • βœ… Private conversations
  • βœ… View message history
  • βœ… Display user online status
  • βœ… Follow button within messages

πŸ”” Notification System

  • βœ… Like notifications
  • βœ… Comment notifications
  • βœ… Follow notifications
  • βœ… View unread notifications

πŸ” Search and Explore System

  • βœ… Search for users
  • βœ… Search for posts
  • βœ… Explore page for discovering popular posts
  • βœ… Search by hashtags

⭐ Highlights System

  • βœ… Create highlights from organized stories
  • βœ… Display highlights on profile
  • βœ… Manage highlights

πŸ—οΈ Project Architecture

Backend (Backend)

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

Frontend (Frontend)

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

πŸ› οΈ Technologies Used

Backend

  • 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

Frontend

  • Next.js 15 - React framework
  • React 19 - UI library
  • TypeScript - Type safety
  • Tailwind CSS - Styling
  • Axios - HTTP client
  • next/image - Image optimization

πŸ“‹ Requirements

System

  • Python 3.9+
  • Node.js 18+
  • npm or yarn

Python Dependencies

Django==4.x
djangorestframework
django-cors-headers
Pillow
python-dotenv
psycopg2-binary

Node.js Dependencies

next@15
react@19
typescript
tailwindcss
axios

πŸš€ Quick Start

1️⃣ Backend Setup (Django)

Clone the project:

git clone https://github.com/AhmadReza16/instagram-Clone.git
cd instagram-Clone

Activate virtual environment:

# Windows
python -m venv venv
venv\Scripts\activate

# Mac/Linux
python3 -m venv venv
source venv/bin/activate

Install dependencies:

cd config
pip install -r requirements.txt

Set up .env:

# 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:8000

Run migrations:

python manage.py migrate

Create superuser:

python manage.py createsuperuser

Run Django server:

python manage.py runserver

Django server runs at http://127.0.0.1:8000.


2️⃣ Frontend Setup (Next.js)

Install dependencies:

cd my-instaclone
npm install

Set up .env.local:

# my-instaclone/.env.local
NEXT_PUBLIC_API_URL=http://127.0.0.1:8000

Run Next.js server:

npm run dev

Next.js server runs at http://localhost:3000.


πŸ“‘ API Endpoints

Authentication

POST   /api/auth/register/          - Register new user
POST   /api/auth/login/             - User login
POST   /api/auth/refresh/           - Refresh token
POST   /api/auth/logout/            - Logout

Users

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

Posts

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

Comments

GET    /api/posts/<id>/comments/    - Get post comments
POST   /api/posts/<id>/comments/    - Create new comment
DELETE /api/comments/<id>/          - Delete comment

Likes

POST   /api/posts/<id>/like/        - Like post
DELETE /api/posts/<id>/like/        - Unlike post
GET    /api/posts/<id>/likes/       - Get likers list

Follow

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

Stories

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

Messages

GET    /api/messages/               - List conversations
GET    /api/messages/<user_id>/     - Messages with user
POST   /api/messages/<user_id>/     - Send new message

Search

GET    /api/search/users/           - Search users
GET    /api/search/posts/           - Search posts
GET    /api/posts/explore/          - Explore posts

Notifications

GET    /api/notifications/          - All notifications
GET    /api/notifications/unread/   - Unread notifications
POST   /api/notifications/<id>/read/ - Mark as read

πŸ” Authentication

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>

πŸ› Troubleshooting

Likes not working

If likes don't work:

  1. Reset database: python manage.py migrate
  2. Refresh page
  3. Check browser console

Image upload errors

If images won't upload:

  1. Check media/ folder exists
  2. Verify directory write permissions
  3. Check file size limits

CORS errors

If CORS requests are blocked:

  1. Set ALLOWED_HOSTS in Django
  2. Configure CORS_ORIGINS_ALLOWED

πŸ“ Important Notes

  • All images are stored in config/media/
  • Tokens expire after 24 hours
  • Stories auto-delete after 24 hours
  • Notifications are auto-created by signals

🀝 Contributing

To contribute to the project:

  1. Fork it
  2. Create a feature branch
  3. Commit your changes
  4. Submit a Pull Request

πŸ“„ License

This project is licensed under the MIT License.


πŸ“§ Contact and Support

For questions and issues:


🎯 Roadmap

  • 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

About

instagram clone with Django & REST framework and Next.js & TypeScript & Tailwind css

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages