This project implements a comprehensive distributed chat system using:
- Vert.x for event-driven architecture and async processing
- RabbitMQ as the message broker for reliable message delivery
- JavaFX for rich desktop client UI with modern interface
The system supports:
- β Real-time text messaging (1-to-1 and group chat)
- β File sharing with preview and download capabilities
- β Image sharing with inline preview and full-screen view
- β Group chat management (create, join, leave groups)
- β Message editing functionality
- β Multiple concurrent users with unique ID system
- β User registration with UUID generation
- β File type detection with appropriate icons
- β Monitoring / Logging
UI:
graph TD
A[Client 1] -->|Publish| B[RabbitMQ Exchange]
C[Client 2] -->|Publish| B
D[Client 3] -->|Publish| B
B -->|Route| E[Server Verticle]
E -->|Group Messages| F[Group Queue]
E -->|Direct Messages| G[User Queue]
F -->|Broadcast| H[Group Members]
G -->|Forward| I[Target User]
style D stroke-width:2px, stroke-dasharray: 2
style B fill:#ff9999
style E fill:#99ccff
style F fill:#99ff99
style G fill:#ffcc99
classDef whiteText color:#000000
class B,E,F,G whiteText
classDef blackOutline stroke:#ffffff
class A,B,C,D,E,F,G blackOutline
-
Server Verticle (
ServerVerticle.kt):- Manages user registration with collision detection
- Routes messages between users and groups
- Handles group operations (create, join, leave)
- Manages message editing and history
- Uses dedicated RabbitMQ queues for each operation type
-
Client Verticle (
ClientVerticle.kt):- Manages connection to RabbitMQ broker
- Handles real-time message receiving
- Processes different message types (text, file, image, group operations)
- Maintains user session and authentication state
-
Chat UI (
ChatUI.kt):- Modern JavaFX interface with tabbed layout
- File/Image preview before sending
- Group management dialog
- Message editing capabilities
- Drag-and-drop file support
- Responsive design with proper layouts
-
Group Manager (
Group.kt):- Complete group chat functionality
- Create groups with unique IDs
- Join/leave group operations
- Member management
- Group message broadcasting
sequenceDiagram
participant C as Client
participant S as Server
participant R as RabbitMQ
C->>R: Register request (username + UUID)
R->>S: Forward to registration queue
S->>S: Check ID collision
alt ID Available
S->>R: Send back confirmation
R->>C: Registration successful
else ID Exists
S->>R: Send error response
R->>C: Registration failed
end
sequenceDiagram
participant C1 as Sender
participant R as RabbitMQ
participant S as Server
participant C2 as Receiver
C1->>R: Send message (to: userID, content)
R->>S: Route to message queue
S->>S: Validate sender & recipient
S->>R: Forward to recipient queue
R->>C2: Deliver message with metadata
C2->>C2: Display in chat UI
sequenceDiagram
participant C1 as Group Member 1
participant S as Server
participant C2 as Group Member 2
participant C3 as Group Member 3
C1->>S: Send group message
S->>S: Identify group members
par Broadcast to all members
S->>C2: Forward message
and
S->>C3: Forward message
end
Note over C2,C3: Sender excluded from broadcast
- Java 11+ (with JavaFX support)
- RabbitMQ Server (running on default port 5672)
- Gradle or Maven for dependency management
# Set RabbitMQ host (optional, defaults to localhost)
export RABBITMQ_HOST=your_rabbitmq_host
# For production deployment
export RABBITMQ_HOST=production-rabbitmq-server.com- Start RabbitMQ Server:
# Using Docker
docker run -d --hostname rabbitmq --name rabbitmq-server -p 5672:5672 -p 15672:15672 rabbitmq:3-management
# Or using local installation
sudo systemctl start rabbitmq-server- Launch the Application:
// Main application entry point
fun main() {
Application.launch(ChatApp::class.java)
}The system automatically:
- Deploys server verticle
- Creates multiple client instances for testing
- Sets up all necessary RabbitMQ queues and exchanges
| Message Type | Route Key | JSON Format | Description |
|---|---|---|---|
| Registration | register |
{username, uuid} |
User registration with custom/generated ID |
| Text Message | message |
{toId, message, messageId} |
Direct or group text messages |
| File Sharing | file |
{toId, file, data(base64)} |
File attachments with base64 encoding |
| Image Sharing | image |
{toId, image(base64)} |
Image files with preview support |
| Message Edit | edit |
{messageId, newContent} |
Edit existing messages |
| Group Create | create_group |
{groupId, groupName, createdBy} |
Create new group chats |
| Group Join | join_group |
{groupId} |
Join existing groups |
| Group Leave | leave_group |
{groupId} |
Leave group chats |
- Preview: View files and images before sending
- Type Detection: Automatically detect file types with icons (π PDF, π DOC, π XLS, etc.)
- Downloadable: Recipients can download shared files
- Image Viewer: Full-screen image viewing with copy-to-clipboard support
- Dynamic Groups: Create groups with custom names and auto-generated IDs
- Join/Leave Events: Real-time notifications for member activity
- Group Persistence: Groups remain active until the last member leaves
- Broadcast Messaging: Efficiently send messages to all group members
- Edit: Users can edit their own sent messages
- History: Message history and edits are tracked
- Delivery Status: Visual indicators for message delivery
- Timestamps: Server-generated timestamps for all messages
- Modern UI: Clean JavaFX interface with intuitive controls
- Live Updates: Instant message rendering with smooth scrolling
- User Info: Display user UUID with copy functionality
- Notifications: Toast notifications for system events
- Responsive Layout: UI adapts to window size dynamically
- Dynamic Creation: Queues created on demand for new users
- Auto Cleanup: Automatically remove unused queues
- Durability: RabbitMQ durability ensures message reliability
- Error Handling: Robust error handling for connection failures
- Thread-Safe: Use of
ConcurrentHashMapfor user/group tracking - UI Threading: Proper use of
Platform.runLater()for UI updates - Async: Vert.x event loop ensures non-blocking operations
- UUID Authentication: Unique ID system for user identity
- Validation: Server-side validation of all messages
- Access Control: Users can only edit their own messages
- Group Security: Group messages are only delivered to members
The system includes robust handling for:
- Connection Failures: Automatic reconnection to RabbitMQ
- Invalid Messages: Malformed JSON or missing fields
- User Conflicts: Prevent duplicate UUID registrations
- File Transfer Issues: Graceful handling of large/corrupted files
- UI Exceptions: Display error messages in the JavaFX interface
Potential upcoming features:
- Message Encryption β End-to-end secure communication
- Voice Messages β Audio recording and playback
- User Presence β Online/offline status indicators
- Reactions β Emoji responses to messages
- File Streaming β Large file transfer with progress indicators
- Database Integration β Persistent message storage
- Web Client β Browser-based client with WebSocket
- Mobile Support β Cross-platform mobile apps

