Skip to content

Lab 3 - JavaFX Chat Application (Updated)#35

Closed
gitnes94 wants to merge 7 commits intomainfrom
labb3
Closed

Lab 3 - JavaFX Chat Application (Updated)#35
gitnes94 wants to merge 7 commits intomainfrom
labb3

Conversation

@gitnes94
Copy link

@gitnes94 gitnes94 commented Nov 17, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Launched Java 2025 Chat Application with a Sakura-themed interface
    • Added file attachment support for sharing files in conversations
    • Implemented real-time message sending and receiving capabilities
    • Added online/offline status indicator
  • Chores

    • Updated project dependencies for improved stability
    • Enhanced configuration management with environment variable support

@coderabbitai
Copy link

coderabbitai bot commented Nov 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR transforms the project from a basic JavaFX template into a fully-featured chat application with network capabilities. It introduces a chat UI layer, model classes for messages, a Ntfy-based network client for sending/receiving messages and files, environment configuration loading, updated dependencies (Jackson, WireMock, JUnit 5), and comprehensive module-level exports and requires declarations.

Changes

Cohort / File(s) Summary
Configuration & Metadata
.gitignore, ntfy-server.yml, pom.xml, src/main/java/module-info.java
Extended gitignore with environment patterns; added Ntfy server configuration; updated Maven to include JavaFX 21.0.3, Jackson, WireMock, and JUnit 5; refactored module exports/requires for chat application packages and network libraries
Documentation & Application Bootstrap
README.md, src/main/java/com/example/HelloFX.java
Added Author section; updated app entry point to load environment variables, switch FXML from hello-view to ChatView, and change window title
Legacy Model & Controller Cleanup
src/main/java/com/example/HelloController.java, src/main/java/com/example/HelloModel.java
Removed Javadoc comments; no functional changes
Chat UI & Controller
src/main/resources/com/example/ChatView.fxml, src/main/java/com/example/controller/ChatController.java
New Sakura-themed chat interface with message list, input, file attach, and send buttons; ChatController wires UI components, manages async send/file operations, and updates connection status
Chat Model & Message Entity
src/main/java/com/example/model/ChatModel.java, src/main/java/com/example/model/NtfyMessage.java
New ChatModel initializes Ntfy client, exposes observable messages list, provides send/file-upload methods; new NtfyMessage record with Jackson support and convenience constructors
Network Layer
src/main/java/com/example/network/ChatNetworkClient.java, src/main/java/com/example/network/NtfyHttpClient.java
New interface defining send, sendFile, and subscribe contract; NtfyHttpClient implements HTTP-based operations with JSON serialization and long-running subscription streams
Utilities
src/main/java/com/example/util/EnvLoader.java
New utility to load .env file and populate system properties
Tests
src/test/java/com/example/model/ChatModelTest.java, src/test/java/com/example/model/NtfyMesageTest.java
Unit tests for NtfyMessage construction, serialization, and field handling

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChatUI as ChatView (UI)
    participant ChatCtrl as ChatController
    participant ChatModel
    participant NetworkClient as NtfyHttpClient
    participant NtfyServer as Ntfy Server

    rect rgb(230, 245, 230)
    Note over User,NtfyServer: Send Message Flow
    User->>ChatUI: Enter text & click Send
    ChatUI->>ChatCtrl: handleSendButtonAction()
    ChatCtrl->>ChatModel: sendMessage(text)
    ChatModel->>ChatModel: Create NtfyMessage
    ChatModel->>NetworkClient: send(baseUrl, message)
    NetworkClient->>NtfyServer: POST /topic (JSON)
    NtfyServer-->>NetworkClient: 200 OK
    ChatCtrl->>ChatUI: Clear input, update status
    end

    rect rgb(245, 230, 230)
    Note over User,NtfyServer: Receive Message Flow (Async Subscription)
    ChatModel->>NetworkClient: subscribe(baseUrl, topic, onMessage, onError)
    NetworkClient->>NtfyServer: GET /topic/json (stream)
    NtfyServer-->>NetworkClient: Lines of NtfyMessage JSON
    NetworkClient->>ChatModel: onMessage(NtfyMessage)
    ChatModel->>ChatModel: Post to JavaFX Thread
    ChatModel->>ChatUI: Update messages list
    ChatUI->>User: Display new message with emoji prefix
    end

    rect rgb(245, 240, 230)
    Note over User,NtfyServer: File Upload Flow
    User->>ChatUI: Select file & click Attach
    ChatUI->>ChatCtrl: handleAttachFileAction()
    ChatCtrl->>ChatModel: sendFile(file)
    ChatModel->>NetworkClient: sendFile(baseUrl, topic, file)
    NetworkClient->>NtfyServer: PUT /topic (file bytes)
    NtfyServer-->>NetworkClient: 200 OK
    ChatModel->>ChatModel: Post formatted file message
    ChatModel->>ChatUI: Update messages list
    ChatUI->>User: Display file message (name + size)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • NtfyHttpClient implementation: HTTP streaming with Jackson deserialization, error handling, and long-running subscription threads—requires careful review of stream management and error propagation
  • ChatController async operations: Multiple Task-based async workflows for sending/uploading with success/failure callbacks and UI state updates—verify thread safety and resource cleanup
  • ChatModel integration: Network client initialization, observable list updates from async threads, environment-based configuration—ensure thread-safe message delivery
  • Module configuration: Exports, requires, and opens for Jackson/network libraries—validate that module declarations are consistent with usage
  • FXML binding: UI component wiring via @FXML and controller references—verify all fx:id and method bindings are correct

Possibly related PRs

  • setup #27: Both PRs introduce overlapping chat-related classes (ChatController, ChatModel, NtfyMessage) and update HelloFX, module-info, and UI resources; indicates parallel or dependent chat feature implementation.

Poem

🐰 Hoppy times with threads that stream,
Messages flow like carrot dreams!
Sakura blooms on chat so bright,
Network hops from left to right. ✨🌸

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between daa1037 and 35286d5.

📒 Files selected for processing (17)
  • .gitignore (1 hunks)
  • README.md (1 hunks)
  • ntfy-server.yml (1 hunks)
  • pom.xml (1 hunks)
  • src/main/java/com/example/HelloController.java (0 hunks)
  • src/main/java/com/example/HelloFX.java (1 hunks)
  • src/main/java/com/example/HelloModel.java (1 hunks)
  • src/main/java/com/example/controller/ChatController.java (1 hunks)
  • src/main/java/com/example/model/ChatModel.java (1 hunks)
  • src/main/java/com/example/model/NtfyMessage.java (1 hunks)
  • src/main/java/com/example/network/ChatNetworkClient.java (1 hunks)
  • src/main/java/com/example/network/NtfyHttpClient.java (1 hunks)
  • src/main/java/com/example/util/EnvLoader.java (1 hunks)
  • src/main/java/module-info.java (1 hunks)
  • src/main/resources/com/example/ChatView.fxml (1 hunks)
  • src/test/java/com/example/model/ChatModelTest.java (1 hunks)
  • src/test/java/com/example/model/NtfyMesageTest.java (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gitnes94 gitnes94 closed this Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant