A robust RESTful API for a professional networking and dating platform, built with Node.js, Express, and MongoDB. Features real-time chat, advanced authentication, email notifications, and automated scheduling.
π Live API: linkdev.online
- π JWT Authentication & Authorization - Secure token-based auth with cookie management
- π€ User Management - Complete CRUD operations with profile customization
- π€ Connection System - Send, accept, reject connection requests
- π¬ Real-time Chat - Instant messaging using Socket.io
- π§ Email Notifications - Automated emails via AWS SES
- β° Scheduled Tasks - Cron jobs for daily connection digests
- π Advanced Queries - Complex MongoDB aggregations and filtering
- Password hashing with bcrypt
- Data validation with Mongoose and validator.js
- Custom middleware for authentication and error handling
- MongoDB indexing for optimized queries
- RESTful API design with proper HTTP methods
- Comprehensive error handling and logging
- Node.js
- Express.js
- MongoDB (MongoDB Atlas)
- Mongoose ODM
- JWT (jsonwebtoken)
- bcrypt
- cookie-parser
- validator
- Socket.io
- AWS SES (Simple Email Service)
- AWS SDK v3
- node-cron
- date-fns
- Nodemon
- Postman (API testing)
POST /signup - Register new user
POST /login - User login
POST /logout - User logout
GET /profile - Get logged-in user profile
PATCH /profile/edit - Update profile details
PATCH /profile/password - Change password
POST /request/send/:status/:userId - Send connection request
POST /request/review/:status/:requestId - Accept/reject request
GET /user/requests/received - Get pending requests
GET /user/connections - Get all connections
GET /feed?page=1&limit=10 - Get user feed with pagination
GET /user/:id - Get user by ID
GET /user/email/:email - Get user by email
DELETE /user/:id - Delete user
PATCH /user/:id - Update user
- firstName, lastName (required, min: 4, max: 50)
- emailId (required, unique, lowercase, validated)
- password (required, min: 8, validated)
- age (min: 18)
- gender (custom validation)
- photoUrl (validated URL)
- about (max: 200)
- skills (array, max: 10 skills)
- timestamps (createdAt, updatedAt)
- fromUserId (ref: User)
- toUserId (ref: User)
- status (interested, ignored, accepted, rejected)
- timestamps
- Compound index on fromUserId + toUserId
- Platform: AWS EC2 (Ubuntu)
- Process Manager: PM2
- Reverse Proxy: Nginx
- Domain: linkdev.online
- SSL: Enabled via Cloudflare
Frontend (React) β Nginx (Port 80) β linkdev.online
Backend (Node.js) β PM2 (Port 7777) β linkdev.online/api
Database (MongoDB) β MongoDB Atlas β Cloud hosted
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;
}- Node.js (v16.17.0 or higher)
- MongoDB Atlas account
- AWS account (for SES)
# Clone the repository
git clone https://github.com/Dhruv-Raichand/devlink-backend.git
cd devlink-backend
# Install dependencies
npm install
# Create .env file
cp .env.example .env
# Add your environment variables
DATABASE_URL=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
AWS_REGION=your_aws_region
SENDER_EMAIL=your_verified_ses_email
# Start development server
npm run devDATABASE_URL=mongodb+srv://...
JWT_SECRET=your_secret_key
PORT=7777
COOKIE_DOMAIN=localhost
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret
AWS_REGION=ap-south-1
SENDER_EMAIL=noreply@linkdev.onlinenpm start # Start production server
npm run dev # Start development server with nodemon
npm test # Run tests (if configured)# Start application
pm2 start npm --name "devlink-backend" -- start
# View logs
pm2 logs devlink-backend
# Monitor
pm2 monit
# Restart
pm2 restart devlink-backend
# Stop
pm2 stop devlink-backend
# Delete
pm2 delete devlink-backend- Password hashing with bcrypt (10 salt rounds)
- JWT tokens with 7-day expiry
- HTTP-only cookies for token storage
- Input validation and sanitization
- MongoDB injection prevention
- Rate limiting ready
- CORS configuration with credentials
- Authentication middleware
- Error handling middleware
- Request validation middleware
- Compound indexes for frequent queries
- Pre-save hooks for password hashing
- Population for related documents
- Query operators ($or, $and, $nin, $ne)
- Pagination logic:
skip = (page - 1) * limit - JWT token generation and verification
- Socket.io for real-time communication
- Cron jobs for scheduled tasks
- AWS SES integration for emails
Frontend Repository: DevLink Frontend
Import the Postman collection for testing all endpoints:
- Authentication flows
- CRUD operations
- Connection request handling
- Feed pagination
- Real-time chat
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
Dhruv Raichand
- GitHub: @Dhruv-Raichand
- Website: linkdev.online
- MongoDB for excellent documentation
- AWS for reliable cloud services
- Socket.io for real-time capabilities
- Express.js community
Built with π» and β by Dhruv Raichand