Skip to content

akshadjaiswal/devTinder-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevTinder Backend πŸš€

πŸ“Œ Overview

DevTinder is a MERN stack web application designed to help developers connect and collaborate, similar to Tinder but specifically for developers. Users can create profiles, explore other developers, send connection requests, and manage their matches.

This repository contains the backend of DevTinder, built with Node.js, Express, and MongoDB, following a microservices architecture for scalability.

⚠️ Note: The backend is fully functional and ready for further scaling and optimizations.


πŸ“– My Node.js Learning Repository

I learned and maintained all my Node.js knowledge in one place: Namsate Nodejs

πŸ› οΈ Tech Stack


πŸ”‘ Features Implemented

1. Authentication System

βœ… User Signup, Login, and Logout
βœ… JWT-based authentication with secure cookies
βœ… Password encryption using bcryptjs
βœ… Authentication middleware to protect routes

2. User Profile Management

βœ… View user profile
βœ… Edit profile details (restricted fields for security)
βœ… Update password with validation

3. Connection Request System

βœ… Send connection requests (Interested or Ignored)
βœ… Accept or reject received requests
βœ… Prevent duplicate requests using MongoDB validation
βœ… Prevent self-requests using Mongoose .pre middleware

4. Feed API & Pagination

βœ… Fetch suggested developers while excluding:

  • Logged-in user
  • Existing connections
  • Ignored users
  • Users with pending requests
    βœ… Implemented pagination using skip & limit
    βœ… Optimized query using MongoDB $nin and $ne operators

5. Database Design

βœ… User Schema:

  • Sanitized input fields (trim, lowercase, validation)
  • Unique constraints on email and username

βœ… ConnectionRequest Schema:

  • fromUserId, toUserId, status with enum validation
  • Indexed fields for optimized queries
  • Prevents multiple requests between the same users

6. Advanced Query Optimization

βœ… Indexes & Compound Indexes:

  • Used index: true for faster queries
  • Implemented compound indexes to optimize search

7. Middleware Implementation

βœ… Authentication Middleware: Protects private routes
βœ… Error Handling Middleware: Centralized error response
βœ… Mongoose .pre Middleware: Prevents self-requests

8. Express Router Structure

βœ… Modular route organization for maintainability
βœ… APIs structured into separate routers (auth, profile, connections, users)


πŸš€ API Endpoints

1️⃣ Authentication Routes

Method Endpoint Description Auth Required
POST /auth/signup Register a new user ❌
POST /auth/login Authenticate user & issue JWT ❌
POST /auth/logout Logout user by clearing JWT cookie βœ…

2️⃣ User Profile Routes

Method Endpoint Description Auth Required
GET /profile/view Get logged-in user profile βœ…
PATCH /profile/edit Update allowed profile fields βœ…
PATCH /profile/password Update user password βœ…

3️⃣ Connection Request Routes

Method Endpoint Description Auth Required
POST /request/send/:status/:toUserId Send a connection request (Interested/Ignored) βœ…
POST /request/review/:status/:requestId Accept/Reject a request βœ…
GET /user/requests/received Fetch pending connection requests βœ…
GET /user/connections Fetch accepted connections βœ…

4️⃣ Feed API & Pagination

Method Endpoint Description Auth Required
GET /user/feed?page=1&limit=10 Get suggested developer profiles with pagination βœ…

πŸ—οΈ Setup & Running the Server

1️⃣ Clone the Repository

git clone https://github.com/akshadjaiswal/devTinder-backend.git
cd devTinder-backend

2️⃣ Set Up Environment Variables

Create a .env file and add:

DATABASE_URL=mongodb+srv://<username>:<password>@cluster0.mongodb.net/devTinder
JWT_SECRET=your_jwt_secret
PORT=3000

3️⃣ Start the Backend Server

npm start

Server runs at: http://localhost:3000/


πŸ”— Frontend Integration

The frontend for DevTinder is available at: πŸ”— DevTinder Frontend Repository

Make sure the backend is running before accessing the frontend.


Learning Resources

Explore my additional repositories to deepen your understanding of related topics in the JavaScript ecosystem:

  • Namaste Javascript: A repository focused on learning Javascript concepts, from basics to advanced programming.
  • Namaste React: A repository dedicated to mastering React.js, covering foundational and advanced aspects of building interactive UIs.

πŸ“’ Contribution Guidelines

Since the project is now fully functional, improvements are still welcome! βœ… Feel free to open issues for bugs or feature requests.
βœ… Fork the repository and submit a pull request.


πŸ“Œ Future Enhancements

πŸ”Ή Real-time notifications using WebSockets
πŸ”Ή Messaging System for better user interaction
πŸ”Ή Profile Search & Filtering
πŸ”Ή Unit Testing for API reliability


πŸ“œ License

This project is open-source and available under the MIT License.


About

devTinder MERN application backend for developers to connect and collaborate.

Topics

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •