How bluexsx/box-im works
Project type and purpose
• This is a full-stack, WeChat-like instant-messaging system (“盒子IM”) supporting web (Vue), mobile (uniapp) and Java SDK clients.
• Core modules:
• im-web (Vue web client)
• im-uniapp (cross-platform mobile/hybrid client)
• im-platform (Spring Boot business API service)
• im-server (Netty-based message push service)
• im-client (Java SDK to push messages into im-server)
• im-common (shared library)
• DB scripts under db/
File-structure indicators
• Top-level directories map to independent deployable modules (microservices + front-ends).
• im-platform and im-server are Spring Boot JARs with their own configurations, controllers, services, mappers.
• im-web and im-uniapp are separate front-end codebases.
• Redis and MinIO configs appear in im-platform; Netty code under im-server.
Key README insights
• Front-ends talk HTTP to im-platform for business data (login, friends, groups, file uploads).
• im-platform uses im-client SDK to deliver messages to im-server.
• im-server is cluster-aware, uses Redis lists and a “im:unread:${serverId}” queue scheme for cross-node delivery.
• Persistence: MySQL (im_platform DB).
• File storage: MinIO.
• Real-time push: WebSocket / TCP (Netty).
• Clients (blue rectangles):
• Web browser (Vue im-web)
• Mobile/hybrid app (uniapp im-uniapp)
• Java backend clients (im-client SDK)
• im-platform cluster (multiple Spring Boot instances behind HTTP LB)
• im-server cluster (multiple Netty WS/TCP servers behind TCP/WS LB)
• MySQL
• Redis (pub/sub + lists)
• MinIO (object storage)
• Optional Load Balancer (Nginx or TCP/WS LB)
1. Clients → HTTP LB → im-platform: REST/HTTP for business operations.
2. im-platform → MySQL: persist user/groups/messages.
3. im-platform → MinIO: upload/download files.
4. im-platform → Redis: caching, locking, pub/sub, queue writes (im-client SDK posts to Redis list).
5. im-server ↔ Redis:
• Pushers (im-platform/im-client) write to per-server Redis lists (“im:unread:${serverId}”).
• im-server pool polls its own list to fetch messages for connected users.
• Redis also holds user→server mapping for live connections.
6. Clients ↔ im-server: persistent WebSocket/TCP connections; Netty handles protocol encoding/decoding and dispatches to processors.
c. Architectural patterns & principles
• Separation of concerns: business API vs. real-time push.
• Microservices-style modules enabling independent scaling (im-platform vs. im-server).
• Event-driven messaging via Redis lists for cross-node coordination.
• Spring Boot + Netty for reactive, non-blocking I/O.
• Clustered Redis for high availability.
• Horizontal scalability: multiple im-platform and im-server instances behind load balancers.
d. Technologies & frameworks
• Front-end: Vue.js, uniapp (h5/app/miniprogram), WebSocket/TCP clients delivered via JavaScript or im-client SDK.
• Backend: Java 17, Spring Boot 3.x, MyBatis mappers, Spring AOP (annotations for locks, repeat submits, online checks), RedisTemplate, MinIO Java client.
• Messaging: Netty (custom protocol over WS/TCP), Redis as message queue and connection registry.
• Storage: MySQL 8.x, MinIO.
Detail level
• Redis roles: caching vs. message queue vs. connection registry.
• Im-client SDK as part of im-platform’s message-push pipeline.
• If desired, break out im-common as a library dependency for back-ends but not as a runtime component.