Skip to main content

P2P Terminal Chat - Decentralized chat application for local networks

Project description

🍐 Pear - P2P Terminal Chat MVP

A peer-to-peer command line messaging tool for local network communication with a beautiful terminal interface powered by Rich.

Features

  • 🌐 P2P Networking: Direct peer-to-peer connections (currently mocked)
  • 💬 Real-time Chat: Beautiful terminal-based chat interface
  • 🔍 Network Discovery: Find active chat sessions on your network
  • 👥 Multi-user Support: Multiple users in the same chat session
  • 🎨 Rich UI: Beautiful terminal interface with panels, colors, and layouts
  • Commands: Built-in chat commands (/help, /quit, /stats, etc.)

Installation

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Make the CLI executable:

    chmod +x pear_cli.py
    

Usage

Basic Commands

# Show help
python pear_cli.py --help

# Start a new chat session
python pear_cli.py start [session_name]

# Join an existing session
python pear_cli.py join [session_name]

# List available sessions
python pear_cli.py list

Interactive Chat Commands

Once in a chat session, you can use these commands:

  • /help - Show available commands
  • /quit or /exit - Leave the chat
  • /clear - Clear message history
  • /stats - Show chat statistics
  • /users - Show connected users

Testing

Run the test suite to verify all components work:

python test_pear.py

MVP Architecture

The MVP consists of several modular components:

1. CLI Interface (pear_cli.py)

  • Main entry point with argument parsing
  • Command routing (start, join, list)
  • Integration between all components

2. Network Layer (network_layer.py)

  • P2P networking functionality (currently mocked)
  • Session discovery and connection management
  • Message broadcasting to peers

3. Message System (message_system.py)

  • Message handling and storage
  • Callback system for real-time updates
  • Message formatting and statistics

4. Terminal UI (terminal_ui.py)

  • Rich-powered beautiful terminal interface
  • Live updating chat display
  • User input handling and command processing

Current State

This is an MVP with mocked networking. The P2P networking components are currently simulated for testing and development purposes.

What Works:

✅ CLI argument parsing and command routing
✅ Beautiful terminal interface with Rich
✅ Message system with callbacks
✅ Mock network discovery and sessions
✅ Interactive chat interface
✅ Chat commands and user management

Next Steps:

🔄 Implement real UDP discovery protocol
🔄 Implement real TCP messaging between peers
🔄 Add proper connection management
🔄 Add user authentication
🔄 Add message encryption

Example Usage

  1. Start a session:

    python pear_cli.py start my_chat
    
  2. In another terminal, join the session:

    python pear_cli.py join my_chat
    
  3. List available sessions:

    python pear_cli.py list
    

Dependencies

  • rich: Beautiful terminal interface components
  • Python 3.7+: Required for modern Python features

Development

The codebase is structured for easy extension:

  • All networking is abstracted in NetworkManager
  • Message handling is separate from UI
  • Rich components make the UI easily customizable
  • Mock implementations allow testing without network setup

To extend functionality, focus on replacing the mock methods in NetworkManager with real UDP/TCP implementations.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pear_chat-0.1.0.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pear_chat-0.1.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file pear_chat-0.1.0.tar.gz.

File metadata

  • Download URL: pear_chat-0.1.0.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for pear_chat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9188c7d810822f1bb8faea4c13691b8b751242452ee8c6b74714aa492daa3acd
MD5 55e20ad55db8584e99ac2495dd16c668
BLAKE2b-256 9390c25e129c019ef331b1de735f89cd069dfad699e4979352d480ae5dcc42fc

See more details on using hashes here.

File details

Details for the file pear_chat-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pear_chat-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for pear_chat-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 854ee093f86a6617912db3c3936418efa8674efff3da19cdf196e92748dfa873
MD5 978bbd229c9aab0afc362f1444bb67a9
BLAKE2b-256 afc845da3e1b1f05e0c12b0e0c14c8f6f8b1caa8c2a4a76a3297f87e67fb767f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page