A peer-to-peer chat system built on the Hermes Architecture, enabling communication between multiple users over an overlay and AI models including GPT-4, Claude, Gemini, and Mistral.
- 🤝 Peer-to-peer messaging
- 🤖 Multi-AI integration (OpenAI, Anthropic, Google, Mistral)
- 🔄 Basic auto-response capability
- 📊 Web-based controller dashboard
- ⚡ Real-time updates via SSE
- 🎯 Configurable endpoints
The system utilizes the Hermes Architecture pattern, providing a clear separation of concerns between networking, application logic, and system management.
Controller (8000)
├── Behrooz
│ ├── UI/Peer (5000)
│ └── Proxy (10000)
├── Alice
│ ├── UI/Peer (5001)
│ └── Proxy (10001)
├── Bob
│ ├── UI/Peer (5002)
│ └── Proxy (10002)
└── BOT
├── UI/Peer (5003)
└── Proxy (10003)
-
Peer Component
- Focuses on chat logic and user interface
- Handles local message storage and display
- Manages user interactions
- Communicates only with its local proxy
-
Proxy Component
- Abstracts network complexity from the application
- Handles message routing
- Performs message transformation for AI services
- Manages API communications
-
Controller Component
- Provides centralized configuration management
- Handles peer registration
- Enables system monitoring via dashboard
- Manages endpoint configuration
-
Network Abstraction
- Applications communicate through local proxy
- Proxy handles all remote communication details
- Simplified error handling through proxy layer
- Consistent message routing
-
Centralized Management
- Single point of configuration through controller
- Dynamic endpoint updates
- System-wide monitoring
- Simplified peer discovery
- Peer: Handles chat interface and message storage
- Proxy: Routes messages and handles API communication
- Controller: Manages configuration and provides dashboard
- Python 3.7 or higher
- pip package manager
- Available ports (8000, 5000-5003, 10000-10003)
pip install quart httpx tinydb hypercornAdd your API keys in controller.py:
DEFAULT_ENDPOINTS = {
'behrooz': {
'endpoints': {
'BOT': {
'headers': {
'Authorization': 'Bearer your-openai-api-key-here',
},
},
'ANTHROPIC': {
'headers': {
'x-api-key': 'your-anthropic-api-key-here',
},
},
'GEMINI': {
'params': {
'key': 'your-google-api-key-here',
},
},
'MISTRAL': {
'headers': {
'Authorization': 'Bearer your-mistral-api-key-here',
},
},
}
}
}Configure instances in startup.py:
INSTANCES = {
'behrooz': {
'name': 'Behrooz App',
'client_port': 5000,
'proxy_port': 10000,
'auto_mode': False
},
# Add more instances as needed.
}Configure auto-responses in peer.py:
AUTO_RESPONSES = {
"alice": [
"Hi! This is Alice's automated response.",
"Hope you're having a great day!"
],
# Add more responses for other instances
}python startup.py- Controller Dashboard:
http://localhost:8000 - Chat Interfaces:
- Behrooz:
http://localhost:5000 - Alice:
http://localhost:5001 - Bob:
http://localhost:5002 - BOT:
http://localhost:5003
- Behrooz:
- Select a peer from the available list
- Type your message in the input field
- Press Enter or click Send
- For AI interactions, select BOT/ANTHROPIC/GEMINI/MISTRAL
- View active connections
- Configure endpoints
- View system status
- Manages endpoint configuration
- Provides web dashboard
- Handles proxy registration
- Routes messages between peers
- Handles API communication
- Transforms messages for different APIs
- Provides chat interface
- Stores messages locally using TinyDB
- Handles chat logic
- Starts all components
- Manages process lifecycle
- User sends message through chat interface
- Peer forwards to local proxy
- Proxy determines destination and routes message
- For AI services, proxy transforms message format
- Recipient displays message
-
Ports Already in Use
# Check ports netstat -ano | findstr "8000 5000 10000" # Kill process taskkill /PID <process_id> /F
-
Connection Issues
- Verify controller is running
- Check proxy configuration
- Confirm port availability
-
API Issues
- Verify API keys in controller configuration
- Check network connectivity
- Review console logs
Logs are available in the console with timestamp and component name.
- The system currently supports endpoint updates and peers can be distributed across different machines
- Peers receive routing information through controller (no direct peer discovery)
- Currently requires all peers to be directly reachable (not behind NAT)
- Best suited for peers in the same network or with public IP addresses
-
NAT Traversal
- Need to implement TURN server for NAT bypass
- Controller already handles peer discovery/routing
- TURN server would relay actual traffic between proxies when direct connection impossible
- Proxy layer would hide TURN relay complexity from chat application
- Would enable peer connectivity across different networks (home networks, offices etc.)
-
P2P Network Enhancement
- Improve proxy-to-proxy communication reliability
- Add better handling of network partitions
- Improve fault tolerance
-
Security Enhancements
- Add encryption for proxy-to-proxy communication
- Implement authentication system
- Secure API key management
Feel free to contribute to any of these improvements while maintaining the Hermes Architecture pattern of separating networking concerns from application logic.