https://github.com/chiragsdev/codemate-backend
Codemate is a production-grade social media platform built using the MERN stack, designed to help developers connect, collaborate, and communicate. It includes authentication, real-time chat, reminders, notifications, and payment integration โ all deployed securely using cloud infrastructure and modern DevOps practices.
https://github.com/chiragsdev/codemate-backend
aws bullmq continuous-deployment continuous-integration express mongodb nginx node-cron nodejs notifications pm2 razorpay redis websocket
Last synced: about 2 months ago
JSON representation
Codemate is a production-grade social media platform built using the MERN stack, designed to help developers connect, collaborate, and communicate. It includes authentication, real-time chat, reminders, notifications, and payment integration โ all deployed securely using cloud infrastructure and modern DevOps practices.
- Host: GitHub
- URL: https://github.com/chiragsdev/codemate-backend
- Owner: chiragsdev
- Created: 2025-04-23T09:50:33.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-07-18T11:12:47.000Z (3 months ago)
- Last Synced: 2025-08-17T22:34:09.700Z (2 months ago)
- Topics: aws, bullmq, continuous-deployment, continuous-integration, express, mongodb, nginx, node-cron, nodejs, notifications, pm2, razorpay, redis, websocket
- Language: JavaScript
- Homepage: https://codemate.tech
- Size: 217 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# ๐จโ๐ป Codemate - Connect with Coders
Codemate is a production-grade social media platform built using the MERN stack, designed to help developers connect, collaborate, and communicate. It includes authentication, real-time chat, reminders, notifications, and payment integration โ all deployed securely using cloud infrastructure and modern DevOps practices.
---
## ๐ Live Site
๐ [https://codemate.tech](https://codemate.tech)
---
## ๐ Features
- ๐ **JWT Authentication** with secure login, signup, and logout
- ๐ก๏ธ **Security**: Rate-limiting, CAPTCHA, and route protection
- ๐ฌ **Real-Time Chat** using Socket.IO for connected users
- ๐ค **Connection System**: Send and accept connection requests to chat
- ๐
**Daily Reminder Service** using `node-cron`, Redis & BullMQ to email users about pending requests
- ๐ณ **Razorpay Payment Integration** with Webhook-based order handling
- โ
**API Unit Testing** using Vitest with 80%+ code coverage
- ๐ **Production Deployment** on AWS EC2 with:
- NGINX reverse proxy
- SSL/TLS via OpenSSL & Cloudflare
- Domain: [codemate.tech](https://codemate.tech)
---
## ๐ ๏ธ Tech Stack
| Layer | Tech |
| --------------- | ---------------------------------------- |
| Frontend | React.js |
| Backend | Node.js, Express.js |
| Database | MongoDB + Mongoose |
| Auth | JWT, bcrypt, cookie-parser |
| Real-time Comm. | Socket.IO |
| Job Queue | BullMQ + Redis |
| Scheduler | Node-Cron |
| Payment Gateway | Razorpay + Webhooks |
| Email Service | Nodemailer |
| Security | express-rate-limit, CAPTCHA (Cloudflare) |
| Testing | Vitest |
| Deployment | AWS EC2, NGINX, Cloudflare SSL |
---
## ๐ค Hosting & DevOps Deployment
- ๐ **Single EC2 Instance Deployment** on AWS with both frontend and backend hosted on same machine
- ๐ **NGINX Reverse Proxy**: Routes `/api` to backend and serves React build for all other routes
- ๐ **OpenSSL Certificates**: Self-signed SSL certificates configured for HTTPS using NGINX
- ๐ฉ๏ธ **Cloudflare Integration**:
- Free SSL layer on top of server TLS
- Managed DNS and CAPTCHA protection
- ๐ **Webhook Handling**:
- Razorpay webhooks for payment validation
- Secure middleware validation of webhook signatures
- ๐ฉ **Email Queue via Redis**:
- Scalable queue-based email service using Redis + BullMQ
- Handles retries and failure states
- ๐งช **Test Coverage + CI Ready**:
- Codebase tested using Vitest
- Configured for 80%+ coverage
- Easy to plug into CI/CD pipelines
- ๐ **Job Scheduling via Node-Cron**:
- Sends reminder emails every day at 9:30 AM
- Runs as a background service
---
## ๐ System Design Highlights
Codemate is designed with **modular, scalable, and production-grade architecture** in mind:
### ๐ 1. Queue-Based Email Notification System
- Uses **Redis + BullMQ** for background jobs
- Prevents API blocking and ensures delivery via retry attempts
- Emails include daily reminders about connection requests
### ๐ฌ 2. Real-Time Messaging with Socket.IO
- Two-way real-time connection using **WebSocket protocol**
- Chat room created dynamically based on approved connection
- Enables instant dev-to-dev communication
### ๐งฑ 3. Scalable Architecture
- Backend follows **controller-service-repository pattern**
- Clear separation of concerns for maintainability
- Easily adaptable for microservices in future phases
### ๐ 4. Secure Authentication Flow
- JWT tokens are stored in **HTTP-only cookies**
- Login endpoint rate-limited to avoid brute-force attacks
- Signup integrated with CAPTCHA challenge (via Cloudflare)
### โ๏ธ 5. Background Job Scheduling
- **Node-Cron** used to run daily jobs
- Integrates with BullMQ queue for processing tasks
- Lightweight but production-ready scheduler
### ๐งช 6. API Testing & Coverage
- Every core route is covered by **Vitest unit tests**
- Can be extended with E2E and integration tests
- Ensures regression-proof development process
---
## ๐ API Endpoints
### ๐ Auth Routes
```http
POST /api/auth/login // Login (with rate-limiting)
POST /api/auth/signup // Signup (with CAPTCHA)
POST /api/auth/logout // Logout (protected route)
```
### ๐ค Connection Routes
```
POST /api/connection/send/:status/:toUserId // Send connection request
POST /api/connection/review/:status/:requestId // Accept/Reject connection request
```
### ๐งโ๐คโ๐ง User Routes
```
GET /api/user/feed // Get developer feed
GET /api/user/chat/:targetUserId // Get chat with user
GET /api/user/requests/received // Received connection requests
GET /api/user/connections // All approved connections
```
### ๐ค Profile Routes
```
GET /api/profile/view
PATCH /api/profile/edit
DELETE /api/profile/delete
```
### ๐ฐ Payment Routes
```
POST /api/payment/create // Create Razorpay order
POST /api/payment/webhook // Razorpay webhook handler
GET /api/payment/verify // Confirm payment
```
### โ
Testing
- Unit tests for backend APIs using Vitest
- Achieves 80%+ code coverage
- Ensures robustness and catches edge cases