Skip to content

MohammedMogeab/ChatSystem

Repository files navigation

JavaFX Chat System

A modern, feature-rich chat application built with JavaFX, supporting real-time private and group messaging, file sharing, media, and more. The project uses the MVC architecture and incorporates design patterns such as Observer and Factory for maintainability and scalability.


Project Info

  • Project Name: JavaFX Chat System
  • Author: Eng: Mohammed Mogeab Ahmed
  • Description: A desktop chat application for real-time communication, supporting private and group chats, file/media sharing, notifications, and a modern user interface. Built for educational and demonstration purposes.

Features

  • User Authentication: Login, sign up, and Google OAuth support.
  • Private & Group Chat: Real-time messaging with friends or groups.
  • File & Media Sharing: Send images, videos, and files in chats.
  • Group Management: Create groups, add/remove members, and manage group settings.
  • Search: Find users, groups, and messages with full-text search.
  • Notifications: In-app toast notifications and Windows notifications.
  • Modern UI: Stylish, responsive interface with custom JavaFX CSS.
  • Database Integration: MySQL backend for users, messages, groups, and media.
  • Design Patterns: Uses MVC, Observer, and Factory patterns for clean code.

Project Structure

src/
  main/
    java/
      program/
        chatsystem/
          Home.java                # Main chat window/controller
          Main.java                # Application entry point
          HelloApplication.java    # JavaFX Application launcher
          ChatServer.java          # Server-side logic
          database                 # MySQL schema and sample data
          Model/                   # Data models (User, Contact, Group, Message, etc.)
          service/                 # Service layer (ChatService, GroupService)
          Controller/              # Controllers for UI and logic
          Factory/                 # Factory pattern for message creation
          observer/                # Observer pattern interfaces
          Toast/                   # Toast/notification utilities
          ui/                      # Custom UI components
    resources/
      program/
        chatsystem/
          *.fxml                  # JavaFX UI layouts (Login, Home, Group, etc.)
          *.css                   # Custom stylesheets
          images/                 # UI images/icons

Getting Started

Prerequisites

  • Java 22 or later
  • Maven 3.6+
  • MySQL server

Setup

  1. Clone the repository:

    git clone <your-repo-url>
    cd ChatSystem
  2. Database Setup:

    • Import the provided SQL schema and sample data:
      mysql -u <user> -p < src/main/java/program/chatsystem/database
    • Update your MySQL credentials in the code if needed.
  3. Build the Project:

    mvn clean install
  4. Run the Server:

    mvn exec:java -Dexec.mainClass="program.chatsystem.ChatServer"
  5. Run the Client:

    mvn javafx:run

    Or, run the main class:

    mvn exec:java -Dexec.mainClass="program.chatsystem.Main"

Usage

  • Login/Sign Up: Start at the login screen (LoginPage.fxml). Supports username/password and Google sign-in.
  • Main Chat Window: After login, access the main chat UI (home.fxml) with tabs for All Chats, Friends, and Groups.
  • Group Chat: Create and manage groups, send group messages, and view group info/settings.
  • File/Media Sharing: Use the attachment button to send images, videos, or files.
  • Search: Use the search bar to find users, groups, or messages.
  • Notifications: Receive toast and system notifications for new messages.

Design Patterns

  • MVC: Separation of UI (FXML), controllers, and models.
  • Observer: ChatObserver and ChatSubject for real-time updates.
  • Factory: MessageFactory for creating different message types.

Key Classes

  • Home.java: Main controller for chat UI and logic.
  • ChatService.java: Handles private chat logic and server communication.
  • GroupService.java: Manages group creation, membership, and group messages.
  • ChatServer.java: Multi-threaded server for handling all chat operations.
  • Model/: Contains User, Contact, Group, ChatMessage, etc.
  • Factory/MessageFactory.java: Factory for message creation.
  • observer/ChatObserver.java, observer/ChatSubject.java: Observer pattern interfaces.

UI & Styling

  • FXML Layouts: All UI screens are defined in FXML (e.g., LoginPage.fxml, home.fxml, ChatSetting.fxml).
  • Custom CSS: Modern look and feel with styles.css and popup-styles.css.
  • Responsive Design: UI adapts to different window sizes.

Database

  • MySQL schema for users, friends, groups, messages, media, and files.
  • Sample data for quick testing.
  • Full-text search indexes for fast message and group search.

Extending the Project

  • Add new message types (e.g., voice, stickers) via the Factory pattern.
  • Integrate more notification channels.
  • Enhance group management (roles, permissions).
  • Add REST API for mobile/web clients.

Credits

  • Author: Eng: Mohammed Mogeab Ahmed
  • JavaFX for UI
  • MySQL for database
  • OpenJFX, ControlsFX, and other libraries (see pom.xml for details)

License

This project is for educational purposes. Please check with your instructor or team for licensing and usage.


Enjoy chatting!

About

A modern, feature-rich chat application built with JavaFX, supporting real-time private and group messaging, file sharing, media, and more. The project uses the MVC architecture and incorporates design patterns such as Observer and Factory for maintainability and scalability.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors