Skip to content

quckapp/backend-gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

QuckApp Backend

Production-ready NestJS backend for QuckApp - a real-time chat application with audio/video calling capabilities.

TypeScript NestJS MongoDB Socket.io Docker

πŸš€ Features

  • βœ… JWT Authentication - Secure authentication with refresh tokens
  • βœ… Real-time Messaging - Socket.io for instant messaging
  • βœ… WebRTC Signaling - Audio and video calling support
  • βœ… End-to-End Encryption - AES encryption for messages
  • βœ… File Upload - Images, videos, audio, and files
  • βœ… Push Notifications - Firebase Cloud Messaging integration
  • βœ… Message Features - Reactions, read receipts, typing indicators
  • βœ… Group Chat - Create and manage group conversations
  • βœ… MongoDB - Scalable NoSQL database with Mongoose
  • βœ… Docker Support - Easy deployment with Docker Compose

πŸ“‹ Prerequisites

  • Node.js 18+ or 20+
  • MongoDB 5+ or 7+
  • npm or yarn

πŸ› οΈ Installation

  1. Clone the repository
git clone https://github.com/QuckApp/quckapp-backend.git
cd quckapp-backend
  1. Install dependencies
npm install
  1. Configure environment variables
cp .env.example .env

Edit .env file with your configuration:

MONGODB_URI=mongodb://localhost:27017/quckapp
JWT_SECRET=your-super-secret-jwt-key
JWT_REFRESH_SECRET=your-refresh-secret-key
ENCRYPTION_KEY=your-32-character-encryption-key
  1. Start MongoDB
# Using Docker
docker-compose up -d mongodb

# Or use local MongoDB installation
  1. Run the application
# Development
npm run start:dev

# Production
npm run build
npm run start:prod

The server will start at http://localhost:3000

🐳 Docker Deployment

# Start both MongoDB and backend
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down

πŸ“š API Documentation

Authentication

  • POST /api/v1/auth/register - Register new user
  • POST /api/v1/auth/login - Login
  • POST /api/v1/auth/refresh - Refresh access token

Users

  • GET /api/v1/users/me - Get current user profile
  • PUT /api/v1/users/me - Update profile
  • GET /api/v1/users/search?q=query - Search users

Conversations

  • GET /api/v1/conversations - Get user conversations
  • POST /api/v1/conversations/single - Create single conversation
  • POST /api/v1/conversations/group - Create group conversation

Messages

  • GET /api/v1/messages/conversation/:id - Get conversation messages
  • PUT /api/v1/messages/:id - Edit message
  • DELETE /api/v1/messages/:id - Delete message

Upload

  • POST /api/v1/upload/image - Upload image
  • POST /api/v1/upload/video - Upload video
  • POST /api/v1/upload/audio - Upload audio
  • POST /api/v1/upload/file - Upload file

πŸ”Œ WebSocket Events

Chat Namespace (/chat)

Client β†’ Server:

  • message:send - Send message
  • message:edit - Edit message
  • message:delete - Delete message
  • message:reaction:add - Add reaction
  • typing:start - Start typing
  • typing:stop - Stop typing
  • message:read - Mark message as read

Server β†’ Client:

  • message:new - New message received
  • message:edited - Message edited
  • message:deleted - Message deleted
  • typing:start - User started typing
  • user:online - User came online
  • user:offline - User went offline

WebRTC Namespace (/webrtc)

Client β†’ Server:

  • call:initiate - Start a call
  • call:answer - Answer incoming call
  • call:reject - Reject incoming call
  • call:end - End active call
  • webrtc:offer - Send WebRTC offer
  • webrtc:answer - Send WebRTC answer
  • webrtc:ice-candidate - Send ICE candidate

Server β†’ Client:

  • call:incoming - Incoming call notification
  • call:participant:joined - Participant joined call
  • call:ended - Call ended
  • webrtc:offer - Receive WebRTC offer
  • webrtc:answer - Receive WebRTC answer

πŸ—οΈ Project Structure

src/
β”œβ”€β”€ common/
β”‚   └── logger/              # Winston logger service
β”œβ”€β”€ gateways/
β”‚   β”œβ”€β”€ chat.gateway.ts      # Real-time messaging
β”‚   └── webrtc.gateway.ts    # WebRTC signaling
β”œβ”€β”€ modules/
β”‚   β”œβ”€β”€ auth/                # Authentication module
β”‚   β”œβ”€β”€ users/               # Users module
β”‚   β”œβ”€β”€ conversations/       # Conversations module
β”‚   β”œβ”€β”€ messages/            # Messages module
β”‚   β”œβ”€β”€ upload/              # File upload module
β”‚   └── notifications/       # Push notifications module
β”œβ”€β”€ app.module.ts
└── main.ts

πŸ” Security Features

  • JWT authentication with refresh tokens
  • Password hashing with bcrypt
  • Message encryption (AES)
  • Input validation with class-validator
  • Rate limiting
  • CORS protection
  • Helmet security headers

🌐 Environment Variables

See .env.example for all configuration options:

  • NODE_ENV - Environment (development/production)
  • PORT - Server port (default: 3000)
  • MONGODB_URI - MongoDB connection string
  • JWT_SECRET - JWT secret key
  • JWT_REFRESH_SECRET - Refresh token secret
  • ENCRYPTION_KEY - Message encryption key
  • FIREBASE_* - Firebase credentials for push notifications
  • TURN_SERVER_URL - TURN server for WebRTC
  • STUN_SERVER_URL - STUN server for WebRTC

πŸ“± Mobile App

This backend works with our React Native mobile app: πŸ‘‰ QuckApp Mobile

πŸ§ͺ Testing

# Unit tests
npm run test

# E2E tests
npm run test:e2e

# Test coverage
npm run test:cov

πŸ“„ License

MIT

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“ž Support

For issues and questions, please open an issue on GitHub.


Built with ❀️ using NestJS, Socket.io, and WebRTC

About

Backend Gateway - API gateway and request routing for microservices

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages