An open API service indexing awesome lists of open source software.

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.

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