An open API service indexing awesome lists of open source software.

https://github.com/shoyeb45/lan-messenger-java-p2p-chat

๐Ÿ”ฅ 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.
https://github.com/shoyeb45/lan-messenger-java-p2p-chat

chat-application cross-platform gui-application java java-networking java-swing lan-chat lan-messenger local-network multithreading netwo p2p peer-to-peer socket-programming swing-gui tcp udp

Last synced: 6 months ago
JSON representation

๐Ÿ”ฅ 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.

Awesome Lists containing this project

README

          

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

![Java](https://img.shields.io/badge/java-%23ED8B00.svg?style=for-the-badge&logo=openjdk&logoColor=white) ![Java Swing](https://img.shields.io/badge/Java%20Swing-%23007396.svg?style=for-the-badge&logoColor=white) ![Socket Programming](https://img.shields.io/badge/Socket%20Programming-%2334A853.svg?style=for-the-badge&logoColor=white) ![Multithreading](https://img.shields.io/badge/Multithreading-%23FF6F00.svg?style=for-the-badge&logoColor=white) ![Real-time Messaging](https://img.shields.io/badge/Real--time%20Messaging-%239C27B0.svg?style=for-the-badge&logoColor=white) ![LAN Networking](https://img.shields.io/badge/LAN%20Networking-%2300BCD4.svg?style=for-the-badge&logoColor=white) ![P2P Communication](https://img.shields.io/badge/P2P%20Communication-%23F44336.svg?style=for-the-badge&logoColor=white) ![Cross-platform GUI](https://img.shields.io/badge/Cross--platform%20GUI-%232196F3.svg?style=for-the-badge&logoColor=white)

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)](https://yourhost.com/lanmessanger/installer.exe)** - One-click installation
๐ŸŽ **[macOS App Bundle (.dmg)](https://yourhost.com/lanmessanger/lanmessenger.dmg)** - Drag and drop installation

**Need support for other platforms?** Contact us at: [shoyebff45@gmail.com](mailto: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:**

```plaintext
๐Ÿ“ 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:
```bash
java --version
```

### **Installation & Setup**

1. **Clone the Repository**
```bash
git clone https://github.com/Shoyeb45/lan-messanger.git
cd lan-messenger
```

2. **Development Setup (VS Code)**
- Install [Extension Pack for Java by Microsoft](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack)
- Navigate to `src/main/java/com/lanmessanger/Main.java`
- Click the **Run** button above the main method


Running the application in VS Code

3. **Alternative Build Methods**
```bash
# 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**
```bash
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**
```bash
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**
- [Java Socket Programming Guide](https://www.baeldung.com/a-guide-to-java-sockets)
- [Java Swing Tutorial by Bro Code](https://www.youtube.com/@BroCodez)
- [Multithreading in Java](https://docs.oracle.com/javase/tutorial/essential/concurrency/)

### **Documentation**
- [Java Networking API](https://docs.oracle.com/javase/8/docs/api/java/net/package-summary.html)
- [Gson Documentation](https://github.com/google/gson/blob/master/UserGuide.md)
- [Maven Build Lifecycle](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html)

---

## ๐Ÿ™ Acknowledgments

### **Special Thanks**
- **[Professor Zabi](https://www.linkedin.com/in/syedzaabii/)** - Academic guidance and mentorship
- **[Baeldung](https://www.baeldung.com/)** - Comprehensive Java Socket programming tutorials
- **[Bro Code](https://www.youtube.com/@BroCodez)** - Excellent Java Swing video tutorials
- **AI Assistants** - Code review, debugging assistance, and optimization suggestions
- **[Linus Torvalds](https://github.com/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](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](mailto:shoyebff45@gmail.com)**

**Want to Contribute?** ๐Ÿš€ **Check out our [Contributing Guidelines](#contributing)**

---

**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