A Bio-Mimetic, Self-Healing P2P Mesh Network
SHOP (Self-Healing Overlay Protocol) is a decentralized networking protocol inspired by Ant Colony Optimization. Nodes communicate using virtual pheromones, enabling emergent routing intelligence without central coordination.
| Feature | Description |
|---|---|
| ๐ง Stigmergy | Pheromone-based routing โ successful paths strengthen automatically |
| ๐ Hybrid Discovery | mDNS (LAN) + Kademlia DHT (WAN) for zero-config peering |
| ๐ WAN Connectivity | NAT traversal via Circuit Relay v2 + DCUtR hole punching |
| ๐พ Crash-Safe Persistence | sled embedded DB with zstd compression and versioned schemas |
| ๐ก๏ธ DoS Protection | Token auth, SSE rate limiting, input sanitization |
| ๐ Real-Time Dashboard | Cyberpunk-styled network visualizer with live pheromone updates |
| ๐ณ Production-Ready | Docker Compose deployment with health checks |
graph TB
subgraph Node["๐ SHOP Node"]
CLI["shop-cli"]
subgraph Actors["Actor System"]
NA["NetworkActor<br/>๐ libp2p Swarm"]
CA["ColonyActor<br/>๐ง Bio-Engine"]
AA["ApiActor<br/>๐ฅ๏ธ HTTP API"]
end
subgraph Storage["Persistence"]
Sled["sled DB<br/>๐พ Identity + Graph"]
end
end
subgraph Network["P2P Network"]
mDNS["mDNS<br/>๐ก LAN Discovery"]
Kad["Kademlia DHT<br/>๐ WAN Routing"]
Gossip["Gossipsub<br/>๐ข Pheromone Broadcast"]
Relay["Relay Servers<br/>๐ NAT Traversal"]
end
CLI --> NA
NA <--> CA
CA <--> AA
CA --> Sled
NA <--> mDNS
NA <--> Kad
NA <--> Gossip
NA <-.-> Relay
The easiest way to see the swarm in action (requires Linux/Mac):
# Runs 5 nodes, primes the network, and starts generating traffic
./scripts/simulate_swarm.shNote: This simulates on one machine. For real devices (Pi, servers, IoT), see DEPLOYMENT.md.
# Clone and enter directory
git clone https://github.com/your-org/shop-protocol.git
cd shop-protocol/shop
# Start 1 bootnode + 4 workers
docker compose up --build -d
# View logs
docker compose logs -f bootnode
# Open Dashboard
open http://localhost:3000# Install Rust (if needed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Clone and build
git clone https://github.com/your-org/shop-protocol.git
cd shop-protocol/shop
cargo build --release
# Run a node
cargo run -p shop-cli -- --api-port 3000
# Run additional nodes (in separate terminals)
cargo run -p shop-cli -- --api-port 3001
cargo run -p shop-cli -- --api-port 3002The quick start options above are for local testing. For deploying SHOP across real devices (Raspberry Pi, VPS, IoT devices, etc.), see:
๐ DEPLOYMENT.md - Comprehensive guide covering:
- โ Platform support (Linux, macOS, Windows, Raspberry Pi, Docker, Kubernetes)
- โ LAN vs WAN deployment strategies
- โ NAT traversal configuration
- โ Production readiness assessment
- โ Troubleshooting common issues
โ ๏ธ Current limitations and gaps
TL;DR:
- LAN (Same Network): Just run the binary, nodes auto-discover via mDNS
- WAN (Internet): Need a bootnode with public IP + relay configuration
- Production: Use Docker with persistent volumes and structured logging
| Endpoint | Description |
|---|---|
GET / |
Cyberpunk network visualizer |
GET /api/v1/graph |
JSON graph state |
GET /api/v1/events |
SSE stream of updates |
| Endpoint | Auth | Description |
|---|---|---|
POST /dispatch |
x-shop-token |
Send packet to peer |
POST /api/v1/control |
x-shop-token |
Update PID parameters |
Example: Dispatch a Packet
curl -X POST http://localhost:3000/dispatch \
-H "Content-Type: application/json" \
-H "x-shop-token: shop-secret" \
-d '{"destination": "12D3KooW...", "payload": "hello"}'shop/
โโโ crates/
โ โโโ shop-cli/ # CLI entry point
โ โโโ shop-node/ # Core node (actors, API, storage)
โ โโโ shop-core/ # Shared types and math
โ โโโ shop-proto/ # Protobuf definitions
โโโ Dockerfile # Multi-stage production build
โโโ docker-compose.yml # 5-node deployment
โโโ scripts/ # Simulation utilities
- Bio-Engine with PID-tuned evaporation
- Hybrid mDNS/DHT discovery
- Persistent identity and graph state
- Security hardening (auth, DoS protection)
- Docker deployment
- ๐ WAN Connectivity โ NAT traversal via Circuit Relay v2 + DCUtR hole punching
- ๐ AutoNAT โ Automatic NAT status detection
- ๐ก๏ธ Stability Hardening โ Deadlock prevention, graph pruning, Monitor Pattern
- ๐ Fail-Fast Actors โ JoinHandle tracking triggers shutdown on panic
- ๐ Multi-Colony Competition โ Red vs Blue foraging strategies
- ๐ WASM Plugins โ Hot-swap foraging logic at runtime
- ๐ Prometheus Metrics โ Production observability
MIT License โ see LICENSE for details.
Built with ๐ฆ Rust and inspired by ๐ Nature