Skip to content

Dhruv-Raichand/devlink-frontend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

107 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ DevLink - Frontend

A modern, responsive frontend for a professional networking and dating platform. Built with React 18, Vite, Redux Toolkit, and styled with Tailwind CSS and DaisyUI. Features real-time chat, dynamic feed, and seamless user experience.

🌐 Live Demo: linkdev.online


✨ Features

User Interface

  • 🎨 Modern UI/UX - Clean, responsive design with Tailwind CSS and DaisyUI
  • πŸ” Authentication Flow - Login, Signup, and protected routes
  • πŸ‘€ User Profiles - View and edit profile with photo upload
  • 🀝 Connection System - Send, accept, or reject connection requests
  • πŸ’¬ Real-time Chat - Instant messaging with Socket.io
  • πŸ”” Toast Notifications - Real-time feedback for user actions
  • πŸ“± Fully Responsive - Mobile-first design

Technical Features

  • ⚑ Lightning-fast Vite build system
  • πŸ—ƒοΈ Redux Toolkit for state management
  • πŸ›£οΈ React Router for navigation
  • πŸ”’ Protected routes with authentication
  • πŸ“‘ Axios for API communication
  • 🎭 Component-based architecture
  • πŸ”„ Auto-updating UI on state changes

πŸ› οΈ Tech Stack

Core Framework

  • React 18
  • Vite

State Management

  • Redux Toolkit
  • React-Redux

Routing

  • React Router DOM

Styling

  • Tailwind CSS
  • DaisyUI

API & Real-time

  • Axios
  • Socket.io Client

Development Tools

  • Redux DevTools
  • ESLint

πŸ“‚ Project Structure

devlink-frontend/
β”œβ”€β”€ public/              # Static assets
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/      # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ Navbar.jsx
β”‚   β”‚   β”œβ”€β”€ Footer.jsx
β”‚   β”‚   β”œβ”€β”€ UserCard.jsx
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ pages/           # Route pages
β”‚   β”‚   β”œβ”€β”€ Feed.jsx
β”‚   β”‚   β”œβ”€β”€ Login.jsx
β”‚   β”‚   β”œβ”€β”€ Profile.jsx
β”‚   β”‚   β”œβ”€β”€ Connections.jsx
β”‚   β”‚   β”œβ”€β”€ Requests.jsx
β”‚   β”‚   └── Chat.jsx
β”‚   β”œβ”€β”€ store/           # Redux store
β”‚   β”‚   β”œβ”€β”€ store.js
β”‚   β”‚   β”œβ”€β”€ userSlice.js
β”‚   β”‚   β”œβ”€β”€ feedSlice.js
β”‚   β”‚   └── connectionSlice.js
β”‚   β”œβ”€β”€ utils/           # Utility functions
β”‚   β”‚   β”œβ”€β”€ constants.js
β”‚   β”‚   └── api.js
β”‚   β”œβ”€β”€ App.jsx          # Main app component
β”‚   β”œβ”€β”€ main.jsx         # Entry point
β”‚   └── index.css        # Global styles
β”œβ”€β”€ package.json
└── vite.config.js

🎯 Key Pages & Routes

Public Routes

  • /login - User login page
  • /signup - New user registration

Protected Routes (Require Authentication)

  • / - Main feed with user cards
  • /profile - User profile view and edit
  • /connections - All accepted connections
  • /requests - Pending connection requests
  • /chat/:targetUserId - Real-time chat with specific user

πŸ” Authentication Flow

  1. User logs in via /login
  2. JWT token stored in HTTP-only cookie
  3. Token validated on protected routes
  4. User redirected to /login if unauthorized
  5. Navbar updates based on auth state
  6. Logout clears token and redirects

πŸ“¦ Installation & Setup

Prerequisites

  • Node.js (v16.17.0 or higher)
  • npm or yarn

Local Development

# Clone the repository
git clone https://github.com/Dhruv-Raichand/devlink-frontend.git
cd devlink-frontend

# Install dependencies
npm install

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

# Add your environment variables
VITE_API_URL=http://localhost:7777

# Start development server
npm run dev

The app will be available at http://localhost:5173


πŸ”§ Environment Variables

Create a .env file in the root directory:

VITE_API_URL=https://linkdev.online/api
VITE_SOCKET_URL=https://linkdev.online

πŸ“œ Available Scripts

npm run dev          # Start development server with hot reload
npm run build        # Build for production
npm run preview      # Preview production build locally
npm run lint         # Run ESLint for code quality

πŸ—ƒοΈ Redux Store Structure

Slices

  • userSlice - Current user data, authentication state
  • feedSlice - Feed data with pagination
  • connectionSlice - Connections and pending requests

Example State

{
  user: {
    data: { id, firstName, lastName, emailId, ... },
    isAuthenticated: true
  },
  feed: {
    users: [...],
    page: 1,
    hasMore: true
  },
  connections: {
    list: [...],
    requests: [...]
  }
}

🎨 UI Components

Core Components

  • Navbar - Navigation with conditional rendering based on auth
  • Footer - Site footer
  • UserCard - Display user info on feed
  • Body - Main layout wrapper with Outlet for routes
  • ProtectedRoute - HOC for route protection

Features Implementation

  • Toast notifications for user feedback
  • Loading states for async operations
  • Error handling with user-friendly messages
  • Responsive design for all screen sizes

πŸš€ Deployment

Build for Production

# Create optimized production build
npm run build

# Output will be in /dist folder

Deployment on AWS EC2

# SSH into EC2 instance
ssh -i "your-key.pem" ubuntu@your-ec2-ip

# Navigate to project directory
cd devlink-frontend

# Pull latest changes
git pull origin main

# Install dependencies and build
npm install
npm run build

# Copy build files to Nginx
sudo cp -r dist/* /var/www/html/

# Restart Nginx
sudo systemctl restart nginx

Nginx Configuration

server {
    listen 80;
    server_name linkdev.online;

    root /var/www/html;
    index index.html;

    location / {
        try_files $uri $uri/ /index.html;
    }

    location /api/ {
        proxy_pass http://localhost:7777/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

πŸ”— API Integration

Axios Configuration

import axios from 'axios';

const api = axios.create({
  baseURL: import.meta.env.VITE_API_URL,
  withCredentials: true, // Important for cookies
});

export default api;

Example API Calls

// Login
const login = async (email, password) => {
  const response = await api.post('/login', { email, password });
  return response.data;
};

// Get Feed
const getFeed = async (page = 1) => {
  const response = await api.get(`/feed?page=${page}`);
  return response.data;
};

// Send Connection Request
const sendRequest = async (userId, status) => {
  const response = await api.post(`/request/send/${status}/${userId}`);
  return response.data;
};

πŸ”„ Real-time Chat Implementation

Socket.io Client Setup

import { io } from 'socket.io-client';

const socket = io(import.meta.env.VITE_SOCKET_URL, {
  withCredentials: true,
});

// Listen for messages
socket.on('message', (data) => {
  console.log('New message:', data);
});

// Send message
socket.emit('sendMessage', { targetUserId, message });

🎯 Key Features Implementation

Route Protection

  • Checks for JWT token in cookies
  • Redirects to /login if not authenticated
  • Updates Navbar based on auth state

State Management

  • User login updates Redux store
  • Navbar re-renders automatically
  • Feed data cached in store for performance

Pagination

  • Feed loads 10 users at a time
  • "Load More" button for next page
  • Handles end of feed gracefully

Toast Notifications

  • Success messages on profile save
  • Error messages on failed operations
  • Auto-dismiss after 3 seconds

πŸ”— Related Repository

Backend Repository: DevLink Backend


🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License.


πŸ‘€ Author

Dhruv Raichand


πŸ™ Acknowledgments

  • Vite for lightning-fast development
  • Redux Toolkit for simplified state management
  • DaisyUI for beautiful components
  • Socket.io for real-time features

Built with ❀️ and βš›οΈ by Dhruv Raichand

About

Frontend for DevLink - Built with React 18, Vite, Redux Toolkit, Tailwind CSS, DaisyUI, Socket.io, and deployed on AWS EC2

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages