A modern, decentralized peer-to-peer chat application built with libp2p, Node.js, and a clean web interface.
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.
- 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.
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
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.
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.
git clone https://github.com/ayushjava07/chatp2p.git
cd chatp2p
npm installTo see the P2P chat in action, start two separate nodes in two terminals.
The first node acts as a listener on port 10333.
npm run server:listener- Web UI: http://localhost:3000
The second node will automatically discover the first one via mDNS.
npm run server:dialer- Web UI: http://localhost:3001
- Bridge:
server.jsserves the UI and creates a WebSocket connection to the browser. - Protocol: Connected nodes use the
/chat/1.0.0protocol for data exchange. - Flow:
- Frontend → WebSocket → server.js (Node)
- Node → libp2p Stream → Remote Node
- Remote Node → WebSocket → Remote Frontend
This project forms the foundation for the Autonomous Token Orchestration System (ATOS), demonstrating:
- Multi-agent communication
- Decentralized discovery
- Task orchestration protocols
- Cryptographic agent identity
Ayush Kumar DMP26 C4GT Applicant ATOS — Autonomous Token Orchestration System NSUT × SEETA × AIC
Built with ❤️ for decentralized communication.