Matching, conversation, realtime chat, read receipt, typing, and presence service for BeeFriends.
- Discover - returns candidate profiles for the Explore screen
- Swipe - records like/pass actions and creates matches when both users like each other
- Matches - lists active matches and supports unmatch
- Conversations - creates and retrieves user conversations
- Messages - sends messages, loads conversation history, and marks messages as read
- Realtime Chat - Socket.IO events for messages, read receipts, typing, and presence
- Profile Sync - consumes user, campus, major, and hobby events from User Service
- Pub/Sub - Redis Streams for durable events and Redis Pub/Sub for realtime fanout
| Layer | Stack |
|---|---|
| Runtime | Node.js, NestJS, TypeScript |
| Database | PostgreSQL, Prisma |
| Realtime | Socket.IO |
| Pub/Sub | Redis Streams, Redis Pub/Sub |
| Contracts | @beefriends/shared-kernel |
| Environment | Base URL |
|---|---|
| Production Gateway | https://beefriends-be.drian.my.id/v1/matchchat |
| Local | http://localhost:3003/v1/matchchat |
Swagger docs:
http://localhost:3003/v1/matchchat/docsMain routes:
| Area | Routes |
|---|---|
| Messages | /messages, /messages/conversation/:conversationId, /messages/:messageId/read |
| Conversations | /conversations, /conversations/user/:userId, /conversations/:id, /conversations/:id/messages |
| Matches | /matches/discover, /matches/swipe, /matches/user/:userId, /matches/:id |
| Filters | /matches/campuses, /matches/majors, /matches/hobbies |
| Presence | /presence/:userId, /presence/batch |
Socket.IO connects through:
https://beefriends-be.drian.my.id/socket.io/| Event | Purpose |
|---|---|
join_conversation |
Join a conversation room |
leave_conversation |
Leave a conversation room |
send_message |
Send a realtime message |
message_received |
Broadcast a new message |
message_read |
Broadcast read receipts |
typing_start |
Broadcast typing started |
typing_stop |
Broadcast typing stopped |
presence_get |
Request presence for multiple users |
presence_changed |
Broadcast online/offline changes |
Event names are exported from @beefriends/shared-kernel/dto.
BeeFriends Mobile
-> API Gateway
-> Match Chat Service
-> PostgreSQL
-> Socket.IO rooms
-> Redis Streams / Pub/SubMatch and chat events are published to pub/sub so notification and realtime listeners can react without tight coupling.
PORT=3003
API_PREFIX=v1/matchchat
API_DOCS_PATH=v1/matchchat/docs
CORS_ORIGINS=*
MATCH_CHAT_DATABASE_URL=
DATABASE_URL=
REDIS_URL=
PUBSUB_CONSUMER_ID=
PUBSUB_POLL_INTERVAL_MS=5000
PUBSUB_RECONNECT_INTERVAL_MS=5000
REDIS_STREAM_MAXLEN=10000
CHAT_MESSAGE_ENCRYPTION_KEY=MATCH_CHAT_DATABASE_URL is preferred. DATABASE_URL is accepted as a fallback by Prisma.
Use the same CHAT_MESSAGE_ENCRYPTION_KEY in services that need to decrypt chat previews.
npm install
npm run prisma:generate
npm run prisma:push
npm run start:dev| Command | Description |
|---|---|
npm run start:dev |
Start service in watch mode |
npm run build |
Compile NestJS app |
npm run start:prod |
Run compiled app |
npm run lint |
Run ESLint with fixes |
npm run test |
Run unit tests |
npm run prisma:generate |
Generate Prisma client |
npm run prisma:migrate |
Run local Prisma migration |
npm run prisma:push |
Push schema to database |
npm run prisma:studio |
Open Prisma Studio |