A comprehensive, high-performance chat application featuring real-time messaging, peer-to-peer communication, decentralized storage, and advanced media processing capabilities.
PChat is a modern chat platform that combines the robustness of Elixir/Phoenix with the performance of Rust. The application provides secure, real-time communication with offline P2P delivery, WebRTC voice/video calls, decentralized file storage via IPFS, and AI-powered features.
- Real-time Messaging: Phoenix Channels for instant communication
- Offline P2P Delivery: Direct device-to-device message transfer (1GB in 5 seconds)
- WebRTC Integration: Voice and video calling with advanced audio processing
- Decentralized Storage: IPFS for secure, distributed file storage
- Multi-platform Support: Web, mobile, and Discord bot integration
- Advanced Security: End-to-end encryption, JWT authentication, QR code login, zero-knowledge authentication
- AI-Powered Features: Voice modulation, noise cancellation, content moderation, smart replies
- Smart Message Scheduling: User-defined send times with AI-powered optimal timing suggestions
- Voice-Activated Commands: "Hey PChat" wake word for hands-free messaging and navigation
- Rich Presence Indicators: Activity-based status updates with location-aware presence
- Anti-Screenshot Watermarking: OS-level screenshot blocking and forensic content tracing
- Flexible Chat Types: Normal, Important, and Session messaging with different behaviors
- Organization Groups: Anonymous group chats for organizational communication
- Self-Destructing Messages: Ephemeral messaging with configurable timers (seconds to weeks)
- Collaborative Whiteboards: Embedded drawing and brainstorming tools in channels and calls
- Sentiment-Aware Moderation: LLM-powered toxicity detection and automated responses
- Real-time Translation: Automatic multilingual translation for global communication
- Smart Reply Suggestions: AI-generated context-aware response suggestions
The application consists of two main components:
- Framework: Phoenix 1.7+ with Elixir 1.14+
- Database: PostgreSQL with Ecto ORM
- Real-time: Phoenix Channels and Presence
- Authentication: Guardian JWT with QR code support
- Media Processing: WebRTC integration with voice enhancement
- Web Server: Actix-web for high-performance APIs
- Async Runtime: Tokio for concurrent processing
- WebRTC: Real-time communication with voice profiles
- Audio Processing: Opus codec with noise cancellation
- Storage: IPFS client with content moderation
- Bot Integration: Discord bot with advanced commands
.
βββ elx/ # Elixir/Phoenix backend
β βββ lib/
β β βββ elx/ # Main application modules
β β β βββ application.ex # App supervision tree
β β β βββ models.ex # Ecto schemas
β β β βββ offline_messaging.ex # P2P message delivery
β β β βββ auth/ # Authentication system
β β β βββ channels/ # Real-time communication
β β β βββ chats/ # Chat types (normal, important, session)
β β β βββ media/ # WebRTC and video processing
β β β βββ storage/ # IPFS integration
β β βββ elx_web/ # Web layer
β βββ config/ # Configuration files
β βββ assets/ # Frontend assets
β βββ test/ # Test suite
βββ PRust/ # Rust performance layer
βββ src/
β βββ main.rs # Application entry point
β βββ actix_server.rs # REST API server
β βββ webrtc.rs # WebRTC manager
β βββ audio_processor.rs # Audio processing
β βββ ipfs_handler.rs # IPFS operations
β βββ tokio_runtime.rs # Async message queuing
β βββ bot.rs # Discord bot
βββ Cargo.toml # Rust dependencies
- Elixir: 1.14+ with Erlang OTP 25+
- Rust: 1.70+ with Cargo
- PostgreSQL: 13+
- Node.js: 18+ (for assets)
- IPFS: Local node or Infura API
- Discord Bot Token (optional)
# Navigate to Elixir project
cd elx
# Install dependencies
mix deps.get
# Create and migrate database
mix ecto.setup
# Install Node.js dependencies
npm install --prefix assets
# Start Phoenix server
mix phx.serverVisit localhost:4000 to access the web interface.
# Navigate to Rust project
cd PRust
# Install dependencies
cargo build
# Set environment variables
export DISCORD_TOKEN="your_discord_bot_token"
export IPFS_API_URL="http://localhost:5001" # or Infura URL
# Run the server
cargo runThe Rust layer will start on port 8080 with the REST API.
-
Start Elixir Backend:
cd elx && mix phx.server
-
Start Rust Performance Layer:
cd PRust && cargo run
-
Access Interfaces:
- Web App: http://localhost:4000
- REST API: http://localhost:8080/api
- Discord Bot: Invite bot to your server
POST /api/message- Send text messagePOST /api/message/ephemeral- Send self-destructing message with timerPOST /api/voice- Send voice messagePOST /api/file- Send file with IPFS storageGET /api/smart_replies/{message_id}- Get AI-powered reply suggestions
POST /api/webrtc/start_call- Initiate voice/video callPOST /api/webrtc/end_call- End active callPOST /api/whiteboard/create- Create collaborative whiteboard in callGET /api/whiteboard/{call_id}- Access whiteboard for active call
POST /api/ipfs/upload- Upload file to IPFSGET /api/ipfs/download/{hash}- Download from IPFS
POST /api/translate- Translate message to target languagePOST /api/moderate- Analyze message for sentiment/toxicityGET /api/moderation/report- Get moderation analytics
POST /api/groups/organization- Create anonymous organization groupPOST /api/groups/{group_id}/message- Send anonymous message to org group
!ping- Check bot status!status- Get system status!help- Show available commands!translate [lang] [text]- Translate text to specified language!whiteboard- Create collaborative whiteboard in channel!smart_reply- Get AI reply suggestions for last message!schedule [time] [message]- Schedule message for future delivery!schedule_list- List all your scheduled messages!schedule_cancel [id]- Cancel a scheduled message
DATABASE_URL=postgresql://user:pass@localhost/elx_dev
SECRET_KEY_BASE=your_secret_key
IPFS_API_URL=http://localhost:5001DISCORD_TOKEN=your_discord_token
IPFS_API_URL=http://localhost:5001
RUST_LOG=infoThe application supports multiple voice modulation profiles:
- male_us: Standard US male voice
- male_europe: European male accent
- female_brazil: Brazilian female voice
- female_east_asia: East Asian female voice
The application supports three distinct chat types with different behaviors and lifecycles:
- Normal Chat: Standard messaging with 24-hour message retention. Messages are delivered in real-time when possible, with P2P fallback for offline delivery.
- Important Chat: Priority messaging that never expires. Features delivery confirmation, escalation workflows, and guaranteed delivery even for offline recipients.
- Session Chat: Temporary conversations with 5-minute auto-cleanup. Perfect for quick, ephemeral interactions that self-destruct after a short time.
- Anonymous Communication: Groups marked as "organization" type maintain sender anonymity
- Irreversible: Organization groups cannot be modified or deleted once created
- Secure Collaboration: Enables confidential team communication without revealing individual identities
- Audit Trail: All messages are logged while preserving anonymity
- Messages are queued when recipients are offline
- Direct P2P delivery when peers come online
- High-speed file transfer (1GB in 5 seconds target)
- Automatic retry with exponential backoff
- Voice Modulation: Real-time voice changing with pitch/formant shifting
- Noise Cancellation: Multi-algorithm noise reduction
- Quality Enhancement: Dynamic range compression and equalization
- Opus Codec: Low-latency audio compression
- Malware Scanning: Pattern-based threat detection
- NSFW Content: Image and video analysis
- Text Filtering: Inappropriate content detection
- Private Data: Email/phone/credit card detection
- IPFS Integration: Content-addressed storage
- Encryption: AES-256-GCM file encryption
- Compression: Zstd compression for efficiency
- Optimization: Automatic image/video optimization
- Ephemeral Messaging: Messages automatically delete after configurable timers (seconds to weeks)
- E2EE Guarantees: End-to-end encryption maintained throughout message lifecycle
- Decentralized Routing: Messages routed through P2P networks before self-destruction
- Timer Options: Flexible timing from instant deletion to extended retention periods
- Screenshot Protection: Advanced anti-screenshot measures for sensitive communications
- Embedded Drawing Tools: Integrated whiteboards in channels and video calls
- Real-time Collaboration: Multi-user simultaneous editing and brainstorming
- Channel Integration: Whiteboards launched via slash commands with permission inheritance
- Browser-Based Canvases: No additional installations required for participants
- Video Call Integration: Whiteboards accessible during voice/video sessions
- LLM-Powered Analysis: Advanced language models for context-aware content review
- Toxicity Detection: Multi-language toxicity scoring (50+ languages supported)
- Sentiment Scoring: Automated severity levels (Low-Critical) with smart responses
- Automated Actions: Auto-nudge, cool-down periods, or moderator escalation
- Code-Switching Detection: Identifies abuse attempts across multiple languages
- Automatic Translation: Instant translation of incoming and outgoing messages
- Multilingual Support: Seamless communication across language barriers
- Context Preservation: Maintains conversation flow and intent during translation
- Inline Translation: Translations appear instantly without leaving chat interface
- Global Communication: Enables worldwide collaboration without language constraints
- User-Defined Send Times: Set specific times for messages to be delivered to receivers
- Universal Availability: Works in all chat sections (Normal, Important, Session, Group chats)
- AI-Powered Optimization: Intelligent suggestions for optimal send times based on recipient behavior
- Timezone Intelligence: Automatic timezone handling for global messaging
- Delivery Confirmation: Real-time tracking and confirmation of message delivery
- Smart Retry Logic: Automatic retry with exponential backoff for failed deliveries
- Privacy-Aware: User-controlled scheduling preferences and analytics
- Engagement Analytics: Success rate tracking and delivery performance metrics
- Context-Aware Suggestions: LLM-generated response suggestions based on conversation history
- Workflow Automation: Smart routing to support, ticket logging, or specialized responses
- Professional Responses: Polished reply suggestions for business communications
- Privacy-First: All processing respects end-to-end encryption boundaries
- Customizable Suggestions: Adaptable to different communication styles and contexts
- OS-Level Screenshot Blocking: Native platform integration to prevent unauthorized screenshots on iOS and Android
- Dynamic User-Specific Watermarks: Real-time generation of unique, user-specific visual watermarks
- Screen Recording Prevention: Detection and blocking of screen mirroring and recording attempts
- App Switcher Protection: Prevention of content capture through app switching interfaces
- Forensic Watermarking: Invisible digital signatures for tracing leaked content back to source
- Multi-Layered Protection: Frontend and backend integration for comprehensive content security
- Real-Time Updates: Dynamic watermark rotation to prevent circumvention attempts
- Activity-Based Status Updates: Automatic status changes based on user activities (typing, in meeting, etc.)
- Location-Aware Presence: Optional location sharing with privacy controls (approximate, city-level, or disabled)
- Meeting Status Synchronization: Integration with calendar systems for automatic "in meeting" status
- Custom Availability Settings: User-defined availability states with custom messages and expiration times
- Contextual Presence Information: Rich metadata about current activity and engagement level
- Privacy-Controlled Sharing: Granular privacy settings for presence information sharing
- Real-Time Broadcasting: Instant presence updates via Phoenix Channels to all connected clients
- "Hey PChat" Wake Word: Customizable wake word detection with high accuracy speech recognition
- Voice Message Dictation: Hands-free message composition and sending
- Smart Query Responses: Natural language processing for intelligent command interpretation
- Privacy-Aware Processing: Configurable privacy modes (high, standard, offline) for voice data handling
- Custom Wake Word Support: Personalized wake words with validation and security checks
- Session Management: Intelligent voice session handling with automatic timeouts and cleanup
- Command History: Voice command logging and analytics for usage optimization
- Password-Less Authentication: Schnorr zero-knowledge proofs for secure login without credential exposure
- Anonymous Group Verification: Membership verification without revealing individual identities
- KYC-Compliant Privacy: Selective disclosure of attributes for regulatory compliance
- Anti-Phishing Protection: Cryptographic domain verification to prevent phishing attacks
- Challenge-Response Protocol: Time-limited authentication challenges with automatic cleanup
- Session Token Management: Secure session creation with configurable expiration
- Multi-Factor Integration: Combines ZKP with existing authentication methods for enhanced security
cd elx
mix testcd PRust
cargo test# Run both test suites
cd elx && mix test && cd ../PRust && cargo test- Message Delivery: < 100ms for online peers
- P2P Transfer: 1GB file in < 5 seconds
- Concurrent Users: 10,000+ simultaneous connections
- Audio Latency: < 50ms end-to-end
- Storage: Decentralized with IPFS replication
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Elixir: Follow Phoenix conventions and use proper supervision trees
- Rust: Use async/await patterns and proper error handling
- Testing: Maintain >80% test coverage
- Documentation: Update README and inline docs for new features
This project is licensed under the MIT License - see the LICENSE file for details.
- Phoenix Framework: For the robust Elixir web framework
- Actix: For high-performance Rust web services
- IPFS: For decentralized storage capabilities
- WebRTC: For real-time communication standards
- Tokio: For async runtime excellence
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Discord: Join our community server
Built with β€οΈ using Elixir, Phoenix, Rust, and modern web technologies