← wiki

peerchat

overview

A fully peer-to-peer chat application written in Rust with a terminal UI. No central server — peers connect directly using libp2p.

Phase 1 MVP is complete: peers on a LAN discover each other automatically via mDNS, and text messaging and presence status are working. File transfer, voice chat (Opus), and ASCII art webcam streaming are planned for future phases.

tech stack

Language: Rust (async with Tokio).

Networking: libp2p — Kademlia DHT (internet-wide discovery), mDNS (LAN auto-discovery), Gossipsub (message propagation), QUIC transport. All peer connections use the Noise protocol for encryption.

UI: ratatui + crossterm — cyberpunk dark theme with neon pink (#FF10F0) accents. Contact list on the left, message history top-right, input bottom-right.

Audio: cpal (cross-platform audio capture/playback) + Opus codec for low-latency voice.

Storage: SQLite.

architecture

PeerChat uses a daemon-client split: peerchat-daemon is a background service that owns all P2P networking and runs persistently, while peerchat-client is a lightweight TUI that communicates with the daemon over a local IPC socket.

This means you can detach and re-attach the UI without dropping connections, and multiple clients could theoretically connect to the same daemon.

development

Phase 1 (complete): daemon with libp2p, IPC protocol, TUI client, text messaging, mDNS local discovery, presence broadcasting.

Phase 2: message history storage, DHT discovery (internet-wide), contact management.

Phase 3: file transfer with chunking and resume support.

Phase 4: voice chat — audio capture, Opus encoding, voice streaming UI.

Phase 5: ASCII camera — webcam capture, ASCII conversion, frame streaming.

Phase 6: NAT traversal, group chats, offline messages, encryption at rest, error handling. Windows support is also planned; current focus is Linux and macOS.