A powerful real-time communication server supporting audio/video calls, chat, and file sharing. Built with modern technologies and best practices for scalability and performance.
- JWT-based authentication
- Role-based access control
- Secure password hashing
- CORS protection
- Text chat with typing indicators
- Audio/Video calls using WebRTC
- File sharing & image uploads
- Presence detection
- Kafka integration for distributed events
- Socket.IO for real-time communication
- Horizontal scaling support
- Redis for session management
- TypeScript for type safety
- Swagger API documentation
- Prisma ORM for database operations
- Husky for git hooks
- Node.js (v18.x or later)
- PostgreSQL (v14.x or later)
- Kafka cluster
- Redis (optional, for session storage)
-
Clone the repository
git clone https://github.com/sarwar-asik/study-live-server cd study-live-server
-
Install dependencies
npm install
-
Set up environment variables Create a
.env
file in the root directory (see Environment Variables section below) -
Run database migrations
npx prisma migrate dev
-
Start the server
# Development npm run dev # Production npm run build npm start
Create a .env
file in the root directory with the following variables:
# Server Configuration
PORT=5000
NODE_ENV=development
SERVER_NAME=study-live-server
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/dbname"
# Authentication
JWT_SECRET=your-jwt-secret
JWT_EXPIRES_IN=7d
BCRYPT_SALT_ROUNDS=12
# Admin Credentials
SUPER_ADMIN_EMAIL=[email protected]
SUPER_ADMIN_PASSWORD=admin123
DEFAULT_STUDENT_PASS=student123
# Cloudinary Configuration
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret
# Kafka Configuration
KAFKA_CLIENT_ID=study-live-server
KAFKA_BROKERS=kafka://kafka-0.kafka.svc.cluster.local:9092,kafka-1.kafka.svc.cluster.local:9092
# Frontend URL (CORS)
FRONTEND_URL=http://localhost:3000
POST /api/auth/sign-up
- Register new userPOST /api/auth/login
- User loginGET /api/auth/profile
- Get user profileGET /api/user/:id
- Get user details
POST /api/messages
- Send messagePOST /api/messages/image
- Send message with imageGET /api/messages
- Get conversation history
send-message
- Send chat messagenew-message
- Receive new messagetyping
- User typing indicator
join-room
- Join video chat roomoffer
- WebRTC offeranswer
- WebRTC answerice-candidate
- ICE candidate exchange
room-join
- Room join eventsroom-leave
- Room leave eventswebrtc-offer
- WebRTC offerswebrtc-answer
- WebRTC answersice-candidate
- ICE candidates
- JWT authentication
- Request validation using Zod
- CORS protection
- Rate limiting
- Secure password hashing
- Input sanitization
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
-
Build the application:
npm run build
-
Start the production server:
npm start
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
For support, email [email protected] or join our Slack channel.