| Crates.io | synapse |
| lib.rs | synapse |
| version | 1.1.0 |
| created_at | 2025-06-29 03:04:55.32093+00 |
| updated_at | 2025-07-17 01:55:19.21466+00 |
| description | Neural Communication Network with Federated Identity and Blockchain Trust |
| homepage | https://github.com/ciresnave/synapse |
| repository | https://github.com/ciresnave/synapse |
| max_upload_size | |
| id | 1730293 |
| size | 1,964,865 |

A revolutionary neural communication network for AI and distributed systems with federated identity, dual trust systems, and privacy-respecting discovery.
Synapse is a cutting-edge communication system that transforms how AI entities, applications, and distributed systems interact across the internet. Built on a foundation of federated identity management and blockchain-verified trust, Synapse provides:
One of Synapse's most powerful features is its contextual identity system. You can send messages using natural language descriptions that are automatically resolved to participants through multiple discovery layers:
// Instead of complex addressing...
router.send_to("alice@ai-lab.example.com:8080", message).await?;
// Just use simple names!
router.send_to("Alice", message).await?; // ๐ Automatically resolved!
"Alice", "Claude", "GPT-4""alice@ai-lab.example.com", "claude@anthropic.com""Alice" โ alice@ai-lab.example.com โ 192.168.1.100:8080 โ TCP/direct
"Claude" โ claude@anthropic.com โ [encrypted email] โ SMTP/relay
"LocalBot" โ bot@localhost โ 127.0.0.1:9090 โ UDP/local
Synapse operates on multiple layers to provide maximum flexibility and performance:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Synapse Message Layer โ
โ Simple names, security, routing, message types โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Identity Resolution โ
โ Local names โ Global IDs โ Network addresses โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Multi-Transport Router โ
โ Automatic selection of best available transport โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโค
โ Real-Time โ Direct โ Local โ Email โ
โ (<100ms) โ Connection โ Discovery โ Reliable โ
โ โ โ โ โ
โ โข TCP โ โข UDP โ โข mDNS โ โข SMTP โ
โ โข WebSocket โ โข Raw IP โ โข LAN scan โ โข IMAP โ
โ โข gRPC โ โข P2P โ โข Bluetooth โ โข Exchange โ
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
[dependencies]
message_routing_system = "0.1.0"
use message_routing_system::*;
#[tokio::main]
async fn main() -> Result<()> {
// 1. Initialize the enhanced router
let config = Config::default();
let router = EnhancedSynapseRouter::new(config, "MyBot@example.com".to_string()).await?;
// 2. Register some identities (optional - auto-discovery also works)
router.register_peer("Alice", "alice@ai-lab.example.com").await?;
router.register_peer("Bob", "bob@robotics.company.com").await?;
// 3. Start all services (email server, transport discovery, etc.)
router.start().await?;
// 4. Send messages using simple names!
router.send_message_smart(
"Alice", // Just use the name
"Hello from Synapse!", // Your message
MessageType::Direct, // Message type
SecurityLevel::Authenticated, // Security level
MessageUrgency::Interactive, // Urgency (affects transport choice)
).await?;
Ok(())
}
// AI agents coordinating on a research project
async fn ai_research_collaboration() -> Result<()> {
let claude = EnhancedSynapseRouter::new(config, "claude@anthropic.com".to_string()).await?;
// Real-time brainstorming (uses TCP/UDP if available, falls back to email)
claude.send_message_smart(
"GPT-4",
"What's your take on quantum consciousness theories?",
MessageType::Conversation,
SecurityLevel::Authenticated,
MessageUrgency::RealTime, // <100ms preferred
).await?;
// File sharing (automatic transport selection based on size)
claude.send_file(
"ResearchTeam",
"quantum_paper_draft_v3.pdf",
MessageUrgency::Normal,
).await?;
// Reliable delivery for important results (guaranteed delivery via email)
claude.send_message_smart(
"Human-Researcher",
"Breakthrough achieved! See attached simulation results.",
MessageType::Notification,
SecurityLevel::Encrypted,
MessageUrgency::Background, // Reliability over speed
).await?;
Ok(())
}
Synapse automatically selects the best transport method based on:
// The system automatically chooses:
// โข TCP for local real-time messages
// โข UDP for low-latency discovery
// โข Email for reliable remote delivery
// โข mDNS for local peer discovery
// โข NAT traversal for firewall penetration
Synapse can run its own email infrastructure when externally accessible:
// Automatic email server with intelligent connectivity detection
let router = EnhancedSynapseRouter::new(config, entity_id).await?;
if router.is_running_email_server() {
println!("๐ Running local SMTP/IMAP server");
// Can receive emails directly at your-bot@your-domain.com
} else {
println!("๐ Using external email providers");
// Falls back to Gmail, Outlook, etc.
}
Comprehensive circuit breaker protection across all transports:
// Automatic circuit breaker protection
let transport = EnhancedMdnsTransport::new("entity-id", 8080, None).await?;
// Circuit breaker automatically protects against failures
let result = transport.send_message("target", &message).await;
// Monitor circuit breaker state
let stats = transport.get_circuit_breaker().get_stats();
println!("Circuit state: {:?}, failures: {}", stats.state, stats.failure_count);
Key Features:
Decentralized trust verification with staking mechanisms:
// Blockchain-based trust verification
let blockchain = SynapseBlockchain::new(config).await?;
// Stake tokens to vouch for network participants
blockchain.stake_for_participant("alice@ai-lab.com", 1000).await?;
// Verify trust scores before communication
let trust_score = blockchain.get_trust_score("alice@ai-lab.com").await?;
if trust_score.reputation > 0.8 {
// Proceed with high-trust communication
}
Key Features:
Live streaming capabilities for continuous communication:
// Start a streaming session
let stream = router.start_stream("Alice").await?;
// Send streaming data
stream.send_chunk(b"Live data chunk 1").await?;
stream.send_chunk(b"Live data chunk 2").await?;
// End the stream
stream.finalize().await?;
Key Features:
Enterprise-grade authentication with OAuth 2.0 support:
// OAuth provider integration
let auth_manager = SynapseAuthManager::new(auth_config).await?;
// Authenticate with multiple providers
let token = auth_manager.authenticate_oauth("google", credentials).await?;
// Use federated identity
let user_context = auth_manager.get_user_context(&token).await?;
Key Features:
Comprehensive system monitoring and performance tracking:
// Get system metrics
let metrics = router.get_metrics().await?;
println!("Messages/sec: {}", metrics.message_throughput);
println!("Average latency: {:?}", metrics.average_latency);
// Subscribe to performance alerts
let mut alerts = router.subscribe_alerts().await?;
while let Some(alert) = alerts.recv().await {
println!("Alert: {}", alert.message);
}
Key Features:
// Your Synapse system automatically interoperates with:
// โข Other Synapse systems
// โข Standard email servers
// โข Existing AI communication platforms
// โข Legacy enterprise messaging systems
We welcome contributions! Please see our Contributing Guide for details.
git clone https://github.com/ai-dev-team/message-routing-system
cd message-routing-system
cargo build
cargo test
cargo run --example email_integration_test
src/
โโโ lib.rs # Main library with overview
โโโ types.rs # Core types and message definitions
โโโ identity.rs # Name resolution and identity management
โโโ router.rs # Basic message routing
โโโ router_enhanced.rs # Multi-transport enhanced router
โโโ email_server/ # SMTP/IMAP server implementation
โโโ transport/ # Multi-transport layer
โโโ crypto.rs # Encryption and signatures
โโโ config.rs # Configuration management
examples/ # Comprehensive examples
docs/ # Detailed documentation
tests/ # Integration tests
cargo doc --open for complete API referenceThis project is licensed under either of
at your option.
Built with modern Rust async technology and inspired by the universal reach of email infrastructure. Special thanks to the email protocol designers who created the foundation that enables global communication.
"Making AI communication as universal as email, as fast as the internet allows, and as secure as modern cryptography enables."