Skip to content

πŸ”₯ Real-time P2P chat application for LAN networks built with Java Socket Programming. Cross-platform messaging with auto-discovery, persistent storage, and modern Swing GUI. Perfect for local network communication without internet dependency.

License

Notifications You must be signed in to change notification settings

Shoyeb45/lan-messenger-java-p2p-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

74 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LAN Messenger: Real-Time Peer-to-Peer Chat Application

Java Java Swing Socket Programming Multithreading Real-time Messaging LAN Networking P2P Communication Cross-platform GUI

A powerful peer-to-peer Java chat application designed for seamless communication between devices on the same Local Area Network (LAN). Built with advanced Socket programming, multithreading, and an intuitive Swing GUI for cross-platform compatibility.

LAN Messenger Logo


πŸš€ Key Features

✨ What Makes LAN Messenger Special?

πŸ”₯ Zero Internet Required - Works entirely on your local network
⚑ Real-time Communication - Instant message delivery with TCP protocol
πŸ” Auto Friend Discovery - Automatically find other users on your network
πŸ’Ύ Persistent Chat History - All conversations saved locally and securely
🎨 Modern Single-Page Interface - React-inspired design with smooth navigation
πŸ“± Fully Responsive - Adapts to any screen size and resolution
🌐 Cross-Platform Compatible - Works on Windows, macOS, and Linux


πŸ“¦ Quick Downloads

Ready-to-use installers for popular operating systems:

πŸ’» Windows Installer (.exe) - One-click installation
🍎 macOS App Bundle (.dmg) - Drag and drop installation

Need support for other platforms? Contact us at: shoyebff45@gmail.com


🎯 Core Features Deep Dive

LAN Messenger Start Page

Clean and intuitive start page

1. Modern Single-Page Application (SPA)

Built with a contemporary approach similar to modern web applications, featuring:

  • State Management: React-inspired state handling using Java interfaces and classes
  • Smooth Navigation: Seamless page transitions without window reloads
  • Enhanced UX: Improved accessibility and user experience

Navigation Interface

Intuitive navigation bar for easy access to all features

2. Intelligent Friend Discovery

Advanced network scanning capabilities:

  • UDP Protocol: Lightning-fast user detection on the same network
  • Real-time Updates: Automatically refreshes available users
  • Zero Configuration: Works out-of-the-box without manual setup

Friend Discovery User List

3. Secure Local Storage

Your data remains private and secure:

  • JSON Storage: Efficient data serialization using GSON library
  • Local-Only: All data stored exclusively on your device
  • Persistent History: Conversations and friend lists automatically saved

Data Structure Local Storage

4. Manual Friend Addition

Flexible friend management:

  • IP Address Support: Add friends directly using their IP address
  • Friend Requests: Secure friend request system
  • Contact Management: Easy-to-use friend list interface

Add Friend Interface

Simple and secure friend addition process

5. Responsive Design

Adapts to any screen configuration:

  • Dynamic Layouts: Automatically adjusts to window resizing
  • Multi-Resolution Support: Works on various screen sizes
  • Consistent Experience: Maintains functionality across different dimensions

Responsive Design

6. Real-Time Messaging

Experience instant communication:

  • TCP Protocol: Reliable message delivery
  • Multi-threading: Smooth performance without UI freezing
  • Live Status Updates: See when friends are online and available

πŸ—οΈ Project Architecture

Modular design for maximum maintainability and scalability:

πŸ“ LAN-Messenger/
β”œβ”€β”€ πŸ“ lib/                        # External JAR dependencies
β”œβ”€β”€ πŸ“ public/                     # Static assets and images
β”‚   └── πŸ“ images/
β”‚       β”œβ”€β”€ πŸ“ app/               # Application icons and graphics
β”‚       └── πŸ“ readme/            # Documentation images
└── πŸ“ src/
    └── πŸ“ main/
        └── πŸ“ java/
            └── πŸ“ com/
                └── πŸ“ lanmessanger/
                    β”œβ”€β”€ πŸ“ app/           # Application entry point and configuration
                    β”œβ”€β”€ πŸ“ database/      # Data persistence and management
                    β”œβ”€β”€ πŸ“ models/        # Data models and entity schemas
                    β”œβ”€β”€ πŸ“ network/       # Core networking functionality
                    β”‚   β”œβ”€β”€ πŸ“ client/           # Client-side communication
                    β”‚   β”œβ”€β”€ πŸ“ clientHandler/    # Connection management
                    β”‚   β”œβ”€β”€ πŸ“ discovery/        # Network discovery logic
                    β”‚   └── πŸ“ server/           # Server-side operations
                    └── πŸ“ ui/            # User interface components
                        β”œβ”€β”€ πŸ“ components/        # Reusable UI components
                        β”‚   β”œβ”€β”€ πŸ“ addFriendPage/
                        β”‚   β”œβ”€β”€ πŸ“ chatPage/
                        β”‚   β”œβ”€β”€ πŸ“ navBar/
                        β”‚   └── πŸ“ scannerPage/
                        β”œβ”€β”€ πŸ“ pages/            # Application pages
                        β”œβ”€β”€ πŸ“ router/           # SPA-style navigation
                        β”œβ”€β”€ πŸ“ state/            # Centralized state management
                        └── πŸ“ utils/            # Helper utilities

πŸ“‹ Architecture Overview

Component Responsibility Key Features
app/ Application lifecycle and global configuration Launch logic, settings management
network/ Core networking operations Socket programming, P2P connections, discovery
ui/ User interface and user experience Swing components, responsive design
models/ Data structures and persistence Entity definitions, JSON serialization
database/ Local data management Friend lists, chat history, user preferences

πŸ› οΈ Technology Stack

Core Technologies

  • β˜• Java 17+ - Modern Java features and performance optimizations
  • 🎨 Java Swing - Cross-platform GUI framework (javax.swing)
  • 🌐 Java Networking - Socket programming with TCP/UDP protocols (java.net)
  • ⚑ Collections Framework - Efficient data structure management
  • πŸ“„ Gson Library - JSON serialization and deserialization (com.google.gson)
  • 🎯 Ikonli FontAwesome - Modern icon pack (org.kordamp.ikonli)

Development Tools

  • πŸ’» VS Code IDE - Modern development environment
  • πŸ“š Git & GitHub - Version control and collaboration
  • πŸ”§ Maven - Dependency management and build automation

πŸš€ Quick Start Guide

Prerequisites

Ensure you have Java 17 or higher installed:

java --version

Installation & Setup

  1. Clone the Repository

    git clone https://github.com/Shoyeb45/lan-messanger.git
    cd lan-messenger
  2. Development Setup (VS Code)

    Running the application in VS Code

  3. Alternative Build Methods

    # Using Maven (if pom.xml is configured)
    mvn clean compile exec:java
    
    # Direct compilation (for simple setups)
    javac -cp "lib/*:src" src/main/java/com/lanmessanger/Main.java
    java -cp "lib/*:src" com.lanmessanger.Main

Contributing

We welcome contributions! Here's how to get started:

  1. Create a Feature Branch

    git checkout -b feature/your-feature-name
  2. Implement Your Feature

    • Write clean, documented code
    • Test thoroughly on multiple platforms
    • Follow existing code style conventions
  3. Submit Your Changes

    git add .
    git commit -m "Add: your feature description"
    git push origin feature/your-feature-name
  4. Create a Pull Request

    • Include detailed description of changes
    • Add screenshots for UI changes
    • Reference any related issues

πŸ”§ How It Works

Network Architecture

LAN Messenger implements a sophisticated peer-to-peer networking model:

P2P Network Architecture

Decentralized P2P communication between LAN Messenger instances

Key Networking Features:

  • TCP Protocol: Reliable message delivery with connection-oriented communication
  • UDP Discovery: Fast and lightweight user detection broadcasts
  • Multi-threading: Concurrent handling of multiple connections
  • Dual Role Architecture: Each instance acts as both client and server

Client-Server Architecture

Each instance simultaneously operates as client and server

User Interface Architecture

Built with a modern, component-based approach:

UI Architecture

Hierarchical component structure with centralized state management

UI Design Principles:

  • Single Page Application: Smooth navigation without window refreshes
  • Component Reusability: Modular design for maintainable code
  • State Management: Centralized application state similar to modern web frameworks
  • Responsive Layout: Dynamic adaptation to different screen sizes

πŸ§ͺ Testing Guide

Local Testing Setup

Requirements:

  • Two or more devices on the same Wi-Fi network
  • LAN Messenger installed on each device

Step-by-Step Testing:

  1. Launch Application

    • Open LAN Messenger on both devices
    • Ensure both devices are connected to the same network
  2. Establish Connection

    • On Device A: Navigate to "Add Friend" page
    • Enter the IP address of Device B
    • Click "Add Friend"
  3. Accept Friend Request

    • Device B will receive a friend request notification
    • Accept the request to establish connection
  4. Test Messaging

    • Send messages between devices
    • Verify real-time delivery and persistence
    • Test various message types and lengths

Success Indicators:

  • βœ… Real-time message delivery
  • βœ… Message persistence after app restart
  • βœ… Online/offline status updates
  • βœ… Stable connection during extended use

πŸ’» Platform Support

Platform Status Notes
Windows 10/11 βœ… Full Support Native installer available
macOS βœ… Full Support DMG package available
Linux (Ubuntu/Debian) βœ… Full Support JAR executable
Linux (Other Distros) βœ… Compatible May require Java installation

System Requirements

  • Java Runtime: Version 17 or higher
  • RAM: Minimum 512MB available
  • Network: Active LAN/Wi-Fi connection
  • Storage: 50MB free space

πŸ“š Additional Resources

Learning Resources

Documentation


πŸ™ Acknowledgments

Special Thanks

  • Professor Zabi - Academic guidance and mentorship
  • Baeldung - Comprehensive Java Socket programming tutorials
  • Bro Code - Excellent Java Swing video tutorials
  • AI Assistants - Code review, debugging assistance, and optimization suggestions
  • Linus Torvalds - For creating Git, enabling collaborative development

Open Source Libraries

  • Google Gson - JSON serialization library
  • Ikonli - Icon pack integration
  • Java Development Kit - Core runtime and development tools

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for complete details.

Key Points:

  • βœ… Commercial use allowed
  • βœ… Modification and distribution permitted
  • βœ… Private use encouraged
  • ❗ No warranty provided

πŸ”— Connect & Support

Found this project helpful? ⭐ Star the repository to show your support!

Questions or Issues? πŸ“§ shoyebff45@gmail.com

Want to Contribute? πŸš€ Check out our Contributing Guidelines


Keywords: LAN Messenger, Java Chat Application, P2P Messaging, Local Network Communication, Socket Programming, Real-time Chat, Cross-platform Messaging, Network Discovery, Peer-to-Peer, Java Swing GUI, TCP/UDP Protocol, Multithreading, Local Area Network, Instant Messaging, Java Networking

About

πŸ”₯ Real-time P2P chat application for LAN networks built with Java Socket Programming. Cross-platform messaging with auto-discovery, persistent storage, and modern Swing GUI. Perfect for local network communication without internet dependency.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages