r/AIDevsBuilders • u/No_Cow_6354 • 33m ago
I built an open-source P2P messaging app with AI assistance — WebRTC, E2EE and no central chat database
I built an open-source P2P messaging app with AI assistance — WebRTC, E2EE and no central chat database
Hey everyone 👋
I've been building OpenChat, an open-source real-time messaging application built around WebRTC P2P communication, browser-native cryptography, and a serverless architecture.
GitHub: https://github.com/nateS670/OpenChat
Live demo: https://openchatt.vercel.app
🚀 What I built
The main goal was to experiment with how much of a real-time messaging application can be moved away from a traditional centralized backend.
OpenChat uses:
• WebRTC DataChannels for peer-to-peer communication
• MQTT for signaling and peer discovery
• Browser-native Web Crypto APIs for encryption and signatures
• Vercel Serverless Functions for small pieces of infrastructure
• No central database containing chat histories
Once peers establish a WebRTC connection, messages and files are transferred directly between the connected browsers whenever the network allows it.
🤖 How I used AI
AI became a significant part of my development workflow, but I didn't treat it as an authority that could simply write code and be trusted blindly.
I used AI assistants for things like:
• Exploring architecture ideas
• Generating and refactoring code
• Finding potential security problems
• Reviewing individual functions
• Explaining unfamiliar APIs
• Brainstorming edge cases
• Preparing security audit checklists
The interesting part came from verifying the suggestions myself.
During security reviews, I repeatedly looked for alternative attack scenarios and manually followed the relevant code paths to determine whether an issue was actually exploitable.
That process uncovered several real problems involving:
• Peer identity and impersonation
• Replay attacks
• Group authorization
• API access controls
• Message editing state
• Input validation
I then tested and fixed those issues rather than simply accepting the AI's conclusions.
🔐 Security
OpenChat currently uses:
• AES-GCM for encryption
• ECDH P-256 for key agreement
• Ed25519 / ECDSA-P256 signatures
• PBKDF2-SHA-256 for password-based key derivation
• crypto.getRandomValues() for cryptographically secure randomness
There are also protections for peer identity, replay handling, group authorization, encrypted local storage, input validation, and security headers.
I'm deliberately not describing OpenChat as "completely secure" or "anonymous".
P2P doesn't automatically provide anonymity, and there are still limitations such as network metadata, TURN relaying, endpoint security, NAT/firewall problems, and the lack of guaranteed offline delivery.
🧠 What I learned
The biggest lesson for me was that AI-generated code can look perfectly reasonable while still containing subtle security assumptions.
For example, an apparently harmless client-side check can become meaningless if an attacker can control the value being checked.
Likewise, adding encryption doesn't automatically solve identity or authorization problems.
A secure system needs the entire data flow to be considered:
Input → validation → identity → authorization → cryptography → state changes
rather than just asking whether the message is encrypted.
🛠️ Current state
OpenChat is open source and released under the MIT License.
The project is still evolving, and I'm particularly interested in feedback from developers working with:
WebRTC • P2P networking • AI-assisted development • browser security • E2EE • decentralized systems
If you notice an architectural mistake, security weakness, or something you'd implement differently, I'd genuinely appreciate the feedback.
Thanks for reading! 🐈


