You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cd backend
npm install
cp .env.example .env
# Fill in local values (MongoDB: localhost:27017, Redis: localhost:6379)
npm run dev
# Server starts on http://localhost:5000
Frontend
cd frontend
npm install
cp .env.example .env.local
npm run dev
# App starts on http://localhost:3000
Vercel + AWS Deployment
Frontend → Vercel
cd frontend
npm install -g vercel
vercel --prod
# Set env vars in Vercel dashboard
Backend → AWS EC2 / DigitalOcean
# On your VPS:
git clone https://github.com/yourname/echomeet
cd echomeet
docker-compose up -d mongodb redis backend nginx
# Seed DB
docker exec echomeet-backend node dist/utils/seeder.js
Stripe Webhook Setup
In Stripe Dashboard → Webhooks → Add endpoint
URL: https://yourdomain.com/api/webhooks/stripe
Events to listen for:
checkout.session.completed
customer.subscription.deleted
Copy the webhook secret to STRIPE_WEBHOOK_SECRET
Architecture
Matchmaking Algorithm
User clicks "Start Random Chat"
→ socket.emit('join_queue', { type: 'text', genderPreference: 'any' })
→ Server: findMatch() scans queue for compatible user
- Free users: any gender preference = 'any'
- Premium users: can set preference to 'male' | 'female' | 'any'
- Match check: entry1.genderPref matches entry2.gender AND vice versa
→ If match found:
- Create ChatSession in MongoDB
- Join both sockets to shared roomId
- Emit 'match_found' to both with partner info
→ If no match:
- Add to queue
- Emit 'queue_joined' with position
User → sendGift(giftId, receiverId, roomId)
→ Validate coins: user.coins >= gift.coinCost
→ Deduct coins from sender
→ Increment giftsReceived on receiver
→ Create GiftTransaction record
→ socket.emit('gift_received') to room
→ Receiver sees gift animation
API Reference
Authentication
Method
Endpoint
Description
POST
/api/auth/register
Register with username, email, password, gender
POST
/api/auth/login
Login
POST
/api/auth/logout
Logout
GET
/api/auth/me
Get current user
GET
/api/auth/verify-email/:token
Verify email
POST
/api/auth/forgot-password
Request reset
POST
/api/auth/reset-password/:token
Reset password
Users
Method
Endpoint
Description
GET
/api/users/:id
Get profile
PUT
/api/users/profile
Update profile
POST
/api/upload/avatar
Upload avatar
GET
/api/users/search?q=
Search users
POST
/api/users/:id/block
Block user
Friends
Method
Endpoint
Description
GET
/api/friends
Get friends list
GET
/api/friends/requests
Pending requests
POST
/api/friends/request/:userId
Send request
POST
/api/friends/accept/:requestId
Accept
POST
/api/friends/reject/:requestId
Reject
DELETE
/api/friends/:userId
Remove friend
Gifts & Transactions
Method
Endpoint
Description
GET
/api/gifts
All gifts
POST
/api/gifts/send
Send gift
GET
/api/transactions/coin-packs
Coin packages
POST
/api/transactions/buy-coins
Purchase coins via Stripe
POST
/api/transactions/buy-premium
Premium subscription
Admin
Method
Endpoint
Description
GET
/api/admin/stats
Platform stats
GET
/api/admin/users
All users (paginated)
POST
/api/admin/users/:id/ban
Ban/unban user
GET
/api/admin/reports
Reports queue
PUT
/api/admin/reports/:id
Update report status
Socket.io Events
Client → Server
Event
Payload
Description
join_queue
{ type, genderPreference }
Enter matchmaking
leave_queue
—
Exit queue
send_message
{ roomId, content, messageType, mediaUrl }
Send chat message
typing_start
{ roomId }
Start typing indicator
typing_stop
{ roomId }
Stop typing
send_gift
{ roomId, giftId, receiverId }
Send gift in session
end_session
{ roomId }
End chat/call
webrtc_offer
{ roomId, offer }
WebRTC offer (audio)
webrtc_answer
{ roomId, answer }
WebRTC answer
webrtc_ice_candidate
{ roomId, candidate }
ICE candidate
call_muted
{ roomId, muted }
Mute state change
start_friend_chat
{ friendId, type }
Start friend chat/call
Server → Client
Event
Payload
Description
match_found
{ roomId, sessionId, partner, type }
Match found
queue_joined
{ type, position }
Added to queue
new_message
Message
Incoming message
partner_typing
{ userId }
Partner is typing
session_ended
{ roomId, duration }
Session terminated
gift_received
{ gift, sender, receiverId }
Gift received
queue_stats
{ textQueue, audioQueue, activeSessions }
Live stats
user_online/offline
{ userId }
Presence update
friend_call_incoming
{ from, roomId, type }
Incoming friend call
Security Checklist
JWT authentication with refresh tokens
bcrypt password hashing (salt rounds: 12)
Rate limiting (express-rate-limit) on all API routes
Auth rate limiting (20 req/15min)
Helmet.js security headers
CORS configured for specific origins
Input validation (express-validator)
XSS protection headers
File upload validation (type + size limits)
WebRTC audio-only (no video stream allowed)
Socket authentication via JWT
User blocking system
Report & moderation queue
Admin-only routes protected
Stripe webhook signature verification
Performance
The system is built to handle thousands of concurrent users:
Socket.io with WebSocket + polling fallback
Redis session caching (plugged in, extend as needed)