Multi-User Video Chat Application using NestJS, TypeScript, TypeORM, Socket.IO, WebRTC
MiniMeet is a real-time video chat application that demonstrates modern web technologies for peer-to-peer communication. The application provides text chat, video calling, and room management capabilities through a responsive web interface.
- Backend API: NestJS with TypeORM and MySQL database integration
- Authentication: JWT-based authentication with WebSocket security guards
- Real-Time Chat: Socket.IO messaging with message persistence and validation
- Video Communication: WebRTC peer-to-peer video streaming with mesh topology
- Frontend Interface: React + TypeScript client with responsive design
- Admin Panel: Development tools for user and room management
- Search Functionality: User and room search with real-time filtering
- Theme System: Dark/light theme toggle with synthwave aesthetic
Backend Services
- NestJS application server with modular architecture
- TypeORM for database operations and entity management
- Socket.IO gateway for real-time communication
- WebRTC signaling server for peer-to-peer connections
- JWT authentication with WebSocket security guards
Frontend Application
- React + TypeScript single-page application
- Socket.IO client for real-time updates
- WebRTC implementation for video streaming
- Responsive design with mobile support
- Theme system with dark/light mode toggle
Data Storage
- MySQL database for user accounts, rooms, and messages
- In-memory session management for active connections
- Message history persistence with search capabilities
- JWT-based authentication system
- User registration and profile management
- Session management with automatic token refresh
- Admin panel for user administration (development mode)
- Create and join video chat rooms
- Real-time participant tracking
- Room search functionality
- Automatic cleanup of inactive rooms
- Real-time text messaging with Socket.IO
- Message history persistence and retrieval
- Message search functionality
- WebRTC peer-to-peer video calls
- Mesh topology for multi-participant video
- Audio/video controls (mute, camera toggle)
- Responsive design for desktop and mobile
- Dark and light theme support
- Synthwave-inspired visual design
- Modal sidebar for in-room experience
- Real-time status indicators
- Search bars for users and rooms
- NestJS: Application framework with dependency injection
- TypeScript: Type-safe development environment
- TypeORM: Database ORM with entity relationships
- Socket.IO: Real-time bidirectional communication
- MySQL: Relational database for data persistence
- JWT: Token-based authentication system
- Class Validator: DTO validation and sanitization
- React: Component-based user interface library
- TypeScript: Static type checking for JavaScript
- Socket.IO Client: Real-time communication with server
- WebRTC: Peer-to-peer video and audio streaming
- CSS3: Modern styling with custom properties
- Responsive Design: Mobile-first approach
- Docker Compose: Containerized development environment
- ESLint: Code quality and consistency
- Prettier: Code formatting
- Hot Reload: Development server with live updates
βββββββββββββββββββββββ βββββββββββββββββββββββββββββββ
β React Frontend β β NestJS Backend β
β β β β
β βββββββββββββββββ β β ββββββββββββββββββββββββββββ
β β Chat Interfaceβ βββββΊβ β Socket.IO Gateway ββ
β βββββββββββββββββ β β β (Real-time Events) ββ
β βββββββββββββββββ β β ββββββββββββββββββββββββββββ
β β Video Calling β βββββΊβ ββββββββββββββββββββββββββββ
β βββββββββββββββββ β β β WebRTC Signaling ββ
β βββββββββββββββββ β β β (Video Streams) ββ
β β Admin Panel β βββββΊβ ββββββββββββββββββββββββββββ
β βββββββββββββββββ β β βββββββββββ¬ββββββββββ¬βββββββ
βββββββββββββββββββββββ β β Auth β Rooms βMsgs ββ
β β Service β Service βSvc ββ
β βββββββββββ΄ββββββββββ΄βββββββ
βββββββββββββββββββββββββββββββ
β
ββββββββββΌβββββββββ
β MySQL Database β
β (TypeORM) β
βββββββββββββββββββ
User Authentication:
Client β JWT Request β NestJS Auth β Database β JWT Token β Client
Real-time Chat:
Client β Socket.IO β Message Gateway β Database β Broadcast β All Clients
Video Calling:
Client A β WebRTC Offer β Signaling Server β Client B
Client B β WebRTC Answer β Signaling Server β Client A
Direct P2P Connection Established
Room Management:
Client β Join Room β Room Service β Database Update β Participant Broadcast
src/
βββ auth/ # JWT authentication and WebSocket guards
βββ users/ # User management and profiles
βββ rooms/ # Room creation and participant management
βββ messages/ # Chat messaging with persistence
βββ video/ # WebRTC signaling gateway
βββ webrtc/ # WebRTC connection management
βββ search/ # Message and user search functionality
βββ analytics/ # Usage analytics and monitoring
βββ config/ # Application configuration
βββ common/ # Shared utilities and guards
src/
βββ components/ # React UI components
β βββ AuthSection.tsx
β βββ ChatRoom.tsx
β βββ VideoChatMesh.tsx
β βββ AdminPanel.tsx
β βββ UserSearchBar.tsx
β βββ RoomSearchBar.tsx
β βββ ThemeToggle.tsx
βββ services/ # API and Socket.IO clients
βββ hooks/ # Custom React hooks
βββ types/ # TypeScript type definitions
βββ style/ # CSS modules and themes
βββ utils/ # Utility functions
βββββββββββββββ βββββββββββββββββββ βββββββββββββββ
β User β β RoomParticipant β β Room β
βββββββββββββββ€ βββββββββββββββββββ€ βββββββββββββββ€
β id (PK) ββββββΊβ userId (FK) ββββββΊβ id (PK) β
β username β β roomId (FK) β β name β
β email β β joinedAt β β createdAt β
β createdAt β βββββββββββββββββββ β maxUsers β
βββββββββββββββ βββββββββββββββ
β β
β β
βΌ βΌ
βββββββββββββββ βββββββββββββββ
β Message β β CallSession β
βββββββββββββββ€ βββββββββββββββ€
β id (PK) β β id (PK) β
β content β β roomId (FK) β
β senderId(FK)β β startedAt β
β roomId (FK) β β endedAt β
β timestamp β β participantsβ
βββββββββββββββ βββββββββββββββ
Authentication
POST /auth/token- Generate JWT token for userGET /auth/validate- Validate existing token
Users
GET /users- List all users (admin)POST /users- Create new user (admin)PUT /users/:id- Update user (admin)DELETE /users/:id- Delete user (admin)
Rooms
GET /rooms- List all roomsPOST /rooms- Create new room (admin)PUT /rooms/:id- Update room (admin)DELETE /rooms/:id- Delete room (admin)
Messages
GET /messages/:roomId- Get room message historyPOST /messages/search- Search messages by content
Room Management
joinRoom- Join a chat roomleaveRoom- Leave current roomparticipantsUpdate- Broadcast participant changes
Messaging
sendMessage- Send chat messagenewMessage- Receive new messagesloadMessageHistory- Load chat historymessageError- Handle message validation errors
WebRTC Signaling
webrtc-offer- Initiate video callwebrtc-answer- Respond to video callice-candidate- Exchange network informationcall-ended- Handle call termination
- Node.js 16+ and npm
- MySQL 8.0+
- Modern web browser with WebRTC support
- Clone the repository
git clone <repository-url>
cd minimeet- Install dependencies
# Backend
cd minimeet-server
npm install
# Frontend
cd ../minimeet-client
npm install- Configure database
# Create MySQL database
mysql -u root -p
CREATE DATABASE minimeet;- Set environment variables
# minimeet-server/.env
DATABASE_HOST=localhost
DATABASE_PORT=3306
DATABASE_USERNAME=root
DATABASE_PASSWORD=your_password
DATABASE_NAME=minimeet
JWT_SECRET=your_jwt_secret- Start the application
# Start backend (from minimeet-server)
npm run start:dev
# Start frontend (from minimeet-client)
npm start- Authentication: Enter a user ID and generate an authentication token
- Connection: Connect to the server using the generated token
- Join Room: Enter a room ID or search for existing rooms
- Chat: Send and receive real-time messages
- Video Call: Start video calls with other participants
- Admin Panel: Access development tools (development mode only)
# Backend tests
cd minimeet-server
npm run test
# Frontend tests
cd minimeet-client
npm test# Backend
cd minimeet-server
npm run build
# Frontend
cd minimeet-client
npm run build# Start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down
# Rebuild containers
docker-compose up --buildBackend Environment Variables
# Database Configuration
DATABASE_HOST=localhost
DATABASE_PORT=3306
DATABASE_USERNAME=root
DATABASE_PASSWORD=your_password
DATABASE_NAME=minimeet
# Authentication
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=24h
# Server Configuration
PORT=3001
CORS_ORIGIN=http://localhost:3000
# WebSocket Configuration
SOCKET_CORS_ORIGIN=http://localhost:3000Frontend Environment Variables
# API Configuration
REACT_APP_API_URL=http://localhost:3001
REACT_APP_SOCKET_URL=http://localhost:3001
# Development Settings
REACT_APP_ENV=developmentDatabase Connection Errors
- Verify MySQL is running and accessible
- Check database credentials in environment variables
- Ensure database exists and user has proper permissions
WebRTC Connection Issues
- Check browser WebRTC support (Chrome, Firefox, Safari recommended)
- Verify HTTPS is used in production (required for WebRTC)
- Check firewall settings for UDP traffic
Socket.IO Connection Problems
- Verify CORS configuration matches frontend URL
- Check network connectivity between client and server
- Ensure WebSocket support is enabled
Authentication Failures
- Verify JWT secret is consistent between requests
- Check token expiration settings
- Ensure proper token format in Authorization header
Database Performance
- Add indexes on frequently queried columns
- Implement connection pooling
- Consider read replicas for high traffic
WebRTC Optimization
- Implement TURN servers for NAT traversal
- Consider SFU architecture for large groups
- Optimize video quality based on bandwidth
Frontend Performance
- Implement lazy loading for components
- Use React.memo for expensive components
- Optimize bundle size with code splitting
Backend Deployment
# Build the application
npm run build
# Start production server
npm run start:prod
# Or use PM2 for process management
pm2 start dist/main.js --name minimeet-serverFrontend Deployment
# Build for production
npm run build
# Serve static files (using nginx, apache, or CDN)
# Build output is in the 'build' directoryDatabase Setup
-- Production database setup
CREATE DATABASE minimeet_prod;
CREATE USER 'minimeet'@'%' IDENTIFIED BY 'secure_password';
GRANT ALL PRIVILEGES ON minimeet_prod.* TO 'minimeet'@'%';
FLUSH PRIVILEGES;# docker-compose.prod.yml
version: '3.8'
services:
app:
build: .
ports:
- "3001:3001"
environment:
- NODE_ENV=production
- DATABASE_HOST=db
depends_on:
- db
db:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: secure_password
MYSQL_DATABASE: minimeet_prod
volumes:
- mysql_data:/var/lib/mysql
volumes:
mysql_data:Production Security Checklist
- Use HTTPS for all communications
- Implement rate limiting on API endpoints
- Validate and sanitize all user inputs
- Use secure JWT secrets (256-bit minimum)
- Enable CORS only for trusted domains
- Implement proper error handling (no sensitive data exposure)
- Use environment variables for all secrets
- Enable database SSL connections
- Implement proper logging and monitoring
- Regular security updates for dependencies
The application includes basic analytics tracking:
- User registration and authentication events
- Room creation and participation metrics
- Message volume and frequency
- Video call duration and quality metrics
# Check server health
curl http://localhost:3001/health
# Check database connection
curl http://localhost:3001/health/db
# Check WebSocket connectivity
curl http://localhost:3001/health/socketApplication logs include:
- Authentication events
- Room join/leave activities
- Message sending/receiving
- WebRTC connection establishment
- Error tracking and debugging information
Short Term
- File sharing in chat rooms
- Screen sharing capabilities
- Message reactions and threading
- User presence indicators
- Mobile app development
Medium Term
- SFU implementation for larger groups
- Recording and playback functionality
- Advanced admin dashboard
- Integration with external authentication providers
- API rate limiting and quotas
Long Term
- Horizontal scaling with Redis
- Advanced analytics dashboard
- Plugin system for extensions
- Enterprise features (SSO, compliance)
- AI-powered features (transcription, translation)

