IM Instant Messaging
Core Positioning
The IM module provides built-in instant messaging capabilities for your platform — no need to integrate third-party IM SDKs (such as Huanxin, RongCloud), directly implement private chat, group chat, channel broadcasting, and audio-video calls within your system. Particularly suitable for scenarios requiring “in-platform communication,” such as e-commerce customer service, internal enterprise communication, community private messaging, etc.
In one sentence: Let your users chat within your platform, with data and experience fully under your control.
Problems Solved
| Pain Point | How IM Solves It |
|---|---|
| Third-party IM SDK costs are high | Self-built IM, zero additional cost |
| User data stored with third parties | Chat data in your own database |
| Need to integrate with business systems | User system, friend relationships linked with business |
| Audio-video call capability | Integrated with LiveKit, supports WebRTC calls |
User Roles
graph LR
subgraph Roles
IM_USER["Regular User
Private chat/group chat
Send text/images/files/voice
Audio-video calls"] IM_ADMIN["IM Admin
Manage groups
Configure channels
Manage sensitive words
View message records"] end
Private chat/group chat
Send text/images/files/voice
Audio-video calls"] IM_ADMIN["IM Admin
Manage groups
Configure channels
Manage sensitive words
View message records"] end
Functional Architecture
graph TB
subgraph Core["Core Features"]
MSG2["Message Center
Private/Group chat
Text/Image/File/Voice/Video"] FRIEND["Friend Relationships
Add/Delete/Blocklist"] GROUP["Group Management
Create/Join/Leave/Mute"] CHANNEL["Channel Broadcasting
Announcements/Notifications"] CALL["Audio-Video Calls
Based on LiveKit
WebRTC"] end subgraph Auxiliary EMOJI["Emoji Management"] SENSITIVE["Sensitive Word Filtering"] end subgraph Communication["Communication Layer"] WS["WebSocket Real-time Communication
local / redis / rocketmq
/ kafka / rabbitmq"] end Core --> Communication Auxiliary --> Core
Private/Group chat
Text/Image/File/Voice/Video"] FRIEND["Friend Relationships
Add/Delete/Blocklist"] GROUP["Group Management
Create/Join/Leave/Mute"] CHANNEL["Channel Broadcasting
Announcements/Notifications"] CALL["Audio-Video Calls
Based on LiveKit
WebRTC"] end subgraph Auxiliary EMOJI["Emoji Management"] SENSITIVE["Sensitive Word Filtering"] end subgraph Communication["Communication Layer"] WS["WebSocket Real-time Communication
local / redis / rocketmq
/ kafka / rabbitmq"] end Core --> Communication Auxiliary --> Core
Core ER Diagram
erDiagram
IM_USER ||--o{ IM_MESSAGE : "Send"
IM_USER ||--o{ IM_FRIEND : "Friend Relations"
IM_USER ||--o{ IM_GROUP_MEMBER : "Group Members"
IM_GROUP ||--o{ IM_GROUP_MEMBER : "Contains"
IM_GROUP ||--o{ IM_MESSAGE : "Group Messages"
IM_CHANNEL ||--o{ IM_CHANNEL_MESSAGE : "Channel Messages"
IM_CHANNEL ||--o{ IM_CHANNEL_MEMBER : "Channel Members"
IM_MESSAGE {
bigint id PK
bigint from_user_id FK "Sender"
bigint to_user_id FK "Receiver"
bigint group_id FK "Group"
tinyint type "Message Type"
text content "Message Content"
datetime create_time "Send Time"
}
IM_GROUP {
bigint id PK
varchar name "Group Name"
bigint owner_user_id FK "Group Owner"
tinyint status "Status"
}
IM_CHANNEL {
bigint id PK
varchar name "Channel Name"
tinyint type "Channel Type"
}
Database Table Groups
| Group | Table Count | Description |
|---|---|---|
| Message Center | 2 tables | Message records, message conversations |
| Friend Relations | 2 tables | Friends, friend requests |
| Group Management | 3 tables | Groups, group members, group announcements |
| Channel Broadcasting | 3 tables | Channels, channel members, channel messages |
| Audio-Video Calls | 2 tables | Call records, call participants |
| Others | 4 tables | Emojis, sensitive words, etc. |
WebSocket Communication Modes
graph TB
subgraph SendMode["Message Send Modes (Switchable)"]
LOCAL["local
Standalone Mode
For development/debugging"] REDIS3["redis
Redis Broadcast
Small clusters"] ROCKET2["rocketmq
RocketMQ
High throughput"] KAFKA2["kafka
Kafka
Large scale"] RABBIT2["rabbitmq
RabbitMQ
Enterprise-grade"] end
Standalone Mode
For development/debugging"] REDIS3["redis
Redis Broadcast
Small clusters"] ROCKET2["rocketmq
RocketMQ
High throughput"] KAFKA2["kafka
Kafka
Large scale"] RABBIT2["rabbitmq
RabbitMQ
Enterprise-grade"] end
Application Scenarios
| Scenario | Usage |
|---|---|
| E-commerce Customer Service | Buyer ↔ Merchant customer service private chat |
| Enterprise Internal Communication | Employee group chat, department channels |
| Community Private Messaging | User-to-user private chat |
| Online Education | Student ↔ Teacher, course group chat + audio-video |
| Medical Consultation | Patient ↔ Doctor private chat + audio-video consultation |