# DevMesh
Peer-to-peer dev mesh for sharing local services across machines. Run services locally, discover peers on your network, and route traffic transparently by service name.
## Features
- Register local services (from `devmesh.toml`)
- HTTP reverse proxy routes by Host header (e.g. `http://mono:8080/`)
- Peer discovery via UDP broadcast (same LAN or VPN)
- Version awareness with optional strict mode
- Branch-based namespaces (git branch → isolated mesh)
- Web dashboard and ASCII/JSON graph
- Graceful shutdown (Ctrl+C)
## Install
1. **Install Rust** (if needed): [rustup.rs](https://rustup.rs)
2. **Install devmesh:**
```bash
cargo install devmesh
```
Or from this repo: `cargo install --path .`
## Quick Start
1. **Create `devmesh.toml`** in your project root:
```toml
[services.mono]
port = 3000
version = "1.0.0"
```
2. **Add host resolution** (one-time):
```bash
devmesh install
```
Add the printed line to `/etc/hosts` (or `C:\Windows\System32\drivers\etc\hosts`).
3. **Start the proxy** (keeps running):
```bash
devmesh proxy
```
4. **In another terminal**, register and run your service:
```bash
devmesh run mono
# then start your app on port 3000
```
5. **Access** via `http://mono:8080/`
6. **On another machine**, run `devmesh proxy` and `devmesh run mono`. They discover each other; requests route to the nearest peer.
## Commands
| `setup` | Interactive setup wizard (create config, add hosts) |
| `from-docker` | Discover services from running Docker containers (`--write` to merge into config) |
| `run <service>` | Register and start agent for a service |
| `stop <service>` | Unregister service |
| `status` | List local and peer services (`--routes` for routing view) |
| `install` | Show /etc/hosts line for service names |
| `proxy` | Start HTTP proxy + discovery (Ctrl+C to stop) |
| `graph` | Show mesh (`--json` for JSON, `-o file` to write) |
| `dashboard` | Web UI at http://127.0.0.1:3005 |
| `docs` | Serve documentation at http://127.0.0.1:3006 |
| `db status` | Registry and peers paths/stats |
**Global:** `--config PATH` — use specific config file
## Configuration (devmesh.toml)
```toml
[proxy]
port = 8080
version_strict = false # true = reject on version mismatch
cache_ttl_secs = 1
[discovery]
port = 35555
# broadcast_addr = "10.42.0.255" # for VPN/subnet
[namespace]
override = "my-ns" # optional, overrides git branch
auto = true # default: use git branch
[services.mono]
port = 3000
version = "1.0.0"
# Multi-port: api also reachable at api-8001:8080
[services.api]
port = 8000
ports = [8001]
```
Use `devmesh from-docker` to auto-discover services from running Docker containers.
## Environment
| `DEVMESH_CONFIG` | Path to config (overrides devmesh.toml) |
| `RUST_LOG` | Log level (e.g. `devmesh=debug`) |
## Namespaces
By default, namespace = git branch (sanitized: `feature/foo` → `feature-foo`). Services and peers are isolated by namespace. Override via `[namespace] override` or `X-DevMesh-Namespace` header.
## Dashboard
```bash
devmesh dashboard
```
Opens http://127.0.0.1:3005. Use `?namespace=` to view other namespaces.
## Docs
```bash
devmesh docs
```
Serves documentation at http://127.0.0.1:3006.
## License
See [LICENSE](LICENSE) file.