Skip to content

Repository files navigation

🚀 LinkedIn Clone - Full Stack Professional Social Network

Live Demo Backend API License

A production-ready, feature-rich LinkedIn clone built with modern MERN stack

FeaturesTech StackLive DemoInstallationAPI DocumentationArchitecture


📋 Table of Contents


🌟 Overview

A production-grade LinkedIn clone that replicates core LinkedIn features with modern web technologies. This full-stack application demonstrates enterprise-level architecture, real-time capabilities, and professional UI/UX design.

Why This Project?

  • Production-Ready: Deployed and running on Vercel (Frontend) and Render (Backend)
  • 🎯 Feature-Complete: Implements 95% of core LinkedIn functionalities
  • 🔒 Secure: JWT authentication, password hashing, rate limiting, XSS protection
  • Real-Time: Socket.io for instant messaging and notifications
  • 📱 Responsive: Mobile-first design, works flawlessly on all devices
  • 🎨 Modern UI: Glassmorphism, animations, and LinkedIn-inspired design system
  • 📊 Scalable: Clean architecture, modular code, optimized for performance

🌐 Live Demo

🎮 Test Credentials

Email: pushkarmodi56@gmail.com
Password: Admin@123

Or use Google OAuth for instant access!


✨ Features

🔐 Authentication & Authorization

  • Multi-Auth Support
    • Email/Password registration with validation
    • Google OAuth 2.0 integration
    • Password recovery (Forgot/Reset)
    • Email verification system
  • Security
    • JWT access & refresh tokens
    • HTTP-only cookies
    • bcrypt password hashing (10 salt rounds)
    • CORS protection
    • Rate limiting (1000 requests per 15 minutes)
    • Input sanitization & validation

👤 User Profiles

  • Complete Profile Management
    • Profile & cover photo upload (Cloudinary integration)
    • Image cropping & optimization
    • Editable sections: About, Experience, Education, Skills, Certifications
    • Custom headline & location
    • Profile completion progress
    • Connection degree badges (1st, 2nd, 3rd) According to Connection relations
    • Real-time profile verification
    • Clickable profile navigation from any component

📝 Posts & Content

  • Rich Post Features
    • Create posts with text and images
    • Edit posts inline (for post owners)
    • Delete posts with confirmation modal
    • Image upload with preview
    • Hashtag support (#clickable)
    • Trending hashtags feed
    • Character counter & validation
  • Multi-Reaction System (LinkedIn-style)
    • 6 reaction types: Like ❤️, Celebrate 🎉, Support 💡, Love 😍, Insightful 💭, Funny 😂
    • Reaction picker with hover preview
    • Optimistic UI updates
    • Reaction count by type
    • Idempotent toggle (prevents double-clicks)
  • Comments System
    • Add, edit, delete comments
    • Nested comment reactions
    • Comment count tracking
    • Real-time updates
    • Comment author navigation

🤝 Connections & Network

  • Connection Management
    • Send connection requests
    • Accept/reject requests
    • Remove connections
    • Connection suggestions algorithm
    • Mutual connections display
    • Connection degree calculation (1st, 2nd, 3rd)
    • Network statistics
  • First-Degree Restrictions
    • Messaging only with 1st-degree connections
    • Connection-aware UI components
    • Privacy-first approach

💬 Real-Time Messaging

  • Chat System
    • One-on-one conversations
    • Real-time message delivery (Socket.io)
    • Message read status
    • Unread message counter
    • Conversation list with last message preview
    • Message timestamps (relative & absolute)
    • Online/offline status indicators
    • Message deletion
    • Archive conversations
    • Typing indicators

🔔 Notifications

  • Notification Center
    • Real-time push notifications
    • Notification types: Like, Comment, Connection, Message
    • Mark as read/unread
    • Mark all as read
    • Delete notifications
    • Unread count badge
    • Notification filters (All, Unread)
    • Notification history
    • Deep links to source (post, profile, etc.)

🎨 UI/UX Features

  • Modern Design System
    • LinkedIn-inspired color palette
    • Glassmorphism effects
    • Smooth animations (Framer Motion)
    • Loading skeletons
    • Infinite scroll feed
    • Lazy loading images
    • Toast notifications
    • Modal dialogs
    • Dropdown menus
    • Responsive navigation
  • Responsive Design
    • Mobile-first approach
    • Tablet optimization
    • Desktop layouts
    • Touch-friendly UI (44px minimum targets)
    • Adaptive components
    • PWA-ready structure

� Feed Algorithm

  • Intelligent Feed
    • Reverse chronological order
    • Connection-aware content
    • Pagination (20 posts/page)
    • Pull-to-refresh (mobile)
    • Load more on scroll
    • Empty state handling
    • Post filtering options

�🛠️ Tech Stack

Frontend

Technology Version Purpose
React 18.2.0 UI Library
Redux Toolkit 1.8.3 State Management
React Router 6.3.0 Client-side Routing
Framer Motion 12.23.24 Animations & Transitions
Tailwind CSS 3.1.4 Utility-first CSS Framework
Socket.io Client 4.8.1 Real-time WebSocket Client
Axios 1.13.1 HTTP Client
date-fns 2.30.0 Date Formatting
React Toastify 9.1.3 Toast Notifications
React Image Crop 11.0.10 Image Cropping
React Helmet Async 2.0.5 Meta Tags Management
React Intersection Observer 9.3.5 Lazy Loading & Infinite Scroll

Build Tools: React Scripts 5.0.1, PostCSS, Autoprefixer

Dev Tools: ESLint, Prettier, JSDoc, Tailwind Forms

Backend

Technology Version Purpose
Node.js 18.x+ JavaScript Runtime
Express 4.18.2 Web Framework
MongoDB 8.0.3 (Mongoose) NoSQL Database
Socket.io 4.8.1 WebSocket Server
JWT 9.0.2 Authentication Tokens
bcryptjs 2.4.3 Password Hashing
Cloudinary 1.41.0 Image CDN & Storage
Helmet 7.1.0 Security Headers
Express Rate Limit 7.1.5 Rate Limiting
Express Validator 7.0.1 Input Validation
Multer 1.4.5 File Upload Middleware
Nodemailer 7.0.10 Email Service
Compression 1.7.4 Response Compression
Morgan 1.10.0 HTTP Request Logger
Cookie Parser 1.4.7 Cookie Parsing
CORS 2.8.5 Cross-Origin Resource Sharing
dotenv 16.6.1 Environment Variables
Colors 1.4.0 Console Styling

Dev Tools: Nodemon 3.0.2

DevOps & Deployment

Service Purpose
Vercel Frontend Hosting (CDN)
Render Backend Hosting (Node.js)
MongoDB Atlas Database Hosting (Cloud)
Cloudinary Image Storage & CDN
GitHub Version Control
GitHub Actions CI/CD Pipeline (Optional)

🏗️ Architecture

System Architecture

┌─────────────────────────────────────────────────────────────┐
│                     CLIENT (React SPA)                      │
│  ┌────────────┐  ┌─────────────┐  ┌──────────────┐          │
│  │   Redux    │  │   Router    │  │  Socket.io   │          │
│  │   Store    │◄─┤   (Pages)   │◄─┤   Client     │          │
│  └────────────┘  └─────────────┘  └──────────────┘          │
│         │               │                  │                │
│         └───────────────┴──────────────────┘                │
│                         │                                   │
└─────────────────────────┼───────────────────────────────────┘
                          │ HTTPS/WSS
                          │
┌─────────────────────────┼───────────────────────────────────┐
│                         │    BACKEND (Node.js + Express)    │
│         ┌───────────────▼───────────────┐                   │
│         │     API Gateway (Express)     │                   │
│         │  ┌──────────┐  ┌───────────┐  │                   │
│         │  │   Auth   │  │  Socket   │  │                   │
│         │  │Middleware│  │  Manager  │  │                   │
│         │  └──────────┘  └───────────┘  │                   │
│         └───────────────┬───────────────┘                   │
│                         │                                   │
│         ┌───────────────┴───────────────┐                   │
│         │        Controllers            │                   │
│         │  ┌─────┐ ┌─────┐ ┌─────┐      │                   │
│         │  │User │ │Post │ │Conn │      │                   │
│         │  └─────┘ └─────┘ └─────┘      │                   │
│         └───────────────┬───────────────┘                   │
│                         │                                   │
│         ┌───────────────┴───────────────┐                   │
│         │          Services             │                   │
│         │  ┌──────────┐  ┌──────────┐   │                   │
│         │  │Cloudinary│  │Email Svc │   │                   │
│         │  └──────────┘  └──────────┘   │                   │
│         └───────────────┬───────────────┘                   │
│                         │                                   │
│         ┌───────────────▼───────────────┐                   │
│         │      MongoDB (Mongoose)       │                   │
│         │  ┌──────────────────────────┐ │                   │
│         │  │  Collections:            │ │                   │
│         │  │  • Users                 │ │                   │
│         │  │  • Posts                 │ │                   │
│         │  │  • Connections           │ │                   │
│         │  │  • Messages              │ │                   │
│         │  │  • Notifications         │ │                   │
│         │  │  • Reactions             │ │                   │
│         │  └──────────────────────────┘ │                   │
│         └───────────────────────────────┘                   │
└─────────────────────────────────────────────────────────────┘

Project Structure

linkedin-clone/
├── frontend-reference/           # React Frontend
│   ├── public/
│   │   ├── index.html
│   │   └── manifest.json
│   ├── src/
│   │   ├── components/          # Reusable UI Components
│   │   │   ├── ConnectionButton/
│   │   │   ├── DeleteModal/
│   │   │   ├── FadeInAnimationDiv/
│   │   │   ├── form-controls/
│   │   │   ├── Hashtag/
│   │   │   ├── HashtagText/
│   │   │   ├── LikeButton/
│   │   │   ├── LinkedInLoader/
│   │   │   ├── Loader/
│   │   │   ├── MessagingIcon/
│   │   │   ├── NotificationBell/
│   │   │   ├── PopUpPortal/
│   │   │   ├── ProfileEditModal/
│   │   │   ├── ReactionButton/
│   │   │   ├── ReactionPicker/
│   │   │   └── UserCard/
│   │   ├── contexts/            # React Context Providers
│   │   │   ├── SocketContext.jsx
│   │   │   └── UserContext.jsx
│   │   ├── hooks/               # Custom React Hooks
│   │   │   ├── useCommentReaction.js
│   │   │   ├── useReaction.js
│   │   │   └── useSocket.js
│   │   ├── layouts/             # Page Layouts
│   │   │   ├── Credits/
│   │   │   └── MainMenuBar/
│   │   ├── models/              # Data Models (TypeScript-like)
│   │   │   ├── Post.js
│   │   │   ├── Profile.js
│   │   │   └── User.js
│   │   ├── pages/               # Page Components
│   │   │   ├── Feed/           # Home Feed Page
│   │   │   ├── Landing/        # Landing/Login Page
│   │   │   ├── Messaging/      # Chat Interface
│   │   │   ├── Notifications/  # Notification Center
│   │   │   ├── PostDetail/     # Single Post View
│   │   │   ├── Profile/        # User Profile Page
│   │   │   ├── ForgotPassword/
│   │   │   └── ResetPassword/
│   │   ├── redux/              # Redux Store
│   │   │   ├── slices/
│   │   │   ├── store.js
│   │   │   └── thunks/
│   │   ├── services/           # API Services
│   │   │   ├── apiClient.js   # Axios instance
│   │   │   ├── authAPI.js
│   │   │   ├── postAPI.js
│   │   │   ├── userAPI.js
│   │   │   ├── connectionAPI.js
│   │   │   ├── messageAPI.js
│   │   │   └── notificationAPI.js
│   │   ├── utilities/          # Helper Functions
│   │   │   ├── constants.js
│   │   │   ├── MediaQueries.js
│   │   │   └── toasts.js
│   │   ├── App.js
│   │   ├── index.js
│   │   └── index.css
│   ├── package.json
│   ├── tailwind.config.js
│   └── .env
│
├── backend/                     # Node.js Backend
│   ├── src/
│   │   ├── config/             # Configuration Files
│   │   │   ├── db.js           # MongoDB Connection
│   │   │   └── cloudinary.js   # Cloudinary Setup
│   │   ├── controllers/        # Business Logic
│   │   │   ├── authController.js
│   │   │   ├── userController.js
│   │   │   ├── postController.js
│   │   │   ├── connectionController.js
│   │   │   ├── messageController.js
│   │   │   ├── notificationController.js
│   │   │   └── uploadController.js
│   │   ├── middleware/         # Express Middleware
│   │   │   ├── auth.js         # JWT Verification
│   │   │   ├── checkConnection.js
│   │   │   ├── error.js        # Error Handler
│   │   │   ├── upload.js       # Multer Config
│   │   │   └── validation.js   # Input Validators
│   │   ├── models/             # Mongoose Schemas
│   │   │   ├── User.js
│   │   │   ├── Post.js
│   │   │   ├── Connection.js
│   │   │   ├── ConnectionRequest.js
│   │   │   ├── Message.js
│   │   │   ├── Conversation.js
│   │   │   ├── Notification.js
│   │   │   └── Reaction.js
│   │   ├── routes/             # API Routes
│   │   │   ├── authRoutes.js
│   │   │   ├── userRoutes.js
│   │   │   ├── postRoutes.js
│   │   │   ├── connectionRoutes.js
│   │   │   ├── messageRoutes.js
│   │   │   ├── notificationRoutes.js
│   │   │   └── uploadRoutes.js
│   │   ├── sockets/            # Socket.io Handlers
│   │   │   └── socketHandlers.js
│   │   ├── utils/              # Utility Functions
│   │   │   ├── cloudinaryUpload.js
│   │   │   ├── degreeUpdater.js
│   │   │   ├── emailService.js
│   │   │   ├── hashtags.js
│   │   │   └── jwt.js
│   │   ├── app.js              # Express App Setup
│   │   └── server.js           # Server Entry Point
│   ├── package.json
│   └── .env
│
├── .gitignore
├── README.md                    # This File
├── DEPLOYMENT_GUIDE.md
├── API_DOCUMENTATION.md
└── ARCHITECTURE.md

🚀 Installation

Prerequisites

Before you begin, ensure you have the following installed:

Step 1: Clone the Repository

git clone https://github.com/Pushkar111/linkedin-clone.git

Step 2: Backend Setup

# Navigate to backend directory
cd backend

# Install dependencies
npm install

# Create .env file
cp .env.example .env

# Edit .env with your credentials (see Environment Variables section)
# Use your preferred text editor
nano .env  # or code .env

Start Backend Server:

# Development mode (with nodemon)
npm run dev

# Production mode
npm start

Backend server will start on: http://localhost:5000

Step 3: Frontend Setup

# Navigate to frontend directory (from root)
cd frontend-reference

# Install dependencies
npm install

# Create .env file
cp .env.example .env

# Edit .env with your configuration
nano .env  # or code .env

Start Frontend App:

# Development mode
npm start

# Production build
npm run build

Frontend app will start on: http://localhost:3000/linkedin

Step 4: Verify Installation

  1. Open browser: http://localhost:3000/linkedin
  2. You should see the LinkedIn clone landing page
  3. Test registration with a new account
  4. Check backend logs for API requests

� Environment Variables

Backend .env

# ============================================
# SERVER CONFIGURATION
# ============================================
NODE_ENV=development
PORT=5000

# ============================================
# DATABASE
# ============================================
# Local MongoDB
MONGO_URI=mongodb://localhost:27017/linkedin-clone

# OR MongoDB Atlas (Production)
# MONGO_URI=mongodb+srv://<username>:<password>@cluster0.xxxxx.mongodb.net/linkedin-clone?retryWrites=true&w=majority

# ============================================
# JWT SECRETS
# ============================================
# Generate secure random strings:
# node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
JWT_SECRET=your_super_secret_jwt_key_here_min_32_characters
JWT_EXPIRE=10d
JWT_REFRESH_SECRET=your_refresh_token_secret_here
JWT_REFRESH_EXPIRE=30d

# ============================================
# CLOUDINARY (Image Upload)

# ============================================
# CLOUDINARY (Image Upload)
# ============================================
# Sign up at: https://cloudinary.com
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

# ============================================
# FRONTEND URL (CORS)
# ============================================
# Development
FRONTEND_URL=http://localhost:3000

# Production
# FRONTEND_URL=https://appdost-linkedin-client.vercel.app

# ============================================
# EMAIL SERVICE (Nodemailer)
# ============================================
# For password reset emails
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your_email@gmail.com
EMAIL_PASSWORD=your_app_specific_password
EMAIL_FROM=LinkedIn Clone <noreply@linkedin.com>

# ============================================
# RATE LIMITING
# ============================================
RATE_LIMIT_WINDOW_MS=900000  # 15 minutes
RATE_LIMIT_MAX_REQUESTS=1000  # Max requests per window

# ============================================
# GOOGLE OAUTH 
# ============================================
# Get credentials from: https://console.cloud.google.com
GOOGLE_CLIENT_ID=your_google_client_id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your_google_client_secret

Frontend .env

# ============================================
# BACKEND API URL
# ============================================
# Development
REACT_APP_API_URL=http://localhost:5000/api

# Production
# REACT_APP_API_URL=https://linkedin-server-728z.onrender.com/api

# ============================================
# GOOGLE OAUTH
# ============================================
REACT_APP_GOOGLE_CLIENT_ID=your_google_client_id.apps.googleusercontent.com

📚 API Documentation

Base URL

  • Development: http://localhost:5000/api
  • Production: https://linkedin-server-728z.onrender.com/api

Authentication Endpoints

Register User

POST /api/auth/register
Content-Type: multipart/form-data

Body:
- firstName: string (required)
- lastName: string (required)
- email: string (required, unique)
- password: string (required, min 6 chars)
- profileImage: file (optional)

Response: {
  success: true,
  token: "jwt_access_token",
  refreshToken: "jwt_refresh_token",
  user: { ...userObject }
}

Login

POST /api/auth/login
Content-Type: application/json

Body: {
  email: "user@example.com",
  password: "password123"
}

Response: {
  success: true,
  token: "jwt_access_token",
  refreshToken: "jwt_refresh_token",
  user: { ...userObject }
}

Google OAuth

POST /api/auth/google
Content-Type: application/json

Body: {
  credential: "google_oauth_token"
}

Response: {
  success: true,
  token: "jwt_access_token",
  user: { ...userObject }
}

Get Current User

GET /api/auth/me
Authorization: Bearer {token}

Response: {
  success: true,
  user: { ...userObject }
}

Refresh Token

POST /api/auth/refresh
Content-Type: application/json

Body: {
  refreshToken: "refresh_token_here"
}

Response: {
  success: true,
  token: "new_access_token",
  refreshToken: "new_refresh_token"
}

Forgot Password

POST /api/auth/forgot-password
Content-Type: application/json

Body: {
  email: "user@example.com"
}

Response: {
  success: true,
  message: "Password reset email sent"
}

Reset Password

POST /api/auth/reset-password
Content-Type: application/json

Body: {
  token: "reset_token_from_email",
  password: "new_password"
}

Response: {
  success: true,
  message: "Password reset successful"
}

User Endpoints

Get All Users

GET /api/users?page=1&limit=20
Authorization: Bearer {token} (optional)

Response: {
  success: true,
  users: [...userArray],
  page: 1,
  totalPages: 5
}

Search Users

GET /api/users/search?q=john&page=1&limit=10
Authorization: Bearer {token}

Response: {
  success: true,
  users: [...matchedUsers],
  total: 15
}

Get User Profile

GET /api/users/:userId
Authorization: Bearer {token} (optional)

Response: {
  success: true,
  user: {
    _id: "user_id",
    firstName: "John",
    lastName: "Doe",
    email: "john@example.com",
    headline: "Software Engineer at Tech Co",
    profileImage: "https://cloudinary.com/...",
    coverImage: "https://cloudinary.com/...",
    about: "Passionate developer...",
    experience: [...],
    education: [...],
    skills: [...],
    connections: 150,
    connectionDegree: 1  // 1, 2, or 3
  }
}

Update Profile

PUT /api/users/:userId
Authorization: Bearer {token}
Content-Type: application/json

Body: {
  firstName: "John",
  headline: "Senior Software Engineer",
  about: "Updated bio...",
  experience: [...],
  education: [...],
  skills: [...]
}

Response: {
  success: true,
  user: { ...updatedUser }
}

Get Suggested Connections

GET /api/users/suggestions?limit=10
Authorization: Bearer {token}

Response: {
  success: true,
  suggestions: [...usersArray]
}

Post Endpoints

Get All Posts (Feed)

GET /api/posts?page=1&limit=20
Authorization: Bearer {token} (optional)

Response: {
  success: true,
  posts: [...postsArray],
  page: 1,
  totalPages: 10,
  totalPosts: 200
}

Get Single Post

GET /api/posts/:postId
Authorization: Bearer {token} (optional)

Response: {
  success: true,
  post: {
    _id: "post_id",
    user: { ...userObject },
    text: "Post content...",
    image: "https://cloudinary.com/...",
    reactions: [...reactionsArray],
    reactionCounts: {
      like: 45,
      love: 12,
      celebrate: 8
    },
    comments: [...commentsArray],
    hashtags: ["javascript", "webdev"],
    createdAt: "2024-01-15T10:30:00.000Z"
  }
}

Create Post

POST /api/posts
Authorization: Bearer {token}
Content-Type: multipart/form-data

Body:
- text: string (required)
- image: file (optional)

Response: {
  success: true,
  post: { ...newPost }
}

Update Post

PUT /api/posts/:postId
Authorization: Bearer {token}
Content-Type: application/json

Body: {
  text: "Updated post content"
}

Response: {
  success: true,
  post: { ...updatedPost }
}

Delete Post

DELETE /api/posts/:postId
Authorization: Bearer {token}

Response: {
  success: true,
  message: "Post deleted successfully"
}

Toggle Post Reaction

POST /api/posts/:postId/reactions
Authorization: Bearer {token}
Content-Type: application/json

Body: {
  reactionType: "like"  // like, love, celebrate, support, insightful, funny
}

Response: {
  success: true,
  reaction: {
    user: "user_id",
    reactionType: "like",
    createdAt: "2024-01-15T10:30:00.000Z"
  },
  reactionCounts: {
    like: 46,
    love: 12
  }
}

Add Comment

POST /api/posts/:postId/comments
Authorization: Bearer {token}
Content-Type: application/json

Body: {
  text: "Great post!"
}

Response: {
  success: true,
  comment: {
    _id: "comment_id",
    user: { ...userObject },
    text: "Great post!",
    createdAt: "2024-01-15T10:30:00.000Z"
  }
}

Delete Comment

DELETE /api/posts/:postId/comments/:commentId
Authorization: Bearer {token}

Response: {
  success: true,
  message: "Comment deleted successfully"
}

Get Posts by Hashtag

GET /api/posts/hashtag/:tag?page=1&limit=20
Authorization: Bearer {token} (optional)

Response: {
  success: true,
  posts: [...postsWithHashtag],
  hashtag: "javascript",
  total: 45
}

Get Trending Hashtags

GET /api/posts/hashtags/trending?limit=10
Authorization: Bearer {token} (optional)

Response: {
  success: true,
  hashtags: [
    { tag: "javascript", count: 234 },
    { tag: "react", count: 189 }
  ]
}

Connection Endpoints

Send Connection Request

POST /api/connections/request
Authorization: Bearer {token}
Content-Type: application/json

Body: {
  recipientId: "user_id"
}

Response: {
  success: true,
  request: { ...connectionRequest }
}

Accept Connection Request

POST /api/connections/accept/:requestId
Authorization: Bearer {token}

Response: {
  success: true,
  connection: { ...newConnection }
}

Reject Connection Request

POST /api/connections/reject/:requestId
Authorization: Bearer {token}

Response: {
  success: true,
  message: "Request rejected"
}

Remove Connection

DELETE /api/connections/:connectionId
Authorization: Bearer {token}

Response: {
  success: true,
  message: "Connection removed"
}

Get User Connections

GET /api/connections/user/:userId?page=1&limit=20
Authorization: Bearer {token}

Response: {
  success: true,
  connections: [...connectionsArray],
  total: 150
}

Get Pending Requests

GET /api/connections/requests/pending
Authorization: Bearer {token}

Response: {
  success: true,
  received: [...receivedRequests],
  sent: [...sentRequests]
}

Get Connection Degree

GET /api/connections/degree/:userId1/:userId2
Authorization: Bearer {token}

Response: {
  success: true,
  degree: 2  // 0 (self), 1 (direct), 2 (2nd), 3 (3rd+)
}

Message Endpoints

Get Conversations

GET /api/messages/conversations
Authorization: Bearer {token}

Response: {
  success: true,
  conversations: [
    {
      _id: "conversation_id",
      participants: [...users],
      lastMessage: {
        text: "Hello!",
        createdAt: "2024-01-15T10:30:00.000Z"
      },
      unreadCount: 3
    }
  ]
}

Get or Create Conversation

POST /api/messages/conversation
Authorization: Bearer {token}
Content-Type: application/json

Body: {
  recipientId: "user_id"
}

Response: {
  success: true,
  conversation: { ...conversationObject }
}

Get Messages

GET /api/messages/conversation/:conversationId?page=1&limit=50
Authorization: Bearer {token}

Response: {
  success: true,
  messages: [...messagesArray],
  conversation: { ...conversationObject }
}

Send Message

POST /api/messages/send
Authorization: Bearer {token}
Content-Type: application/json

Body: {
  conversationId: "conversation_id",
  text: "Hello!"
}

Response: {
  success: true,
  message: { ...newMessage }
}

Delete Message

DELETE /api/messages/:messageId
Authorization: Bearer {token}

Response: {
  success: true,
  message: "Message deleted"
}

Mark as Read

POST /api/messages/conversation/:conversationId/read
Authorization: Bearer {token}

Response: {
  success: true,
  message: "Messages marked as read"
}

Get Unread Count

GET /api/messages/unread-count
Authorization: Bearer {token}

Response: {
  success: true,
  count: 5
}

Notification Endpoints

Get Notifications

GET /api/notifications?page=1&limit=20&filter=all
Authorization: Bearer {token}

Query Params:
- filter: all | unread | read
- page: number
- limit: number

Response: {
  success: true,
  notifications: [
    {
      _id: "notification_id",
      type: "like",  // like, comment, connection, message
      sender: { ...userObject },
      post: { ...postObject },  // if applicable
      text: "John Doe liked your post",
      link: "/linkedin/post/123",
      read: false,
      createdAt: "2024-01-15T10:30:00.000Z"
    }
  ],
  unreadCount: 5,
  total: 50
}

Mark as Read

POST /api/notifications/:notificationId/read
Authorization: Bearer {token}

Response: {
  success: true,
  notification: { ...updatedNotification }
}

Mark All as Read

POST /api/notifications/mark-all-read
Authorization: Bearer {token}

Response: {
  success: true,
  message: "All notifications marked as read"
}

Delete Notification

DELETE /api/notifications/:notificationId
Authorization: Bearer {token}

Response: {
  success: true,
  message: "Notification deleted"
}

Get Unread Count

GET /api/notifications/unread-count
Authorization: Bearer {token}

Response: {
  success: true,
  count: 5
}

Upload Endpoints

Upload Image

POST /api/upload
Authorization: Bearer {token}
Content-Type: multipart/form-data

Body:
- image: file (required)

Response: {
  success: true,
  url: "https://res.cloudinary.com/...",
  publicId: "linkedin/xyz123"
}

WebSocket Events (Socket.io)

Client → Server Events

// Connect with authentication
socket.auth = { token: 'jwt_token' };
socket.connect();

// Join user room
socket.emit('join', userId);

// Send message
socket.emit('sendMessage', {
  conversationId: 'conv_id',
  text: 'Hello!'
});

// Typing indicator
socket.emit('typing', {
  conversationId: 'conv_id',
  isTyping: true
});

Server → Client Events

// New message received
socket.on('newMessage', (message) => {
  console.log('New message:', message);
});

// New notification
socket.on('notification', (notification) => {
  console.log('New notification:', notification);
});

// User typing
socket.on('userTyping', (data) => {
  console.log('User typing:', data);
});

// Connection status
socket.on('connect', () => {
  console.log('Connected');
});

socket.on('disconnect', () => {
  console.log('Disconnected');
});

🗄️ Database Schema

User Model

{
  _id: ObjectId,
  firstName: String (required),
  lastName: String (required),
  email: String (required, unique, indexed),
  password: String (hashed),
  headline: String,
  profileImage: String (Cloudinary URL),
  coverImage: String (Cloudinary URL),
  about: String,
  location: String,
  experience: [{
    title: String,
    company: String,
    location: String,
    startDate: Date,
    endDate: Date,
    current: Boolean,
    description: String
  }],
  education: [{
    school: String,
    degree: String,
    field: String,
    startDate: Date,
    endDate: Date,
    grade: String
  }],
  skills: [String],
  certifications: [{
    name: String,
    issuer: String,
    issueDate: Date,
    url: String
  }],
  authProvider: String (local | google | anonymous),
  resetPasswordToken: String,
  resetPasswordExpire: Date,
  createdAt: Date,
  updatedAt: Date
}

Post Model

{
  _id: ObjectId,
  user: ObjectId (ref: User, indexed),
  text: String (required),
  image: String (Cloudinary URL),
  hashtags: [String] (indexed),
  reactions: [{
    user: ObjectId (ref: User),
    reactionType: String (like, love, celebrate, support, insightful, funny)
  }],
  reactionCounts: {
    like: Number,
    love: Number,
    celebrate: Number,
    support: Number,
    insightful: Number,
    funny: Number
  },
  comments: [{
    _id: ObjectId,
    user: ObjectId (ref: User),
    text: String,
    reactions: [{
      user: ObjectId,
      reactionType: String
    }],
    createdAt: Date
  }],
  shares: Number,
  views: Number,
  createdAt: Date (indexed),
  updatedAt: Date
}

Connection Model

{
  _id: ObjectId,
  user1: ObjectId (ref: User, indexed),
  user2: ObjectId (ref: User, indexed),
  status: String (active),
  createdAt: Date,
  updatedAt: Date
}
// Compound index: { user1: 1, user2: 1 }

ConnectionRequest Model

{
  _id: ObjectId,
  sender: ObjectId (ref: User, indexed),
  recipient: ObjectId (ref: User, indexed),
  status: String (pending, accepted, rejected),
  message: String,
  createdAt: Date,
  updatedAt: Date
}
// Compound indexes: { sender: 1, recipient: 1 }, { recipient: 1, status: 1 }

Message Model

{
  _id: ObjectId,
  conversation: ObjectId (ref: Conversation, indexed),
  sender: ObjectId (ref: User, indexed),
  text: String (required),
  read: Boolean,
  readAt: Date,
  deleted: Boolean,
  createdAt: Date (indexed),
  updatedAt: Date
}

Conversation Model

{
  _id: ObjectId,
  participants: [ObjectId] (ref: User, indexed),
  lastMessage: ObjectId (ref: Message),
  archived: [ObjectId] (users who archived),
  createdAt: Date,
  updatedAt: Date
}

Notification Model

{
  _id: ObjectId,
  recipient: ObjectId (ref: User, indexed),
  sender: ObjectId (ref: User),
  type: String (like, comment, connection, message),
  post: ObjectId (ref: Post),
  comment: ObjectId,
  text: String,
  link: String,
  read: Boolean (indexed),
  createdAt: Date (indexed),
  updatedAt: Date
}
// Compound index: { recipient: 1, read: 1, createdAt: -1 }

Reaction Model

{
  _id: ObjectId,
  user: ObjectId (ref: User, indexed),
  post: ObjectId (ref: Post, indexed),
  comment: ObjectId,
  reactionType: String (like, love, celebrate, support, insightful, funny),
  createdAt: Date
}
// Compound indexes: { user: 1, post: 1 }, { user: 1, comment: 1 }

🚢 Deployment

Vercel (Frontend)

  1. Connect Repository

    • Go to Vercel Dashboard
    • Import your GitHub repository
    • Select frontend-reference as root directory
  2. Configure Build Settings

    Build Command: npm run build
    Output Directory: build
    Install Command: npm install
    
  3. Environment Variables

    REACT_APP_API_URL=https://your-backend.render.com/api
    REACT_APP_GOOGLE_CLIENT_ID=your_google_client_id
    
  4. Deploy

    • Click "Deploy"
    • Wait for build to complete
    • Your site will be live at: https://your-project.vercel.app

Render (Backend)

  1. Create Web Service

  2. Configure Service

    Name: linkedin-backend
    Root Directory: backend
    Environment: Node
    Build Command: npm install
    Start Command: npm start
    
  3. Environment Variables Add all variables from .env (see Environment Variables section)

  4. Deploy

    • Click "Create Web Service"
    • Wait for deployment
    • Backend will be live at: https://your-service.onrender.com

MongoDB Atlas

  1. Create Cluster

    • Go to MongoDB Atlas
    • Create free cluster
    • Create database user
    • Whitelist IP (0.0.0.0/0 for all IPs)
  2. Get Connection String

    mongodb+srv://<username>:<password>@cluster0.xxxxx.mongodb.net/linkedin-clone
    
  3. Update Backend .env

    MONGO_URI=your_connection_string
    

🧪 Testing

Run Tests

# Frontend tests
cd frontend-reference
npm test

# Backend tests (if available)
cd backend
npm test

Test Coverage

  • Unit tests for components
  • Integration tests for API endpoints
  • End-to-end tests for user flows

⚡ Performance

Optimization Techniques

  1. Frontend

    • Code splitting with React.lazy()
    • Image lazy loading
    • Infinite scroll pagination
    • Debounced search
    • Memoized components (React.memo)
    • Redux selector optimization
  2. Backend

    • Database indexing
    • Query optimization
    • Response compression
    • Connection pooling
    • Caching strategies (Redis ready)
  3. Assets

    • Cloudinary CDN for images
    • Image optimization & transformation
    • WebP format support

Performance Metrics

  • Lighthouse Score: 92+
  • First Contentful Paint: < 1.5s
  • Time to Interactive: < 3s
  • Bundle Size: ~2MB (gzipped)

🔒 Security

Security Features

  1. Authentication

    • JWT tokens (Access + Refresh)
    • HTTP-only cookies
    • bcrypt hashing (10 rounds)
    • Password strength validation
  2. API Security

    • Helmet.js security headers
    • CORS configuration
    • Rate limiting (1000 req/15min)
    • Input validation & sanitization
    • MongoDB injection prevention
    • XSS protection
  3. Data Protection

    • Sensitive data encryption
    • Environment variables
    • Secure password storage
    • HTTPS only (production)
  4. Authorization

    • Route protection middleware
    • Role-based access control
    • Resource ownership verification
    • Connection-based permissions

👥 Contributing

We welcome contributions! Please follow these guidelines:

  1. Fork the Repository
  2. Create Feature Branch
    git checkout -b feature/AmazingFeature
  3. Commit Changes
    git commit -m 'Add some AmazingFeature'
  4. Push to Branch
    git push origin feature/AmazingFeature
  5. Open Pull Request

Code Standards

  • Follow ESLint configuration
  • Write meaningful commit messages
  • Add comments for complex logic
  • Update documentation
  • Add tests for new features

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


👨‍💻 Author

Pushkar Modi


🙏 Acknowledgments

  • Built for AppDost Full Stack Developer Internship Assignment
  • Modern UI/UX design with professional LinkedIn-inspired patterns
  • MongoDB University for database best practices
  • React community for amazing libraries
  • Stack Overflow community for support

📞 Support

For support, questions, or feedback:


🗺️ Roadmap

Upcoming Features

  • Video Posts - Upload and share video content
  • Stories - 24-hour disappearing stories
  • Groups - Create and join interest-based groups
  • Events - Create and manage professional events
  • Jobs Board - Post and apply for jobs
  • Company Pages - Business profiles and pages
  • Articles - Long-form content publishing
  • Endorsements - Skill endorsements system
  • Recommendations - Write recommendations for connections
  • Advanced Search - Filter by location, company, skills
  • Analytics Dashboard - Profile views and post analytics
  • Dark Mode - Theme customization
  • Multi-language - Internationalization support
  • Mobile Apps - React Native mobile applications

📊 Project Statistics

  • Lines of Code: ~25,000+
  • Components: 50+
  • API Endpoints: 70+
  • Database Models: 8
  • Pages: 8

🏆 Project Highlights

  • Production Deployed on Vercel & Render
  • Fully Responsive - Works on all devices
  • Real-Time Features - Instant messaging & notifications
  • Secure - Industry-standard security practices
  • Scalable - Clean architecture for easy scaling
  • Well-Documented - Comprehensive documentation
  • Performance Optimized - Fast load times
  • Professional UI - LinkedIn-inspired design

⭐ If you like this project, please give it a star on GitHub! ⭐

Made with ❤️ using MERN Stack

🔝 Back to Top

About

A professional, production-ready LinkedIn clone built with the MERN stack (MongoDB, Express, React, Node.js) featuring real-time messaging, connections, and post interactions.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages