Skip to content

ayushjava07/chatp2p

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⬡ P2P Chat Application

A modern, decentralized peer-to-peer chat application built with libp2p, Node.js, and a clean web interface.

📌 Overview

This project implements a direct Peer-to-Peer Chat where two nodes communicate over a secure network stack — no central server required. It bridges the powerful libp2p networking layer with a premium web UI for a seamless user experience.

🚀 Features

  • True P2P: Direct communication between nodes using libp2p.
  • Auto-Discovery: Nodes find each other on the local network via mDNS.
  • End-to-End Encryption: Secure communication using the Noise protocol.
  • Modern UI: Dark-themed, responsive web interface with real-time status updates.
  • WebSocket Bridge: Efficiently connects the libp2p stream to the browser.

📁 Project Structure

p2p-chat/
├── src/
│   ├── public/         # Frontend assets (HTML, CSS, JS)
│   ├── server.js       # Express + WebSocket Bridge
│   ├── libp2p.js       # libp2p node configuration
│   ├── listener.js     # Original terminal listener
│   ├── dialer.js       # Original terminal dialer
│   └── stream.js       # Stream utilities
├── package.json
└── README.md

🧠 Key Concepts

1. libp2p Stack

Uses a modular approach to networking:

  • Transport: TCP and WebSockets for reliable delivery.
  • Security: Noise protocol for authenticated encryption 🔐.
  • Multiplexing: Yamux for multiple streams over one connection.
  • Discovery: mDNS for zero-config local peer detection.

2. Multiaddr & Peer ID

Peers are identified by a unique Peer ID and reached via Multiaddr (e.g., /ip4/127.0.0.1/tcp/10333/p2p/PEER_ID), which act like complete postal addresses for decentralized nodes.

🛠️ Installation

git clone https://github.com/ayushjava07/chatp2p.git
cd chatp2p
npm install

💻 How to Run

To see the P2P chat in action, start two separate nodes in two terminals.

Step 1: Start the Listener

The first node acts as a listener on port 10333.

npm run server:listener

Step 2: Start the Dialer

The second node will automatically discover the first one via mDNS.

npm run server:dialer

📖 How it Works

  1. Bridge: server.js serves the UI and creates a WebSocket connection to the browser.
  2. Protocol: Connected nodes use the /chat/1.0.0 protocol for data exchange.
  3. Flow:
    • Frontend → WebSocket → server.js (Node)
    • Node → libp2p Stream → Remote Node
    • Remote Node → WebSocket → Remote Frontend

🔗 Connection to ATOS (C4GT)

This project forms the foundation for the Autonomous Token Orchestration System (ATOS), demonstrating:

  • Multi-agent communication
  • Decentralized discovery
  • Task orchestration protocols
  • Cryptographic agent identity

✨ Author

Ayush Kumar DMP26 C4GT Applicant ATOS — Autonomous Token Orchestration System NSUT × SEETA × AIC


Built with ❤️ for decentralized communication.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors